88 tags-ignore :
99 - " **" # Ignore all tags to prevent duplicate builds when tags are pushed.
1010
11- # Trigger a stable version release when a GitHub release is published.
12- release :
13- types : [published]
14-
15- # Allows manual workflow runs from GitHub's UI, with the ability to specify the type of release.
11+ # Trigger a stable version release via GitHub's UI, with the ability to specify the type of release.
1612 workflow_dispatch :
1713 inputs :
1814 release_type :
1915 description : Release type
2016 required : true
2117 type : choice
22- default : alpha
18+ default : auto
2319 options :
24- - alpha
25- - beta
26- - final
20+ - auto
21+ - custom
22+ custom_version :
23+ description : The custom version to bump to (only for "custom" type)
24+ required : false
25+ type : string
26+ default : ' '
2727
2828jobs :
2929 run_code_checks :
@@ -36,20 +36,109 @@ jobs:
3636 name : Check whether to release
3737 if : |
3838 github.event_name == 'workflow_dispatch' ||
39- github.event_name == 'release' ||
4039 (
4140 github.event_name == 'push' &&
4241 !startsWith(github.event.head_commit.message, 'docs') &&
4342 !startsWith(github.event.head_commit.message, 'chore')
4443 )
4544 runs-on : ubuntu-latest
45+ outputs :
46+ version_number : ${{ steps.version_number.result }}
4647 steps :
47- - name : Dummy step
48- run : " true"
48+ - name : Checkout
49+ uses : actions/checkout@v4
50+ with :
51+ fetch-depth : 0
52+
53+ - name : Locally remove beta tags
54+ run : |
55+ git tag | grep 'b[0-9]' | xargs git tag --delete
56+
57+ - name : Install git-cliff
58+ run : cargo install git-cliff
59+
60+ - name : Determine version number
61+ id : version_number
62+ run : |
63+ if [[ ${{ event.inputs.release_type }} = custom ]]; then
64+ echo result=$(echo ${{ event.inputs.custom_version }} | sed s/^v//) >> $GITHUB_OUTPUT
65+ else
66+ echo result=$(git-cliff --bumped-version | sed s/^v//)
67+
68+ update_changelog :
69+ name : Update changelog
70+ needs : [run_code_checks, should_release]
71+ runs-on : ubuntu-latest
72+ permissions :
73+ contents : write
74+ id-token : write # Required for OIDC authentication.
75+ outputs :
76+ changelog_commitish : ${{ steps.push.commitish }}
77+ steps :
78+ - name : Checkout repository
79+ uses : actions/checkout@v4
80+ with :
81+ fetch-depth : 0
82+
83+ - name : Locally remove beta tags
84+ run : |
85+ git tag | grep 'b[0-9]' | xargs git tag --delete
86+
87+ - name : Install git-cliff
88+ run : cargo install git-cliff
89+
90+ - name : Set up git
91+ run : |
92+ git config --global user.name "Apify Release Bot"
93+ git config --global user.email "noreply@apify.com"
94+
95+ - name : Generate changelog with git-cliff
96+ run : |
97+ if [[ ${{ github.event_name }} = workflow_dispatch ]]; then
98+ git-cliff --tag v${{ needs.should_release.outputs.version }} > CHANGELOG.md
99+ else
100+ git-cliff --with-tag-message v${{ needs.should_release.outputs.version }} > CHANGELOG.md
101+ fi
102+
103+ - name : Commit and push the result
104+ id : push
105+ run : |
106+ git commit -am "chore(release): Update changelog [skip ci]"
107+ git push origin master
108+ echo commitish=$(git rev-parse HEAD) >> $GITHUB_OUTPUT
109+
110+ create_github_release :
111+ name : Create github release
112+ if : github.event_name == 'workflow_dispatch'
113+ needs : [update_changelog]
114+ runs-on : ubuntu-latest
115+ steps :
116+ - name : Checkout
117+ uses : actions/checkout@v4
118+ with :
119+ fetch-depth : 0
120+
121+ - name : Locally remove beta tags
122+ run : |
123+ git tag | grep 'b[0-9]' | xargs git tag --delete
124+
125+ - name : Install git-cliff
126+ run : cargo install git-cliff
127+
128+ - name : Generate release notes with git-cliff
129+ run : git-cliff --tag "v${{ steps.version_number.outputs.result }}" --unreleased --strip all > release_notes.md
130+
131+ - name : Create release
132+ uses : softprops/action-gh-release@v2
133+ with :
134+ tag_name : v${{ needs.should_release.outputs.version }}
135+ name : ${{ needs.should_release.outputs.version }}
136+ target_commitish : ${{ needs.update_changelog.outputs.changelog_commitish }}
137+ body_path : release_notes.md
49138
50139 publish_to_pypi :
51140 name : Publish to PyPI
52- needs : [run_code_checks, should_release ]
141+ needs : [create_github_release ]
53142 uses : ./.github/workflows/_publish_to_pypi.yaml
54143
55144 # TODO: add job for publish package to Conda
0 commit comments