Skip to content

Commit 94fc6f0

Browse files
authored
Next swc publish flow (#27932)
1 parent 51a2a02 commit 94fc6f0

File tree

14 files changed

+252
-103
lines changed

14 files changed

+252
-103
lines changed

.github/workflows/build_native.yml

+27-99
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,82 @@
1-
on:
2-
workflow_dispatch:
3-
pull_request:
4-
types: [opened, synchronize]
5-
paths:
6-
- 'packages/next/build/swc/**'
1+
on: workflow_dispatch
72

83
name: Build next-swc native binaries
94

105
jobs:
11-
build:
6+
build-native:
127
strategy:
138
matrix:
149
os: [ubuntu-18.04, macos-latest, windows-latest]
15-
16-
name: stable - ${{ matrix.os }} - node@14
10+
description: [default]
11+
include:
12+
- os: ubuntu-18.04
13+
target: x86_64-unknown-linux-gnu
14+
- os: windows-latest
15+
target: x86_64-pc-windows-msvc
16+
- os: macos-latest
17+
target: x86_64-apple-darwin
18+
- os: macos-latest
19+
target: aarch64-apple-darwin
20+
description: m1
21+
22+
name: next-swc - ${{ matrix.os }} - ${{ matrix.target }} - node@14
1723
runs-on: ${{ matrix.os }}
1824

1925
steps:
2026
- uses: actions/checkout@v2
21-
2227
- name: Setup node
2328
uses: actions/setup-node@v2
2429
with:
2530
node-version: 14
2631
check-latest: true
27-
2832
- name: Install
2933
uses: actions-rs/toolchain@v1
3034
with:
31-
toolchain: stable
3235
profile: minimal
33-
36+
toolchain: nightly-2021-03-25
37+
target: ${{ matrix.target }}
3438
- name: Cache cargo registry
3539
uses: actions/cache@v1
3640
with:
3741
path: ~/.cargo/registry
3842
key: stable-${{ matrix.os }}-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
39-
4043
- name: Cache cargo index
4144
uses: actions/cache@v1
4245
with:
4346
path: ~/.cargo/git
4447
key: stable-${{ matrix.os }}-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
45-
46-
- name: Cache NPM dependencies
47-
uses: actions/cache@v1
48+
- name: Cache native binary
49+
id: binary-cache
50+
uses: actions/cache@v2
4851
with:
49-
path: node_modules
50-
key: npm-cache-${{ matrix.os }}-node@14-${{ hashFiles('yarn.lock') }}
51-
52-
- name: 'Install dependencies'
53-
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
54-
52+
path: packages/next/native/**
53+
key: next-swc-nightly-2021-03-25-${{ matrix.target }}-${{ hashFiles('packages/next/build/swc/**') }}
5554
- name: 'Build'
56-
run: yarn --cwd packages/next build-native
55+
if: steps.binary-cache.outputs.cache-hit != true
56+
run: yarn build-native --target ${{ matrix.target }}
5757
env:
5858
MACOSX_DEPLOYMENT_TARGET: '10.13'
59-
60-
- name: Upload artifact
61-
uses: actions/upload-artifact@v2
62-
with:
63-
name: next-swc-binaries
64-
path: packages/next/native
65-
66-
- name: Clear the cargo caches
67-
run: |
68-
cargo install cargo-cache --no-default-features --features ci-autoclean
69-
cargo-cache
70-
71-
build-apple-silicon:
72-
name: stable - aarch64-apple-darwin - node@14
73-
runs-on: macos-latest
74-
75-
steps:
76-
- uses: actions/checkout@v2
77-
78-
- name: Setup node
79-
uses: actions/setup-node@v2
80-
with:
81-
node-version: 14
82-
83-
- name: Install Rust
84-
uses: actions-rs/toolchain@v1
85-
with:
86-
profile: minimal
87-
override: true
88-
toolchain: nightly-2021-03-25
89-
target: aarch64-apple-darwin
90-
91-
- name: Install dependencies
92-
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
93-
94-
- name: Cross build aarch64
95-
run: yarn --cwd packages/next build-native --target aarch64-apple-darwin
96-
59+
working-directory: packages/next
9760
- name: Upload artifact
9861
uses: actions/upload-artifact@v2
9962
with:
10063
name: next-swc-binaries
101-
path: packages/next/native
102-
64+
path: packages/next/native/next-swc.*.node
10365
- name: Clear the cargo caches
10466
run: |
10567
cargo install cargo-cache --no-default-features --features ci-autoclean
10668
cargo-cache
107-
10869
commit:
109-
needs: [build, build-apple-silicon]
70+
needs: build-native
11071
runs-on: ubuntu-18.04
11172

11273
steps:
11374
- uses: actions/checkout@v2
114-
if: ${{ github.event_name == 'workflow_dispatch' }}
11575
- uses: actions/download-artifact@v2
11676
with:
11777
name: next-swc-binaries
11878
path: packages/next/native
119-
if: ${{ github.event_name == 'workflow_dispatch' }}
12079
- uses: EndBug/add-and-commit@v7
12180
with:
12281
add: 'packages/next/native --force'
12382
message: 'Build next-swc binaries'
124-
if: ${{ github.event_name == 'workflow_dispatch' }}
125-
126-
check:
127-
needs: [build, build-apple-silicon]
128-
runs-on: ubuntu-18.04
129-
130-
steps:
131-
- uses: actions/checkout@v2
132-
if: ${{ github.event_name == 'pull_request' }}
133-
- uses: actions/download-artifact@v2
134-
with:
135-
name: next-swc-binaries
136-
path: packages/next/native
137-
if: ${{ github.event_name == 'pull_request' }}
138-
- run: git diff --exit-code
139-
if: ${{ github.event_name == 'pull_request' }}
140-
141-
test:
142-
runs-on: ubuntu-18.04
143-
144-
steps:
145-
- uses: actions/checkout@v2
146-
if: ${{ github.event_name == 'pull_request' }}
147-
- name: Install
148-
if: ${{ github.event_name == 'pull_request' }}
149-
uses: actions-rs/toolchain@v1
150-
with:
151-
toolchain: nightly-2021-03-25
152-
profile: minimal
153-
- run: cd packages/next/build/swc && cargo test
154-
if: ${{ github.event_name == 'pull_request' }}

.github/workflows/build_test_deploy.yml

+90-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
on:
22
push:
33
branches: [canary]
4+
tags: [v*]
45
pull_request:
56
types: [opened, synchronize]
67

@@ -45,7 +46,7 @@ jobs:
4546
checkPrecompiled:
4647
name: Check Pre-compiled
4748
runs-on: ubuntu-latest
48-
needs: build
49+
needs: [build, build-native]
4950
env:
5051
NEXT_TELEMETRY_DISABLED: 1
5152
steps:
@@ -55,6 +56,10 @@ jobs:
5556
with:
5657
path: ./*
5758
key: ${{ github.sha }}
59+
- uses: actions/download-artifact@v2
60+
with:
61+
name: next-swc-binaries
62+
path: packages/next/native
5863
- run: ./scripts/check-pre-compiled.sh
5964
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
6065

@@ -239,9 +244,10 @@ jobs:
239244
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
240245

241246
publishRelease:
247+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
242248
name: Potentially publish release
243249
runs-on: ubuntu-latest
244-
needs: build
250+
needs: [build, build-native]
245251
env:
246252
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
247253
steps:
@@ -250,7 +256,11 @@ jobs:
250256
with:
251257
path: ./*
252258
key: ${{ github.sha }}
253-
259+
- uses: actions/download-artifact@v2
260+
with:
261+
name: next-swc-binaries
262+
path: packages/next/native
263+
- run: ./scripts/prepublish-native.js
254264
- run: ./scripts/publish-release.sh
255265

256266
releaseStats:
@@ -267,3 +277,80 @@ jobs:
267277
- uses: ./.github/actions/next-stats-action
268278
env:
269279
PR_STATS_COMMENT_TOKEN: ${{ secrets.PR_STATS_COMMENT_TOKEN }}
280+
281+
build-native:
282+
strategy:
283+
matrix:
284+
os: [ubuntu-18.04, macos-latest, windows-latest]
285+
description: [default]
286+
include:
287+
- os: ubuntu-18.04
288+
target: x86_64-unknown-linux-gnu
289+
- os: windows-latest
290+
target: x86_64-pc-windows-msvc
291+
- os: macos-latest
292+
target: x86_64-apple-darwin
293+
- os: macos-latest
294+
target: aarch64-apple-darwin
295+
description: m1
296+
297+
name: next-swc - ${{ matrix.os }} - ${{ matrix.target }} - node@14
298+
runs-on: ${{ matrix.os }}
299+
300+
steps:
301+
- uses: actions/checkout@v2
302+
- name: Setup node
303+
uses: actions/setup-node@v2
304+
with:
305+
node-version: 14
306+
check-latest: true
307+
- name: Install
308+
uses: actions-rs/toolchain@v1
309+
with:
310+
profile: minimal
311+
toolchain: nightly-2021-03-25
312+
target: ${{ matrix.target }}
313+
- name: Cache cargo registry
314+
uses: actions/cache@v1
315+
with:
316+
path: ~/.cargo/registry
317+
key: stable-${{ matrix.os }}-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
318+
- name: Cache cargo index
319+
uses: actions/cache@v1
320+
with:
321+
path: ~/.cargo/git
322+
key: stable-${{ matrix.os }}-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
323+
- name: Cache native binary
324+
id: binary-cache
325+
uses: actions/cache@v2
326+
with:
327+
path: packages/next/native/**
328+
key: next-swc-nightly-2021-03-25-${{ matrix.target }}-${{ hashFiles('packages/next/build/swc/**') }}
329+
- name: 'Build'
330+
if: steps.binary-cache.outputs.cache-hit != true
331+
run: yarn build-native --target ${{ matrix.target }}
332+
env:
333+
MACOSX_DEPLOYMENT_TARGET: '10.13'
334+
working-directory: packages/next
335+
- name: Upload artifact
336+
uses: actions/upload-artifact@v2
337+
with:
338+
name: next-swc-binaries
339+
path: packages/next/native/next-swc.*.node
340+
- name: Clear the cargo caches
341+
run: |
342+
cargo install cargo-cache --no-default-features --features ci-autoclean
343+
cargo-cache
344+
345+
test-native:
346+
name: Unit Test Native Code
347+
runs-on: ubuntu-18.04
348+
349+
steps:
350+
- uses: actions/checkout@v2
351+
- name: Install
352+
uses: actions-rs/toolchain@v1
353+
with:
354+
toolchain: nightly-2021-03-25
355+
profile: minimal
356+
- run: cd packages/next/build/swc && cargo test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `next-swc-darwin-arm64`
2+
3+
This is the **aarch64-apple-darwin** binary for `next-swc`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "next-swc-darwin-arm64",
3+
"version": "0.0.0",
4+
"os": [
5+
"darwin"
6+
],
7+
"cpu": [
8+
"arm64"
9+
],
10+
"main": "next-swc.darwin-arm64.node",
11+
"files": [
12+
"next-swc.darwin-arm64.node"
13+
],
14+
"license": "MIT",
15+
"engines": {
16+
"node": ">= 10"
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `next-swc-darwin-x64`
2+
3+
This is the **x86_64-apple-darwin** binary for `next-swc`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "next-swc-darwin-x64",
3+
"version": "0.0.0",
4+
"os": [
5+
"darwin"
6+
],
7+
"cpu": [
8+
"x64"
9+
],
10+
"main": "next-swc.darwin-x64.node",
11+
"files": [
12+
"next-swc.darwin-x64.node"
13+
],
14+
"license": "MIT",
15+
"engines": {
16+
"node": ">= 10"
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `next-swc-linux-x64-gnu`
2+
3+
This is the **x86_64-unknown-linux-gnu** binary for `next-swc`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "next-swc-linux-x64-gnu",
3+
"version": "0.0.0",
4+
"os": [
5+
"linux"
6+
],
7+
"cpu": [
8+
"x64"
9+
],
10+
"main": "next-swc.linux-x64-gnu.node",
11+
"files": [
12+
"next-swc.linux-x64-gnu.node"
13+
],
14+
"license": "MIT",
15+
"engines": {
16+
"node": ">= 10"
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `next-swc-win32-x64-msvc`
2+
3+
This is the **x86_64-pc-windows-msvc** binary for `next-swc`

0 commit comments

Comments
 (0)