Skip to content

Commit 60bc47e

Browse files
authored
ci(release): Refactor release script with reusable workflow (#2597)
* ci: reusable release script for canary, nightly and stable releases * chore: move triggers back
1 parent 511078f commit 60bc47e

File tree

10 files changed

+616
-928
lines changed

10 files changed

+616
-928
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Single Docker build
2+
3+
description: Docker build for a single target
4+
5+
inputs:
6+
target:
7+
required: true
8+
type: string
9+
image:
10+
required: true
11+
type: string
12+
pre:
13+
required: false
14+
default: ''
15+
type: string
16+
post:
17+
required: false
18+
default: ''
19+
type: string
20+
21+
runs:
22+
using: composite
23+
steps:
24+
- name: Docker Build ${{ inputs.target }}
25+
uses: addnab/docker-run-action@v3
26+
with:
27+
image: ${{ inputs.image }}
28+
options: >
29+
--privileged
30+
--user 0:0
31+
-v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db:cached
32+
-v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache:cached
33+
-v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index:cached
34+
-v ${{ github.workspace }}:/build:cached
35+
-w /build
36+
run: |
37+
set -e
38+
${{ inputs.pre }}
39+
rustup target add ${{ inputs.target }}
40+
RUST_TARGET=${{ inputs.target }} pnpm build:binding:release
41+
${{ inputs.post }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Single Docker Test
2+
3+
description: Docker Test for a single node version
4+
5+
inputs:
6+
node:
7+
required: true
8+
type: string
9+
image:
10+
default: 'slim' # slim or alpine
11+
required: false
12+
type: string
13+
options:
14+
default: ''
15+
required: false
16+
type: string
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- name: Docker Test on Node ${{ inputs.node }}
22+
uses: addnab/docker-run-action@v3
23+
with:
24+
image: node:${{ inputs.node }}-${{ inputs.image }}
25+
options: >
26+
${{ inputs.options }}
27+
-e PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD='true'
28+
-e PUPPETEER_SKIP_DOWNLOAD='true'
29+
--privileged
30+
--user 0:0
31+
-v ${{ github.workspace }}:/build:cached
32+
-w /build
33+
run: |
34+
set -e
35+
36+
# used for e2e tets
37+
# e2e is disabled because this does not run on some targets
38+
# apt-get update
39+
# apt-get install -y gstreamer1.0-libav libnss3-tools libatk-bridge2.0-0 libcups2-dev libxkbcommon-x11-0 libxcomposite-dev libxrandr2 libgbm-dev libgtk-3-0
40+
41+
corepack enable
42+
pnpm install
43+
pnpm run build:js
44+
pnpm run test:unit
45+
# These two breaks on many targets, diabled for now
46+
# pnpm run test:example
47+
# e2e is disabled because this does not run on some targets
48+
# pnpm run test:e2e

.github/actions/pnpm-cache/action.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
name: pnpm cache
2+
23
description: Install Node.js with pnpm global cache
4+
5+
inputs:
6+
node-version:
7+
default: '16'
8+
required: false
9+
type: string
10+
311
runs:
412
using: composite
513
steps:
@@ -11,7 +19,7 @@ runs:
1119
- name: Setup Node.js
1220
uses: actions/setup-node@v3
1321
with:
14-
node-version: "16"
22+
node-version: ${{ inputs.node-version }}
1523
cache: 'pnpm'
1624

1725
- name: Install Npm Dependencies
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Release Canary
2+
3+
description: 'Release Canary by commention with "!canary"'
4+
5+
on:
6+
issue_comment:
7+
types: [created]
8+
9+
jobs:
10+
build:
11+
name: Release Canary
12+
if: github.event.issue.pull_request && contains(github.event.comment.body, '!canary')
13+
runs-on: macos-latest
14+
steps:
15+
- name: Checkout Repo
16+
uses: actions/checkout@v3
17+
with:
18+
# This makes Actions fetch only one branch to release
19+
fetch-depth: 1
20+
ref: refs/pull/${{ github.event.issue.number }}/head
21+
22+
- name: Pnpm Cache
23+
uses: ./.github/actions/pnpm-cache
24+
25+
- name: Install Rust
26+
run: rustup show
27+
28+
- uses: goto-bus-stop/setup-zig@v2
29+
with:
30+
version: 0.10.1
31+
32+
- name: Install Protoc
33+
uses: arduino/setup-protoc@v1
34+
with:
35+
repo-token: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Setup target
38+
run: |
39+
rustup target add aarch64-apple-darwin
40+
rustup target add x86_64-apple-darwin
41+
rustup target add x86_64-unknown-linux-gnu
42+
43+
- name: Build
44+
run: |
45+
set -e
46+
USE_ZIG=1 ./x build cli:release:all
47+
48+
- name: Release
49+
uses: modern-js-dev/actions@v2
50+
with:
51+
# this expects you to have a script called release which does a build for your packages and calls changeset publish
52+
version: "canary"
53+
type: "release"
54+
branch: ""
55+
tools: "changeset"
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
59+
REPOSITORY: ${{ github.repository }}
60+
PULL_REQUEST_NUMBER: ${{ github.event.issue.number }}
61+
COMMENT: ${{ toJson(github.event.comment) }}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Release Nightly
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# 00:07 AM Beijing Time, offset an odd number to avoid cron jobs firing off at the same time
7+
- cron: '7 16 * * *'
8+
9+
jobs:
10+
build:
11+
name: Release Nightly
12+
strategy:
13+
matrix:
14+
target:
15+
- x86_64-unknown-linux-gnu
16+
- aarch64-unknown-linux-gnu
17+
- x86_64-unknown-linux-musl
18+
- aarch64-unknown-linux-musl
19+
- i686-pc-windows-msvc
20+
- x86_64-pc-windows-msvc
21+
- aarch64-pc-windows-msvc
22+
- x86_64-apple-darwin
23+
- aarch64-apple-darwin
24+
uses: ./.github/workflows/reusable-build.yml
25+
with:
26+
target: ${{ matrix.target }}
27+
docker: true
28+
tests: true
29+
30+
release:
31+
name: Nightly
32+
permissions:
33+
contents: write
34+
runs-on: ubuntu-latest
35+
needs: build
36+
steps:
37+
- name: Checkout Repo
38+
uses: actions/checkout@v3
39+
with:
40+
# This makes Actions fetch only one branch to release
41+
fetch-depth: 1
42+
43+
- name: Pnpm Cache
44+
uses: ./.github/actions/pnpm-cache
45+
46+
- name: Download artifacts
47+
uses: actions/download-artifact@v3
48+
with:
49+
path: artifacts
50+
51+
- name: Build node packages
52+
run: pnpm run build:js
53+
54+
- name: Move artifacts
55+
run: node scripts/build-npm.js
56+
57+
- name: Show binding packages
58+
run: ls -R npm
59+
60+
- name: Link optional dependencies
61+
run: pnpm install --no-frozen-lockfile
62+
63+
- name: Prevent changeset crashing on empty changesets
64+
shell: bash
65+
run: |
66+
pnpm run changeset add --empty
67+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
68+
git config user.name "github-actions[bot]"
69+
git add .
70+
git commit -m "chore: bump nightly"
71+
72+
- name: Release
73+
uses: web-infra-dev/actions@v2
74+
with:
75+
version: "canary"
76+
npmTag: "nightly"
77+
type: "release"
78+
branch: ""
79+
tools: "changeset"
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
83+
REPOSITORY: ${{ github.repository }}
84+
REF: ${{ github.ref }}
85+
ONLY_RELEASE_TAG: true

0 commit comments

Comments
 (0)