-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (74 loc) · 2.86 KB
/
publish-new-release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Publish New Release
on:
pull_request:
types:
- closed
branches:
- main
jobs:
release:
name: Publish New Release
runs-on: ubuntu-latest
if: (startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix-release/')) && github.event.pull_request.merged == true # only merged pull requests must trigger this job
steps:
- name: Extract Version
id: extract-version
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=${BRANCH_NAME#hotfix-}
VERSION=${VERSION#release/}
echo "release_version=$VERSION" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install Dependencies
env:
HUSKY: 0
run: |
npm ci
# In order to make a commit, we need to initialize a user.
# You may choose to write something less generic here if you want, it doesn't matter functionality wise.
- name: Initialize Mandatory Git Config
run: |
git config user.name "GitHub Actions"
git config user.email [email protected]
- name: Tag & Create GitHub Release
id: create_release
env:
HUSKY: 0
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag -a ${{ steps.extract-version.outputs.release_version }} -m "chore: release v${{ steps.extract-version.outputs.release_version }}"
git push origin refs/tags/${{ steps.extract-version.outputs.release_version }}
npm run release:github
echo "DATE=$(date)" >> $GITHUB_ENV
- name: Pull Changes Into develop Branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: repo-sync/pull-request@v2
with:
source_branch: 'main'
destination_branch: 'develop'
pr_title: 'chore(release): pull main into develop post release v${{ steps.extract-version.outputs.release_version }}'
pr_body: ':crown: *An automated PR*'
- name: Delete Hotfix Release Branch
uses: koj-co/delete-merged-action@master
if: startsWith(github.event.pull_request.head.ref, 'hotfix-release/')
with:
branches: 'hotfix-release/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Delete Release Branch
uses: koj-co/delete-merged-action@master
if: startsWith(github.event.pull_request.head.ref, 'release/')
with:
branches: 'release/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}