Skip to content

Commit 2503e49

Browse files
committed
ci(release): add release workflow
Ref: #65 Signed-off-by: Philip Gerke <me@philipgerke.com>
1 parent 43216ae commit 2503e49

File tree

3 files changed

+77
-5
lines changed

3 files changed

+77
-5
lines changed

.github/actions/get-version-and-changelog/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ runs:
2828
shell: bash
2929
id: changelog
3030
run: |
31+
cz ch ${{ steps.version.outputs.version }} --dry-run
3132
{
3233
echo "changelog<<EOF"
3334
cz ch ${{ steps.version.outputs.version }} --dry-run

.github/workflows/pr_release_check.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ jobs:
1717
id: detect_version_change
1818
uses: ./.github/actions/detect-version-change
1919

20-
update_pr_comment:
21-
name: Update PR Comment
20+
pr_comment_release:
21+
name: Update PR Comment with Release Information
2222
runs-on: ubuntu-latest
2323
needs: check_release_trigger
24-
if: ${{ needs.check_release_trigger.outputs.version_changed }} == "true"
24+
if: ${{ needs.check_release_trigger.outputs.version_changed == 'true' }}
2525
steps:
2626
- name: Checkout code
2727
uses: actions/checkout@v4
@@ -38,8 +38,8 @@ jobs:
3838
with:
3939
issue-number: ${{ github.event.pull_request.number }}
4040
comment-author: "github-actions[bot]"
41-
body-includes: **This PR will trigger a new release upon merge!** 🚀
42-
- name: Comment on PR if release will be triggered
41+
body-includes: "**This PR will"
42+
- name: Comment on PR that a release will be triggered
4343
uses: peter-evans/create-or-update-comment@v4
4444
with:
4545
comment-id: ${{ steps.fc.outputs.comment-id }}
@@ -54,3 +54,31 @@ jobs:
5454
${{ steps.extract_version.outputs.changelog }}
5555
```
5656
edit-mode: replace
57+
58+
pr_comment_no_release:
59+
name: Update PR Comment with Release Information
60+
runs-on: ubuntu-latest
61+
needs: check_release_trigger
62+
if: ${{ needs.check_release_trigger.outputs.version_changed == 'false' }}
63+
steps:
64+
- name: Checkout code
65+
uses: actions/checkout@v4
66+
- name: Remove "release" label
67+
uses: actions-ecosystem/action-remove-labels@v1
68+
with:
69+
labels: release
70+
- name: Find Comment
71+
uses: peter-evans/find-comment@v3
72+
id: fc
73+
with:
74+
issue-number: ${{ github.event.pull_request.number }}
75+
comment-author: "github-actions[bot]"
76+
body-includes: "**This PR will"
77+
- name: Comment on PR that no release will be triggered
78+
uses: peter-evans/create-or-update-comment@v4
79+
with:
80+
comment-id: ${{ steps.fc.outputs.comment-id }}
81+
issue-number: ${{ github.event.pull_request.number }}
82+
body: |
83+
🚫 **This PR will not trigger a release upon merge!**
84+
edit-mode: replace

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Release
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
branches:
8+
- main
9+
10+
jobs:
11+
check_release_trigger:
12+
name: Check if PR will trigger a Release
13+
runs-on: ubuntu-latest
14+
outputs:
15+
version_changed: ${{ steps.detect_version_change.outputs.version_changed }} == "true"
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
- name: Detect version change
20+
id: detect_version_change
21+
uses: ./.github/actions/detect-version-change
22+
23+
release:
24+
name: Create Release
25+
runs-on: ubuntu-latest
26+
needs: [check_release_trigger]
27+
if: ${{ needs.check_release_trigger.outputs.version_changed == 'true' && !contains(github.event.head_commit.message, '[skip deploy]') }}
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
- name: Get new version and changelog
32+
id: extract_version
33+
uses: ./.github/actions/get-version-and-changelog
34+
- name: Create GitHub Release
35+
uses: softprops/action-gh-release@v2
36+
with:
37+
tag_name: "${{ steps.extract_version.outputs.version }}"
38+
name: "v${{ steps.extract_version.outputs.version }}"
39+
body: |
40+
${{ steps.extract_version.outputs.changelog }}
41+
prerelease: ${{ contains(steps.extract_version.outputs.version, '-') }}
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)