-
Notifications
You must be signed in to change notification settings - Fork 2
356 lines (350 loc) · 13 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
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
name: Release package
on:
workflow_dispatch:
inputs:
release-level:
description: "Release level"
required: true
type: choice
default: prerelease
options:
- prerelease
- patch
- minor
- major
release-kind:
description: "Release kind"
required: false
type: choice
default: alpha
options:
- alpha
- beta
- rc
- stable
host:
description: "Which host package to release"
required: true
type: choice
options:
- js
- python
- all
jobs:
core:
name: Core
runs-on: ubuntu-latest
steps:
# checkout
- uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
# setup
- uses: actions/setup-node@v3
with:
registry-url: https://registry.npmjs.org/
node-version: "18"
cache: yarn
cache-dependency-path: integration/yarn.lock
- name: Cache cargo registry and build directory
uses: actions/cache@v3
with:
path: |
~/.cargo/git
~/.cargo/registry/cache
~/.cargo/registry/index
core/target
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-release
restore-keys: |
cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
cargo-${{ runner.os }}-
- name: Cache WASI SDK
uses: actions/cache@v3
with:
path: core/wasi-sdk-*
key: wasisdk-${{ runner.os }}-${{ runner.arch }}
- name: Install wasm-opt
run: |
sudo apt-get update
sudo apt-get install binaryen
- name: Install rust target
run: rustup target add wasm32-wasi
# build and store
- name: Run make to build core
env:
CARGO_INCREMENTAL: "0" # disable incremental to reduce load on the cache
run: make build_core CORE_PROFILE=release OS=${{ runner.os }}
- name: Upload artifact core-async.wasm
uses: actions/upload-artifact@v3
with:
name: core-async-wasm
path: core/dist/core-async.wasm
- name: Upload artifact core.wasm
uses: actions/upload-artifact@v3
with:
name: core-wasm
path: core/dist/core.wasm
# TODO: Changelog update create tag and GitHub release
host-javascript-prepare:
name: Prepare JavaScript Host
needs: [core, host-python-prepare]
# when host-python is skipped this job should still run if inputs allow
# so we need to include a status check, then manually ensure core build didn't fail
# (see https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions)
if: ${{ !cancelled() && needs.core.result == 'success' && (inputs.host == 'js' || inputs.host == 'all') }}
runs-on: ubuntu-latest
outputs:
RELEASE_VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }}
RELEASE_LEVEL: ${{ steps.release-level.outputs.RELEASE_LEVEL }}
RELEASE_TAG: ${{ steps.release-level.outputs.RELEASE_TAG }}
RELEASE_PREID: ${{ steps.release-level.outputs.RELEASE_PREID }}
steps:
# Setup
- uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- name: Git configuration
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions release workflow"
- uses: actions/setup-node@v3
with:
registry-url: https://registry.npmjs.org/
node-version: "18"
cache: yarn
cache-dependency-path: host/javascript/yarn.lock
# Release version
- name: Resolve release level
id: release-level
run: scripts/release-level.sh ${{ inputs.release-level }} ${{ inputs.release-kind }} >>$GITHUB_OUTPUT
- name: Resolve release version
id: release-version
run: scripts/release-version.sh ./host/javascript/VERSION ${{ steps.release-level.outputs.RELEASE_LEVEL }} ${{ steps.release-level.outputs.RELEASE_PREID }} >>$GITHUB_OUTPUT
# Update version
- name: Update version in package.json
working-directory: host/javascript
run: yarn version --no-git-tag-version --new-version ${{ steps.release-version.outputs.RELEASE_VERSION }}
# Build
- uses: actions/download-artifact@v3
with:
name: core-async-wasm
path: host/javascript/assets
- name: Copy LICENSE
run: cp LICENSE host/javascript/LICENSE
- name: Build host/javascript
working-directory: host/javascript
run: |
yarn install --frozen-lockfile
yarn build
# Changelog
- name: Update changelog
uses: superfaceai/release-changelog-action@v1
if: ${{ steps.release-level.outputs.RELEASE_TAG == 'latest' }}
with:
path-to-changelog: host/javascript/CHANGELOG.md
version: ${{ steps.release-version.outputs.RELEASE_VERSION }}
operation: release
# Commit release changes
- name: Git configuration
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions release workflow"
- name: Commit package.json, VERSION, CHANGELOG.md and create git tag
working-directory: host/javascript
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add package.json VERSION CHANGELOG.md
git commit -m "chore: release host/javascript ${{ steps.release-version.outputs.RELEASE_VERSION }}"
git tag "js-v${{ steps.release-version.outputs.RELEASE_VERSION }}"
git push origin
git push origin --tags
# Create GitHub Release
- name: Version for Changelog entry
id: get-changelog-version
env:
RELEASE_TAG: ${{ steps.release-level.outputs.RELEASE_TAG }}
VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }}
run: |
if [ "$RELEASE_TAG" = "latest" ]; then
echo VERSION="$VERSION"
else
echo VERSION="" # refers to unreleased section
fi
- name: Get release version changelog
id: get-changelog
uses: superfaceai/release-changelog-action@v1
with:
path-to-changelog: host/javascript/CHANGELOG.md
version: ${{ steps.get-changelog-version.outputs.VERSION }}
operation: read
- name: Update GitHub release documentation
uses: softprops/action-gh-release@v1
with:
tag_name: "js-v${{ steps.release-version.outputs.RELEASE_VERSION }}"
body: ${{ steps.get-changelog.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
host-javascript-publish:
name: Publish JavaScript Host
needs: [core, host-javascript-prepare]
if: ${{ !cancelled() && needs.host-javascript-prepare.result == 'success' }}
runs-on: ubuntu-latest
steps:
# Setup
- uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- uses: actions/setup-node@v3
with:
registry-url: https://registry.npmjs.org/
node-version: "18"
cache: yarn
cache-dependency-path: host/javascript/yarn.lock
# Build
- uses: actions/download-artifact@v3
with:
name: core-async-wasm
path: host/javascript/assets
- name: Copy LICENSE
run: cp LICENSE host/javascript/LICENSE
- name: Build host/javascript
working-directory: host/javascript
run: |
yarn install --frozen-lockfile
yarn build
# Publish
- name: Publish to NPM registry
working-directory: host/javascript
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_BOT_PAT }}
run: yarn publish --verbose --no-git-tag-version --access public --new-version ${{ needs.host-javascript-prepare.outputs.RELEASE_VERSION }} --tag ${{ needs.host-javascript-prepare.outputs.RELEASE_TAG }}
host-python-prepare:
name: Prepare Python Host
needs: [core]
if: ${{ inputs.host == 'python' || inputs.host == 'all' }}
runs-on: ubuntu-latest
steps:
# Setup
- uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install Python tools
run: python -m pip install build toml-cli
# Release version
- name: Resolve release level
id: release-level
run: scripts/release-level.sh ${{ inputs.release-level }} ${{ inputs.release-kind }} >>$GITHUB_OUTPUT
- name: Resolve release version
id: release-version
run: scripts/release-version.sh ./host/python/VERSION ${{ steps.release-level.outputs.RELEASE_LEVEL }} ${{ steps.release-level.outputs.RELEASE_PREID }} >>$GITHUB_OUTPUT
# Update version
- name: Update version in pyproject
working-directory: host/python
run: toml set --toml-path pyproject.toml project.version ${{ steps.release-version.outputs.RELEASE_VERSION }}
# Build
- uses: actions/download-artifact@v3
with:
name: core-wasm
path: host/python/src/one_sdk/assets
- name: Build host/python
working-directory: host/python
run: python -m build
# Changelog
- name: Update changelog
uses: superfaceai/release-changelog-action@v1
if: ${{ steps.release-level.outputs.RELEASE_TAG == 'latest' }}
with:
path-to-changelog: host/python/CHANGELOG.md
version: ${{ steps.release-version.outputs.RELEASE_VERSION }}
operation: release
# Commit release changes
- name: Git configuration
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions release workflow"
- name: Commit pyproject.toml, VERSION, CHANGELOG.md and create git tag
working-directory: host/python
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add pyproject.toml VERSION CHANGELOG.md
git commit -m "chore: release host/python ${{ steps.release-version.outputs.RELEASE_VERSION }}"
git tag "python-v${{ steps.release-version.outputs.RELEASE_VERSION }}"
git push origin
git push origin --tags
# Create GitHub Release
- name: Version for Changelog entry
id: get-changelog-version
env:
RELEASE_TAG: ${{ steps.release-level.outputs.RELEASE_TAG }}
VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }}
run: |
if [ "$RELEASE_TAG" = "latest" ]; then
echo VERSION="$VERSION"
else
echo VERSION="" # refers to unreleased section
fi
- name: Get release version changelog
id: get-changelog
uses: superfaceai/release-changelog-action@v1
with:
path-to-changelog: host/python/CHANGELOG.md
version: ${{ steps.get-changelog-version.outputs.VERSION }}
operation: read
- name: Update GitHub release documentation
uses: softprops/action-gh-release@v1
with:
tag_name: "python-v${{ steps.release-version.outputs.RELEASE_VERSION }}"
body: ${{ steps.get-changelog.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
host-python-publish:
name: Publish Python Host
needs: [core, host-python-prepare]
if: ${{ !cancelled() && needs.host-python-prepare.result == 'success' }}
runs-on: ubuntu-latest
steps:
# Setup
- uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install Python tools
run: python -m pip install build toml-cli
# Build
- uses: actions/download-artifact@v3
with:
name: core-wasm
path: host/python/src/one_sdk/assets
- name: Copy LICENSE
run: cp LICENSE host/python/LICENSE
- name: Build host/python
working-directory: host/python
run: python -m build
# Publish
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: host/python/dist
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
trigger_daily:
name: Trigger daily build
needs: [host-javascript-publish, host-python-publish]
if: ${{ !cancelled() && (needs.host-javascript-publish.result == 'success' || needs.host-python-publish.result == 'success') }}
runs-on: ubuntu-latest
steps:
- name: Trigger Daily Test
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.GH_BOT_PAT }}
repository: superfaceai/superface-daily
event-type: on-demand-test