-
Notifications
You must be signed in to change notification settings - Fork 19
165 lines (160 loc) · 5.58 KB
/
release.yml
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Publish release
on:
workflow_dispatch:
inputs:
type:
description: 'Type of publish (one of: rc, main, both, hotfix)'
required: true
default: 'rc'
jobs:
publish_main:
runs-on: ubuntu-latest
steps:
-
name: Setup environment
id: set-vars
run: |
if [[ "${{ github.event.inputs.type }}" == "both" || "${{ github.event.inputs.type }}" == "main" ]]; then
echo "::set-output name=main::true"
elif [[ "${{ github.event.inputs.type }}" == "hotfix" ]]; then
echo "::set-output name=main::true"
echo "::set-output name=hotfix::true"
fi
-
name: Setup Node
if: ${{ steps.set-vars.outputs.main == 'true' }}
uses: actions/setup-node@v1
with:
node-version: 16
-
name: Checkout `main` branch
if: ${{ steps.set-vars.outputs.main == 'true' }}
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}
ref: main
-
name: Configure git
if: ${{ steps.set-vars.outputs.main == 'true' }}
run: |
git config user.email "${{ github.actor }}@users.noreply.github.com"
git config user.name ${{ github.actor }}
git fetch --all
-
name: Merge down from `main` -> `rc` -> `develop`
if: ${{ steps.set-vars.outputs.main == 'true' }}
run: |
git checkout -B release-candidate origin/release-candidate
git merge main
git checkout -B develop origin/develop
git merge release-candidate
git checkout main
-
name: Merge `release-candidate` -> `main`
if: ${{ steps.set-vars.outputs.main == 'true' && steps.set-vars.outputs.hotfix != 'true' }}
run: git merge release-candidate
-
name: Initialize and build code
if: ${{ steps.set-vars.outputs.main == 'true' }}
run: |
npm set unsafe-perm true
npm ci && npm run build
-
name: Publish release
if: ${{ steps.set-vars.outputs.main == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: npm run release -- --ci --github.release --no-npm-publish
-
name: Update and push code to `release-candidate` and `develop`
if: ${{ steps.set-vars.outputs.main == 'true' }}
run: |
git checkout release-candidate
git merge main
git push
git checkout develop
git merge main
git push
-
name: Send Discord notification
if: ${{ steps.set-vars.outputs.main == 'true' }}
run: |
# Prepare notification body
echo '{"embeds":[{"title":"**Release Published**","description":"```' > embed.json
git log -2 --pretty=%B >> embed.json
echo '```","color":3581519}]}' >> embed.json
cat embed.json
# Send notification
res=$(curl -X POST ${{ secrets.DISCORD_RELEASE_WEBHOOK }} -H "Content-Type: application/json" -d @embed.json) || exit 1
publish_rc:
runs-on: ubuntu-latest
needs: publish_main
steps:
-
name: Setup environment
id: set-vars
run: |
if [[ "${{ github.event.inputs.type }}" == "both" || "${{ github.event.inputs.type }}" == "rc" ]]; then
echo "::set-output name=rc::true"
fi
-
name: Setup Node
if: ${{ steps.set-vars.outputs.rc == 'true' }}
uses: actions/setup-node@v1
with:
node-version: 16
-
name: Checkout `release-candidate` branch
if: ${{ steps.set-vars.outputs.rc == 'true' }}
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}
ref: release-candidate
-
name: Configure git
if: ${{ steps.set-vars.outputs.rc == 'true' }}
run: |
git config user.email "${{ github.actor }}@users.noreply.github.com"
git config user.name ${{ github.actor }}
git fetch --all
-
name: Merge down from `rc` -> `develop`
if: ${{ steps.set-vars.outputs.rc == 'true' }}
run: |
git checkout -B develop origin/develop
git merge release-candidate
git checkout release-candidate
-
name: Merge `develop` -> `release-candidate`
if: ${{ steps.set-vars.outputs.rc == 'true' }}
run: git merge develop
-
name: Initialize and build code
if: ${{ steps.set-vars.outputs.rc == 'true' }}
run: |
npm set unsafe-perm true
npm ci && npm run build
-
name: Publish pre-release
if: ${{ steps.set-vars.outputs.rc == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: npm run release -- --ci --preReleaseId=rc --github.preRelease --no-npm-publish
-
name: Update and push code to `develop`
if: ${{ steps.set-vars.outputs.rc == 'true' }}
run: |
git checkout develop
git merge release-candidate
git push
-
name: Send Discord notification
if: ${{ steps.set-vars.outputs.rc == 'true' }}
run: |
# Prepare notification body
echo '{"embeds":[{"title":"**Release Candidate Published**","description":"```' > embed.json
git log -1 --pretty=%B >> embed.json
echo '```","color":3581519}]}' >> embed.json
cat embed.json
# Send notification
res=$(curl -X POST ${{ secrets.DISCORD_RELEASE_WEBHOOK }} -H "Content-Type: application/json" -d @embed.json) || exit 1