@@ -152,38 +152,40 @@ jobs:
152152 commit_user_email : github-actions[bot]@users.noreply.github.com
153153 commit_author : github-actions[bot] <github-actions[bot]@users.noreply.github.com>
154154
155+ # How to create a new GitHub release?
156+ # 1. Create a release branch named "release/<tag>".
157+ # 2. Open a PR from the branch, including the release note in the PR body.
158+ # 3. Wait for the CI to create a draft release.
159+ # 4. Publish the release when it's ready.
155160 release :
156161 name : Create GitHub release
157162 needs : [check, changelog]
158- if : startsWith(github.head_ref, 'release/')
163+ if : startsWith(github.head_ref, 'release/') && github.repository == 'loichyan/dynify'
159164 permissions :
160- contents : write # Need to update release
165+ contents : write # need to update release
161166 runs-on : ubuntu-latest
162167 steps :
163168 - name : Setup | Checkout
164169 uses : actions/checkout@v4
165170
166- # For a PR from "release/v1.0.0", the release tag is set to "v1.0.0"
167171 - name : Setup | Configure
168172 id : configure
169173 run : echo tag="${GITHUB_HEAD_REF#release/}" >$GITHUB_OUTPUT
170174
171- # Release notes are taken from the PR's body
172175 - name : Release | Create Release
173176 env :
174177 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
175178 release_tag : ${{ steps.configure.outputs.tag }}
176179 release_body : ${{ github.event.pull_request.body }}
177180 run : |
178- if gh release view "$release_tag" & >/dev/null; then
179- echo "update existed release $release_tag"
180- command= edit
181+ if gh release view "$release_tag" >/dev/null; then
182+ echo "update existing release $release_tag"
183+ gh release edit "$release_tag" --notes="$release_body"
181184 else
182185 echo "create new release $release_tag"
183- command=create
186+ gh release create "$release_tag" \
187+ --target="$GITHUB_BASE_REF" \
188+ --draft=true \
189+ --title="${release_tag#v} ($(date -u +'%Y-%m-%d'))" \
190+ --notes="$release_body"
184191 fi
185- gh release "$command" "$release_tag" \
186- --target="$GITHUB_BASE_REF" \
187- --draft=true \
188- --title="$release_tag ($(date -u +'%Y-%m-%d'))" \
189- --notes="$release_body"
0 commit comments