Skip to content

Commit 79f7c93

Browse files
Automatically close release issue and add comments to workflow files
1 parent b056ac6 commit 79f7c93

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

.github/workflows/draft-new-release.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,26 @@ jobs:
2727
with:
2828
version: ${{ env.RELEASE_VERSION }}
2929

30+
# In order to make a commit, we need to initialize a user.
31+
# You may choose to write something less generic here if you want, it doesn't matter functionality wise.
3032
- name: Initialize mandatory git config
3133
run: |
3234
git config user.name "GitHub actions"
3335
git config user.email noreply@github.com
3436
3537
# This step will differ depending on your project setup
38+
# Fortunately, yarn has a built-in command for doing this!
3639
- name: Bump version in package.json
3740
run: yarn version --new-version ${{ env.RELEASE_VERSION }} --no-git-tag-version
3841

3942
- name: Commit changelog and manifest files
43+
id: make-commit
4044
run: |
4145
git add CHANGELOG.md package.json
4246
git commit --message "Prepare release ${{ env.RELEASE_VERSION }}"
4347
48+
echo "::set-output name=commit::$(git rev-parse HEAD)"
49+
4450
- name: Push new branch
4551
run: git push origin release/${{ env.RELEASE_VERSION }}
4652

@@ -51,6 +57,14 @@ jobs:
5157
head: release/${{ env.RELEASE_VERSION }}
5258
base: master
5359
title: ${{ github.event.issue.title }}
54-
reviewers: ${{ github.event.issue.user.login }}
60+
reviewers: ${{ github.event.issue.user.login }} # By default, we request a review from the person who opened the issue. You can replace this with a static list of users.
61+
# Write a nice message to the user.
62+
# We are claiming things here based on the `publish-new-release.yml` workflow.
63+
# You should obviously adopt it to say the truth depending on your release workflow :)
5564
body: |
56-
Resolves #${{ github.event.issue.number }}
65+
Hi ${{ github.event.issue.user.login }}!
66+
67+
This PR was created in response to this release issue: #${{ github.event.issue.number }}.
68+
I've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.
69+
70+
Merging this PR will create a GitHub release and upload any assets that are created as part of the release build.

.github/workflows/publish-new-release.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ jobs:
2929
3030
echo "::set-env name=RELEASE_VERSION::$VERSION"
3131
32+
# Unfortunately, GitHub doesn't trigger events for actions that have been taken by a GitHub action.
33+
# This means we cannot use `Fixes #issue_number.` in the body of the PR to close the release issue after the branch is merged.
34+
# Hence, we close it here "manually"
35+
- name: Close release issue
36+
run: |
37+
38+
RELEASE_ISSUE_URL=$(curl https://api.github.com/repos/${{ github.repository }}/issues?labels=release&state=open | jq -r '.[1].url')
39+
40+
curl \
41+
-X PATCH \
42+
-H 'Accept: application/vnd.github.v3+json' \
43+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
44+
-H "Content-Type: application/json" \
45+
$RELEASE_ISSUE_URL \
46+
-d '{"state":"closed"}'
47+
3248
- name: Create Release
3349
uses: thomaseizinger/create-release@1.0.0
3450
env:
@@ -52,3 +68,4 @@ jobs:
5268
This happens to ensure that the updates that happend on the release branch, i.e. CHANGELOG and manifest updates are also present on the dev branch.
5369
5470
# if needed, you can checkout the latest master here, build artifacts and publish / deploy them somewhere
71+
# the create-release action has an output `upload_url` output that you can use to upload assets

0 commit comments

Comments
 (0)