Skip to content

Commit 2c826b1

Browse files
authored
Migrate Provider Releases from TeamCity to GitHub Actions (hashicorp#1408)
Internal RFC References: * ENGSRV-035 * ENGSRV-064 * SEC-036 * SEC-061 * TF-279 _Please note: This process can be adjusted to suit your needs, but it will require changes to the workflow setup._ The initial release workflow submitted here is triggered by pushing a semantic version tag prepended with a `v` to the repository. For example: ```shell git switch main # or your release branch git pull git tag v1.2.3 git push origin v1.2.3 ``` The most important distinction from the TeamCity release process is that the repository must be fully prepared for the release, including the `CHANGELOG.md` file. Providers can decide the most appropriate process to manage the CHANGELOG or any release notes as part of this new process. This initial workflow will automatically grab contents from the top of the CHANGELOG through the previous release tag header line. [Example provider CHANGELOG](https://github.com/hashicorp/terraform-provider-tls/blob/156ae39c7e55ee8597f859a77ae2db739527376b/CHANGELOG.md) and its [GitHub Release description](https://github.com/hashicorp/terraform-provider-tls/releases/tag/v3.3.0). Please reach out if you have questions.
1 parent 18d75c1 commit 2c826b1

File tree

3 files changed

+130
-0
lines changed

3 files changed

+130
-0
lines changed

.github/workflows/release.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
go-version:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
version: ${{ steps.go-version.outputs.version }}
16+
steps:
17+
- uses: actions/checkout@v3
18+
- id: go-version
19+
run: echo "::set-output name=version::$(cat ./.go-version)"
20+
release-notes:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v3
24+
with:
25+
fetch-depth: 0
26+
- name: Generate Release Notes
27+
run: sed -n -e "1{/# /d;}" -e "2{/^$/d;}" -e "/# $(git describe --abbrev=0 --exclude="$(git describe --abbrev=0 --match='v*.*.*' --tags)" --match='v*.*.*' --tags | tr -d v)/q;p" CHANGELOG.md > release-notes.txt
28+
- uses: actions/upload-artifact@v2
29+
with:
30+
name: release-notes
31+
path: release-notes.txt
32+
retention-days: 1
33+
terraform-provider-release:
34+
name: 'Terraform Provider Release'
35+
needs: [go-version, release-notes]
36+
uses: hashicorp/ghaction-terraform-provider-release/.github/workflows/hashicorp.yml@v1
37+
secrets:
38+
hc-releases-aws-access-key-id: '${{ secrets.TF_PROVIDER_RELEASE_AWS_ACCESS_KEY_ID }}'
39+
hc-releases-aws-secret-access-key: '${{ secrets.TF_PROVIDER_RELEASE_AWS_SECRET_ACCESS_KEY }}'
40+
hc-releases-aws-role-arn: '${{ secrets.TF_PROVIDER_RELEASE_AWS_ROLE_ARN }}'
41+
hc-releases-fastly-api-token: '${{ secrets.HASHI_FASTLY_PURGE_TOKEN }}'
42+
hc-releases-github-token: '${{ secrets.HASHI_RELEASES_GITHUB_TOKEN }}'
43+
hc-releases-terraform-registry-sync-token: '${{ secrets.TF_PROVIDER_RELEASE_TERRAFORM_REGISTRY_SYNC_TOKEN }}'
44+
setup-signore-github-token: '${{ secrets.HASHI_SIGNORE_GITHUB_TOKEN }}'
45+
signore-client-id: '${{ secrets.SIGNORE_CLIENT_ID }}'
46+
signore-client-secret: '${{ secrets.SIGNORE_CLIENT_SECRET }}'
47+
with:
48+
release-notes: true
49+
setup-go-version: '${{ needs.go-version.outputs.version }}'

.goreleaser.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
archives:
2+
- files:
3+
# Ensure only built binary is archived
4+
- 'none*'
5+
format: zip
6+
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
7+
before:
8+
hooks:
9+
- 'go mod download'
10+
builds:
11+
- # Binary naming only required for Terraform CLI 0.12
12+
binary: '{{ .ProjectName }}_v{{ .Version }}_x5'
13+
env:
14+
- CGO_ENABLED=0
15+
flags:
16+
- -trimpath
17+
goos:
18+
- darwin
19+
- freebsd
20+
- linux
21+
- windows
22+
goarch:
23+
- '386'
24+
- amd64
25+
- arm
26+
- arm64
27+
ignore:
28+
- goarch: arm
29+
goos: windows
30+
- goarch: arm64
31+
goos: freebsd
32+
- goarch: arm64
33+
goos: windows
34+
ldflags:
35+
- -s -w -X main.Version={{.Version}}
36+
mod_timestamp: '{{ .CommitTimestamp }}'
37+
checksum:
38+
algorithm: sha256
39+
extra_files:
40+
- glob: 'terraform-registry-manifest.json'
41+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
42+
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
43+
publishers:
44+
- checksum: true
45+
# Terraform CLI 0.10 - 0.11 perform discovery via HTTP headers on releases.hashicorp.com
46+
# For providers which have existed since those CLI versions, exclude
47+
# discovery by setting the protocol version headers to 5.
48+
cmd: hc-releases upload-file {{ abs .ArtifactPath }} -header=x-terraform-protocol-version=5 -header=x-terraform-protocol-versions=5.0
49+
env:
50+
- AWS_ACCESS_KEY_ID={{ .Env.AWS_ACCESS_KEY_ID }}
51+
- AWS_SECRET_ACCESS_KEY={{ .Env.AWS_SECRET_ACCESS_KEY }}
52+
- AWS_SESSION_TOKEN={{ .Env.AWS_SESSION_TOKEN }}
53+
extra_files:
54+
- glob: 'terraform-registry-manifest.json'
55+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
56+
name: hc-releases
57+
signature: true
58+
release:
59+
extra_files:
60+
- glob: 'terraform-registry-manifest.json'
61+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
62+
ids:
63+
- none
64+
signs:
65+
- args: ["sign", "--dearmor", "--file", "${artifact}", "--out", "${signature}"]
66+
artifacts: checksum
67+
cmd: signore
68+
signature: ${artifact}.sig
69+
- args: ["sign", "--dearmor", "--file", "${artifact}", "--out", "${signature}"]
70+
artifacts: checksum
71+
cmd: signore
72+
id: key-id
73+
signature: ${artifact}.72D7468F.sig
74+
snapshot:
75+
name_template: "{{ .Tag }}-next"

terraform-registry-manifest.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"version": 1,
3+
"metadata": {
4+
"protocol_versions": ["5.0"]
5+
}
6+
}

0 commit comments

Comments
 (0)