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
+ jobs :
15
+ changelog-version :
16
+ runs-on : ubuntu-latest
17
+ outputs :
18
+ version : ${{ steps.changelog-version.outputs.version }}
19
+ steps :
20
+ - id : changelog-version
21
+ run : echo "version=$(echo "${{ inputs.versionNumber }}" | cut -c 2-)" >> "$GITHUB_OUTPUT"
22
+
23
+ changelog :
24
+ needs : changelog-version
25
+ runs-on : ubuntu-latest
26
+ steps :
27
+ - name : Checkout
28
+ uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
29
+ with :
30
+ fetch-depth : 0
31
+ # Avoid persisting GITHUB_TOKEN credentials as they take priority over our service account PAT for `git push` operations
32
+ # More details: https://github.com/actions/checkout/blob/b4626ce19ce1106186ddf9bb20e706842f11a7c3/adrs/0153-checkout-v2.md#persist-credentials
33
+ persist-credentials : false
34
+
35
+ - name : Batch changes
36
+ uses : miniscruff/changie-action@6dcc2533cac0495148ed4046c438487e4dceaa23 # v2.0.0
37
+ with :
38
+ version : latest
39
+ args : batch ${{ needs.changelog-version.outputs.version }}
40
+
41
+ - name : Merge changes
42
+ uses : miniscruff/changie-action@6dcc2533cac0495148ed4046c438487e4dceaa23 # v2.0.0
43
+ with :
44
+ version : latest
45
+ args : merge
46
+
47
+ - name : Git push changelog
48
+ run : |
49
+ git config --global user.name "${{ vars.TF_THESUDO_CI_COMMIT_AUTHOR }}"
50
+ git config --global user.email "${{ vars.TF_THESUDO_CI_COMMIT_EMAIL }}"
51
+ git add .
52
+ git commit -a -m "Update changelog"
53
+ git push "https://${{ vars.TF_THESUDO_CI_COMMIT_AUTHOR }}:${{ secrets.TF_THESUDO_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
54
+
55
+ release-tag :
56
+ needs : changelog
57
+ runs-on : ubuntu-latest
58
+ steps :
59
+ - name : Checkout
60
+ uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
61
+ with :
62
+ fetch-depth : 0
63
+ # Default input is the SHA that initially triggered the workflow. As we created a new commit in the previous job,
64
+ # to ensure we get the latest commit we use the ref for checkout: 'refs/heads/<branch_name>'
65
+ ref : ${{ github.ref }}
66
+ # Avoid persisting GITHUB_TOKEN credentials as they take priority over our service account PAT for `git push` operations
67
+ # More details: https://github.com/actions/checkout/blob/b4626ce19ce1106186ddf9bb20e706842f11a7c3/adrs/0153-checkout-v2.md#persist-credentials
68
+ persist-credentials : false
69
+
70
+ - name : Git push release tag
71
+ run : |
72
+ git config --global user.name "${{ vars.TF_THESUDO_CI_COMMIT_AUTHOR }}"
73
+ git config --global user.email "${{ vars.TF_THESUDO_CI_COMMIT_EMAIL }}"
74
+
75
+ git tag "${{ inputs.versionNumber }}"
76
+ git push "https://${{ vars.TF_THESUDO_CI_COMMIT_AUTHOR }}:${{ secrets.TF_THESUDO_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" "${{ inputs.versionNumber }}"
77
+
78
+ release-notes :
79
+ needs : [ changelog-version, changelog, release-tag ]
80
+ runs-on : ubuntu-latest
81
+ steps :
82
+ - uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
83
+ with :
84
+ ref : ${{ inputs.versionNumber }}
85
+ fetch-depth : 0
86
+
87
+ - name : Generate Release Notes
88
+ run : |
89
+ cd .changes
90
+ sed -e "1{/# /d;}" -e "2{/^$/d;}" ${{ needs.changelog-version.outputs.version }}.md > release-notes.txt
91
+
92
+ - uses : actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
93
+ with :
94
+ name : release-notes
95
+ path : ./.changes/release-notes.txt
96
+ retention-days : 1
97
+
98
+ # terraform-provider-release:
99
+ # name: 'Terraform Provider Release'
100
+ # needs: [ release-notes ]
101
+ # permissions:
102
+ # contents: write # Needed for goreleaser to create GitHub release
103
+ # issues: write # Needed for goreleaser to close associated milestone
104
+ # uses: hashicorp/ghaction-terraform-provider-release/.github/workflows/hashicorp.yml@9b5d2ca4b85f3a54d5c4d12e7690ddad1526ff6c # v3.0.1
105
+ # secrets:
106
+ # hc-releases-key-prod: '${{ secrets.HC_RELEASES_KEY_PROD }}'
107
+ # hc-releases-key-staging: '${{ secrets.HC_RELEASES_KEY_STAGING }}'
108
+ # hc-releases-github-token: '${{ secrets.HASHI_RELEASES_GITHUB_TOKEN }}'
109
+ # hc-releases-terraform-registry-sync-token: '${{ secrets.TF_PROVIDER_RELEASE_TERRAFORM_REGISTRY_SYNC_TOKEN }}'
110
+ # setup-signore-github-token: '${{ secrets.HASHI_SIGNORE_GITHUB_TOKEN }}'
111
+ # signore-client-id: '${{ secrets.SIGNORE_CLIENT_ID }}'
112
+ # signore-client-secret: '${{ secrets.SIGNORE_CLIENT_SECRET }}'
113
+ # hc-releases-host-staging: '${{ secrets.HC_RELEASES_HOST_STAGING }}'
114
+ # hc-releases-host-prod: '${{ secrets.HC_RELEASES_HOST_PROD }}'
115
+ # with:
116
+ # release-notes: true
117
+ # setup-go-version-file: 'go.mod'
118
+ # # Product Version (e.g. v1.2.3)
119
+ # product-version: '${{ inputs.versionNumber }}'
0 commit comments