66 - ' v*.*.*'
77
88permissions :
9- contents : write
9+ contents : read
1010
1111jobs :
1212 tests :
1313 uses : ./.github/workflows/tests.yml
14- secrets : inherit
1514
1615 release :
1716 needs : tests
1817 runs-on : ubuntu-latest
18+ permissions :
19+ contents : write
1920
2021 steps :
2122 - name : Checkout code
22- uses : actions/checkout@v7
23+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
24+ with :
25+ persist-credentials : false
2326
2427 - name : Determine if pre-release
2528 id : prerelease
29+ env :
30+ TAG : ${{ github.ref_name }}
2631 run : |
27- TAG="${{ github.ref_name }}"
2832 if [[ "$TAG" == *"-"* ]]; then
29- echo "flag=--prerelease" >> $GITHUB_OUTPUT
33+ echo "flag=--prerelease" >> " $GITHUB_OUTPUT"
3034 else
31- echo "flag=" >> $GITHUB_OUTPUT
35+ echo "flag=" >> " $GITHUB_OUTPUT"
3236 fi
3337
3438 - name : Check if release exists
3539 id : check
40+ env :
41+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
42+ TAG : ${{ github.ref_name }}
3643 run : |
37- if gh release view "${{ github.ref_name }} " > /dev/null 2>&1; then
38- echo "exists=true" >> $GITHUB_OUTPUT
44+ if gh release view "$TAG " > /dev/null 2>&1; then
45+ echo "exists=true" >> " $GITHUB_OUTPUT"
3946 else
40- echo "exists=false" >> $GITHUB_OUTPUT
47+ echo "exists=false" >> " $GITHUB_OUTPUT"
4148 fi
42- env :
43- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4449
4550 - name : Create GitHub Release
4651 if : steps.check.outputs.exists == 'false'
47- run : gh release create "${{ github.ref_name }}" --generate-notes ${{ steps.prerelease.outputs.flag }}
4852 env :
4953 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
54+ TAG : ${{ github.ref_name }}
55+ PRERELEASE_FLAG : ${{ steps.prerelease.outputs.flag }}
56+ run : gh release create "$TAG" --generate-notes $PRERELEASE_FLAG
5057
5158 changelog :
5259 needs : release
5360 runs-on : ubuntu-latest
61+ permissions :
62+ contents : write
5463
5564 steps :
5665 - name : Determine target branch
5766 id : branch
67+ env :
68+ TAG : ${{ github.ref_name }}
69+ REPO : ${{ github.repository }}
70+ DEFAULT_BRANCH : ${{ github.event.repository.default_branch }}
5871 run : |
59- TAG="${{ github.ref_name }}"
6072 MAJOR=$(echo "$TAG" | sed -E 's/^v?([0-9]+)\..*/\1/')
6173 BRANCH="${MAJOR}.x"
62- if ! git ls-remote --exit-code --heads "https://github.com/${{ github.repository }} " "$BRANCH" > /dev/null 2>&1; then
63- BRANCH="${{ github.event.repository.default_branch }} "
74+ if ! git ls-remote --exit-code --heads "https://github.com/$REPO " "$BRANCH" > /dev/null 2>&1; then
75+ BRANCH="$DEFAULT_BRANCH "
6476 fi
65- echo "name=${BRANCH}" >> $GITHUB_OUTPUT
77+ echo "name=${BRANCH}" >> " $GITHUB_OUTPUT"
6678
6779 - name : Checkout code
68- uses : actions/checkout@v7
80+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
6981 with :
7082 ref : ${{ steps.branch.outputs.name }}
7183 ssh-key : ${{ secrets.DEPLOY_KEY }}
7284
7385 - name : Get release notes
7486 id : notes
75- run : |
76- NOTES=$(gh release view "${{ github.ref_name }}" --json body --jq .body)
77- EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
78- echo "body<<$EOF" >> $GITHUB_OUTPUT
79- echo "$NOTES" >> $GITHUB_OUTPUT
80- echo "$EOF" >> $GITHUB_OUTPUT
8187 env :
8288 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
89+ TAG : ${{ github.ref_name }}
90+ run : |
91+ NOTES=$(gh release view "$TAG" --json body --jq .body)
92+ EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
93+ {
94+ echo "body<<$EOF"
95+ echo "$NOTES"
96+ echo "$EOF"
97+ } >> "$GITHUB_OUTPUT"
8398
8499 - name : Update Changelog
85- uses : stefanzweifel/changelog-updater-action@v1
100+ uses : stefanzweifel/changelog-updater-action@a938690fad7edf25368f37e43a1ed1b34303eb36 # v1.12.0
86101 with :
87102 latest-version : ${{ github.ref_name }}
88103 release-notes : ${{ steps.notes.outputs.body }}
89104
90105 - name : Commit updated CHANGELOG
91- uses : stefanzweifel/git-auto-commit-action@v7
106+ uses : stefanzweifel/git-auto-commit-action@4a55954c782fc1ea30b9056cd3e7a2b40ca8887d # v7.2.0
92107 with :
93108 branch : ${{ steps.branch.outputs.name }}
94109 commit_message : " chore: update CHANGELOG for ${{ github.ref_name }}"
@@ -103,7 +118,9 @@ jobs:
103118
104119 steps :
105120 - name : Checkout code
106- uses : actions/checkout@v7
121+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
107122
108123 - name : Delete tag on test failure
109- run : git push --delete origin "${{ github.ref_name }}"
124+ env :
125+ TAG : ${{ github.ref_name }}
126+ run : git push --delete origin "$TAG"
0 commit comments