Skip to content

Commit b6d71ae

Browse files
committed
ci(github-actions): add worflow release
1 parent 6fbefa7 commit b6d71ae

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

.github/workflows/release.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: release
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types:
8+
- closed
9+
10+
env:
11+
BRANCH_MAIN: main
12+
BRANCH_DEVELOP: develop
13+
14+
jobs:
15+
release:
16+
name: Publish new release
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
# only merge pull requests that begin with 'release/' or 'hotfix/'
21+
if: github.event.pull_request.merged == true &&
22+
(startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix/'))
23+
24+
steps:
25+
- name: Extract version from release branch
26+
if: startsWith(github.event.pull_request.head.ref, 'release/')
27+
run: |
28+
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
29+
VERSION=${BRANCH_NAME#release/}
30+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
31+
32+
- name: Extract version from hotfix branch
33+
if: startsWith(github.event.pull_request.head.ref, 'hotfix/')
34+
run: |
35+
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
36+
VERSION=${BRANCH_NAME#hotfix/}
37+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
38+
39+
- name: Create release
40+
uses: ncipollo/release-action@v1
41+
with:
42+
token: ${{ secrets.GITHUB_TOKEN }}
43+
commit: ${{ github.event.pull_request.merge_commit_sha }}
44+
tag: ${{ env.RELEASE_VERSION }}
45+
name: ${{ env.RELEASE_VERSION }}
46+
draft: false
47+
prerelease: false
48+
generateReleaseNotes: true
49+
50+
- name: Create merge PR ${{ github.event.pull_request.head.ref }} -> ${{ env.BRANCH_DEVELOP }}
51+
uses: peter-evans/create-pull-request@v4
52+
with:
53+
token: ${{ secrets.GITHUB_TOKEN }}
54+
base: ${{ env.BRANCH_DEVELOP }}
55+
branch: ${{ github.event.pull_request.head.ref }}
56+
delete-branch: false
57+
commit-message: Merge branch '${{ github.event.pull_request.head.ref }}' into ${{ env.BRANCH_DEVELOP }}
58+
title: Merge branch '${{ github.event.pull_request.head.ref }}' into ${{ env.BRANCH_DEVELOP }}
59+
body: |
60+
This PR merges the ${{ github.event.pull_request.head.ref }} branch back into ${{ env.BRANCH_DEVELOP }} branch.
61+
This happens to ensure that the updates that happened on the ${{ github.event.pull_request.head.ref }} branch, i.e. CHANGELOG and manifest updates are also present on the ${{ env.BRANCH_DEVELOP }} branch.
62+
63+
Auto-generated by [create-pull-request][1]
64+
65+
[1]: https://github.com/peter-evans/create-pull-request
66+
labels: |
67+
automated-pr

0 commit comments

Comments
 (0)