-
Notifications
You must be signed in to change notification settings - Fork 41
235 lines (207 loc) · 6.46 KB
/
build_test_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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
name: Build, test, and release
on:
workflow_dispatch:
inputs:
bump:
type: choice
options: [major, premajor, minor, preminor, patch, prepatch, prerelease]
default: prerelease
description: Version Bump
required: true
deployBNCOnboard:
type: boolean
default: false
description: Deploy @uauth/bnc-onboard
required: true
deployCommon:
type: boolean
default: false
description: Deploy @uauth/common
required: true
deployJS:
type: boolean
default: false
description: Deploy @uauth/js
required: true
deployMoralis:
type: boolean
default: false
description: Deploy @uauth/moralis
required: true
deployNode:
type: boolean
default: false
description: Deploy @uauth/node
required: true
deployWagmi:
type: boolean
default: false
description: Deploy @uauth/wagmi
required: true
deployWeb3React:
type: boolean
default: false
description: Deploy @uauth/web3-react
required: true
deployWeb3Modal:
type: boolean
default: false
description: Deploy @uauth/web3modal
required: true
deployWeb3Onboard:
type: boolean
default: false
description: Deploy @uauth/web3-onboard
required: true
pull_request:
types: [opened, reopened, synchronize]
env:
ENVIRONMENT: build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup
uses: ./.github/actions/setup
- name: Build
run: yarn build
- uses: actions/cache@v3
id: cache-build
with:
path: '**/build'
key: ${{ github.sha }}-${{ github.run_number }}
lint:
name: Lint
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup
uses: ./.github/actions/setup
- uses: actions/cache@v3
id: restore-build
with:
path: '**/build'
key: ${{ github.sha }}-${{ github.run_number }}
- name: Lint
run: yarn lint
test:
name: Test
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup
uses: ./.github/actions/setup
- uses: actions/cache@v3
id: restore-build
with:
path: '**/build'
key: ${{ github.sha }}-${{ github.run_number }}
- name: Test
run: yarn test
release:
name: Release
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
needs: [build, lint, test]
steps:
- uses: actions/checkout@v3
with:
# TODO Figure out if we still need to do this
# We use fetch-depth: 0 because yarn version check requires it
fetch-depth: 0
- run: git config user.email ${{ github.actor }}@users.noreply.github.com
- run: git config user.name ${{ github.actor }}
- name: Setup
uses: ./.github/actions/setup
- uses: actions/cache@v3
id: restore-build
with:
path: '**/build'
key: ${{ github.sha }}-${{ github.run_number }}
- uses: oprypin/find-latest-tag@v1
with:
repository: ${{ github.repository }}
sort-tags: true
regex: '^v\d+\.\d+\.\d+(-rc.\d+)?$'
id: get_latest_tag
- name: Calculate Bump
id: calculate_bump
run: |-
BUMP="${{ github.event.inputs.bump }}"
if [[ ${{ github.ref_name != 'main' }} == 'true' && $BUMP != pre* ]]; then
BUMP="pre$BUMP"
fi
echo BUMP $BUMP
echo ::set-output name=bump::"$BUMP"
- name: Evaluate Bump
run: echo ::set-output name=new_version::$(yarn dlx --quiet semver --preid rc -i ${{ steps.calculate_bump.outputs.bump }} ${{ steps.get_latest_tag.outputs.tag }})
id: evaluate_bump
- uses: actions/github-script@v6
name: Get Workspaces to Deploy
id: get_workspaces
with:
script: |-
const inputToWorkspace = {
deployBNCOnboard: "@uauth/bnc-onboard",
deployCommon: "@uauth/common",
deployJS: "@uauth/js",
deployMoralis: "@uauth/moralis",
deployNode: "@uauth/node",
deployWagmi: "@uauth/wagmi",
deployWeb3React: "@uauth/web3-react",
deployWeb3Modal: "@uauth/web3modal",
deployWeb3Onboard: "@uauth/web3-onboard",
}
console.log(context.payload.inputs)
return Object
.keys(inputToWorkspace)
.reduce((a, v) => {
if (context.payload.inputs[v] === 'true') {
a.push(inputToWorkspace[v])
}
return a
}, [])
.join(',')
- name: Configure NPM Access Token
run: yarn config set npmAuthToken "${{ secrets.NPM_TOKEN }}"
- name: Get NPM Tag
id: get_npm_tag
run: |-
if [[ ${{ steps.calculate_bump.outputs.bump }} == pre* ]]; then
echo ::set-output name=tag::next
else
echo ::set-output name=tag::latest
fi
- name: Bump package.json Version
run: |-
variable=${{ steps.get_workspaces.outputs.result }}
for workspace in ${variable//,/ }
do
yarn workspace "$workspace" version ${{ steps.evaluate_bump.outputs.new_version }}
done
- name: Tag
run: |-
git add -u packages/
git commit -m "v${{ steps.evaluate_bump.outputs.new_version }}"
git tag "v${{ steps.evaluate_bump.outputs.new_version }}" -m "v${{ steps.evaluate_bump.outputs.new_version }}"
- name: Publish to NPM
run: |-
yarn build
variable=${{ steps.get_workspaces.outputs.result }}
for workspace in ${variable//,/ }
do
yarn workspace "$workspace" npm publish --tolerate-republish --tag ${{ steps.get_npm_tag.outputs.tag }}
done
- name: Push
run: git push --atomic origin ${{ github.ref_name }} "v${{ steps.evaluate_bump.outputs.new_version }}"