1919 tags :
2020 - " v*.*.*"
2121 - " !varcon*"
22+
2223env :
2324 BIN_NAME : typos
25+
26+ # We need this to be able to create releases.
27+ permissions :
28+ contents : write
29+
2430jobs :
2531 create-release :
2632 name : create-release
2733 runs-on : ubuntu-latest
2834 outputs :
29- upload_url : ${{ steps.release.outputs.upload_url }}
30- release_version : ${{ env.RELEASE_VERSION }}
35+ version : ${{ env.TAG }}
3136 steps :
32- - name : Get the release version from the tag
33- shell : bash
34- if : env.RELEASE_VERSION == ''
35- run : |
36- # See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
37- echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
38- echo "version is: ${{ env.RELEASE_VERSION }}"
3937 - name : Checkout repository
4038 uses : actions/checkout@v4
4139 with :
4240 fetch-depth : 1
41+ - name : Get the release version from the tag
42+ if : env.TAG == ''
43+ run : echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV
44+ - name : Show the tag
45+ run : |
46+ echo "tag is: $TAG"
4347 - name : Generate Release Notes
4448 run : |
45- ./.github/workflows/release-notes.py --tag ${{ env.RELEASE_VERSION }} --output notes-${{ env.RELEASE_VERSION }}.md
46- cat notes-${{ env.RELEASE_VERSION }}.md
49+ ./.github/workflows/release-notes.py --tag ${{ env.TAG }} --output notes-${{ env.ERSION }}.md
50+ cat notes-${{ env.TAG }}.md
4751 - name : Create GitHub release
48- id : release
49- uses : actions/create-release@v1
5052 env :
51- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
52- with :
53- tag_name : ${{ env.RELEASE_VERSION }}
54- release_name : ${{ env.RELEASE_VERSION }}
55- body_path : notes-${{ env.RELEASE_VERSION }}.md
53+ GH_TOKEN : ${{ github.token }}
54+ run : gh release create $TAG --verify-tag --draft --title $TAG --notes-file notes-${{ env.TAG }}.md
5655 build-release :
5756 name : build-release
5857 needs : create-release
9998 shell : bash
10099 run : |
101100 outdir="./target/${{ matrix.target }}/release"
102- staging="${{ env.BIN_NAME }}-${{ needs.create-release.outputs.release_version }}-${{ matrix.target }}"
101+ staging="${{ env.BIN_NAME }}-${{ needs.create-release.outputs.tag }}-${{ matrix.target }}"
103102 mkdir -p "$staging"/doc
104103 cp {README.md,LICENSE-*} "$staging/"
105104 cp {CHANGELOG.md,docs/*} "$staging/doc/"
@@ -116,11 +115,18 @@ jobs:
116115 echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
117116 fi
118117 - name : Upload release archive
119- 120118 env :
121- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
122- with :
123- upload_url : ${{ needs.create-release.outputs.upload_url }}
124- asset_path : ${{ env.ASSET }}
125- asset_name : ${{ env.ASSET }}
126- asset_content_type : application/octet-stream
119+ GH_TOKEN : ${{ github.token }}
120+ shell : bash
121+ run : |
122+ tag="${{ needs.create-release.outputs.tag }}"
123+ gh release upload "$tag" ${{ env.ASSET }}
124+ publish-release :
125+ name : Publish Release
126+ needs : [prepare-release, build-release]
127+ runs-on : ubuntu-latest
128+ steps :
129+ - name : Publish Release
130+ env :
131+ GH_TOKEN : ${{ github.token }}
132+ run : gh release edit "${{ needs.create-release.outputs.tag }}" --draft=false
0 commit comments