1+ name : release
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ versionNumber :
7+ description : ' Release version number (v#.#.#)'
8+ type : string
9+ required : true
10+
11+ permissions :
12+ contents : read # Changelog commit operations use service account PAT
13+
14+ env :
15+ CI_COMMIT_AUTHOR : hc-github-team-tf-provider-devex
16+ CI_COMMIT_EMAIL :
[email protected] 17+
18+ jobs :
19+ changelog-version :
20+ runs-on : ubuntu-latest
21+ outputs :
22+ version : ${{ steps.changelog-version.outputs.version }}
23+ steps :
24+ - id : changelog-version
25+ run : echo "version=$(echo "${{ inputs.versionNumber }}" | cut -c 2-)" >> "$GITHUB_OUTPUT"
26+
27+ changelog :
28+ needs : changelog-version
29+ runs-on : ubuntu-latest
30+ steps :
31+ - name : Checkout
32+ uses : actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
33+ with :
34+ fetch-depth : 0
35+ # Avoid persisting GITHUB_TOKEN credentials as they take priority over our service account PAT for `git push` operations
36+ # More details: https://github.com/actions/checkout/blob/b4626ce19ce1106186ddf9bb20e706842f11a7c3/adrs/0153-checkout-v2.md#persist-credentials
37+ persist-credentials : false
38+ - name : Batch changes
39+ uses : miniscruff/changie-action@6dcc2533cac0495148ed4046c438487e4dceaa23 # v2
40+ with :
41+ version : latest
42+ args : batch ${{ needs.changelog-version.outputs.version }}
43+ - name : Merge changes
44+ uses : miniscruff/changie-action@6dcc2533cac0495148ed4046c438487e4dceaa23 # v2
45+ with :
46+ version : latest
47+ args : merge
48+ - name : Git push changelog
49+ run : |
50+ git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
51+ git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
52+ git add .
53+ git commit -a -m "Update changelog"
54+ git push "https://${{ env.CI_COMMIT_AUTHOR }}:${{ secrets.TF_DEVEX_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
55+
56+ release-tag :
57+ needs : changelog
58+ runs-on : ubuntu-latest
59+ steps :
60+ - name : Checkout
61+ uses : actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
62+ with :
63+ fetch-depth : 0
64+ # Default input is the SHA that initially triggered the workflow. As we created a new commit in the previous job,
65+ # to ensure we get the latest commit we use the ref for checkout: 'refs/heads/<branch_name>'
66+ ref : ${{ github.ref }}
67+ # Avoid persisting GITHUB_TOKEN credentials as they take priority over our service account PAT for `git push` operations
68+ # More details: https://github.com/actions/checkout/blob/b4626ce19ce1106186ddf9bb20e706842f11a7c3/adrs/0153-checkout-v2.md#persist-credentials
69+ persist-credentials : false
70+
71+ - name : Git push release tag
72+ run : |
73+ git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
74+ git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
75+
76+ git tag "${{ inputs.versionNumber }}"
77+ git push "https://${{ env.CI_COMMIT_AUTHOR }}:${{ secrets.TF_DEVEX_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" "${{ inputs.versionNumber }}"
78+
79+ goreleaser :
80+ needs : [ changelog-version, changelog, release-tag ]
81+ runs-on : ubuntu-latest
82+ permissions :
83+ contents : write # Needed for goreleaser to create GitHub release
84+ issues : write # Needed for goreleaser to close associated milestone
85+ steps :
86+ - uses : actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
87+ with :
88+ ref : ${{ inputs.versionNumber }}
89+ fetch-depth : 0
90+
91+ - uses : actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
92+ with :
93+ go-version-file : ' go.mod'
94+
95+ - name : Generate Release Notes
96+ run : |
97+ cd .changes
98+ sed -e "1{/# /d;}" -e "2{/^$/d;}" ${{ needs.changelog-version.outputs.version }}.md > /tmp/release-notes.txt
99+
100+ - uses : goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
101+ env :
102+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
103+ with :
104+ args : release --release-notes /tmp/release-notes.txt --clean
0 commit comments