Skip to content

Commit b2c7b31

Browse files
Next swc publish flow (redo) (#27984)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 40f85f6 commit b2c7b31

File tree

15 files changed

+279
-103
lines changed

15 files changed

+279
-103
lines changed

.github/workflows/build_native.yml

Lines changed: 27 additions & 99 deletions
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

Lines changed: 94 additions & 3 deletions
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

@@ -46,7 +47,7 @@ jobs:
4647
checkPrecompiled:
4748
name: Check Pre-compiled
4849
runs-on: ubuntu-latest
49-
needs: build
50+
needs: [build, build-native]
5051
env:
5152
NEXT_TELEMETRY_DISABLED: 1
5253
steps:
@@ -56,6 +57,14 @@ jobs:
5657
with:
5758
path: ./*
5859
key: ${{ github.sha }}
60+
- uses: actions/download-artifact@v2
61+
with:
62+
name: next-swc-binaries
63+
path: packages/next/build/swc/dist
64+
# Only check linux build for now, mac builds can sometimes be different even with the same code
65+
- run: |
66+
mv ./packages/next/build/swc/dist/next-swc.linux-x64-gnu.node \
67+
./packages/next/native/next-swc.linux-x64-gnu.node
5968
- run: ./scripts/check-pre-compiled.sh
6069
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
6170

@@ -240,9 +249,10 @@ jobs:
240249
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
241250

242251
publishRelease:
252+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
243253
name: Potentially publish release
244254
runs-on: ubuntu-latest
245-
needs: build
255+
needs: [build, build-native]
246256
env:
247257
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
248258
steps:
@@ -251,7 +261,11 @@ jobs:
251261
with:
252262
path: ./*
253263
key: ${{ github.sha }}
254-
264+
- uses: actions/download-artifact@v2
265+
with:
266+
name: next-swc-binaries
267+
path: packages/next/build/swc/dist
268+
- run: ./scripts/publish-native.js $GITHUB_REF
255269
- run: ./scripts/publish-release.sh
256270

257271
releaseStats:
@@ -268,3 +282,80 @@ jobs:
268282
- uses: ./.github/actions/next-stats-action
269283
env:
270284
PR_STATS_COMMENT_TOKEN: ${{ secrets.PR_STATS_COMMENT_TOKEN }}
285+
286+
build-native:
287+
strategy:
288+
matrix:
289+
os: [ubuntu-18.04, macos-latest, windows-latest]
290+
description: [default]
291+
include:
292+
- os: ubuntu-18.04
293+
target: x86_64-unknown-linux-gnu
294+
- os: windows-latest
295+
target: x86_64-pc-windows-msvc
296+
- os: macos-latest
297+
target: x86_64-apple-darwin
298+
- os: macos-latest
299+
target: aarch64-apple-darwin
300+
description: m1
301+
302+
name: next-swc - ${{ matrix.os }} - ${{ matrix.target }} - node@14
303+
runs-on: ${{ matrix.os }}
304+
305+
steps:
306+
- uses: actions/checkout@v2
307+
- name: Setup node
308+
uses: actions/setup-node@v2
309+
with:
310+
node-version: 14
311+
check-latest: true
312+
- name: Install
313+
uses: actions-rs/toolchain@v1
314+
with:
315+
profile: minimal
316+
toolchain: nightly-2021-03-25
317+
target: ${{ matrix.target }}
318+
- name: Cache cargo registry
319+
uses: actions/cache@v1
320+
with:
321+
path: ~/.cargo/registry
322+
key: stable-${{ matrix.os }}-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
323+
- name: Cache cargo index
324+
uses: actions/cache@v1
325+
with:
326+
path: ~/.cargo/git
327+
key: stable-${{ matrix.os }}-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
328+
- name: Cache native binary
329+
id: binary-cache
330+
uses: actions/cache@v2
331+
with:
332+
path: packages/next/native/next-swc.*.node
333+
key: next-swc-nightly-2021-03-25-${{ matrix.target }}-${{ hashFiles('packages/next/build/swc/**') }}
334+
- name: 'Build'
335+
if: steps.binary-cache.outputs.cache-hit != 'true'
336+
run: yarn build-native --target ${{ matrix.target }}
337+
env:
338+
MACOSX_DEPLOYMENT_TARGET: '10.13'
339+
working-directory: packages/next
340+
- name: Upload artifact
341+
uses: actions/upload-artifact@v2
342+
with:
343+
name: next-swc-binaries
344+
path: packages/next/native/next-swc.*.node
345+
- name: Clear the cargo caches
346+
run: |
347+
cargo install cargo-cache --no-default-features --features ci-autoclean
348+
cargo-cache
349+
350+
test-native:
351+
name: Unit Test Native Code
352+
runs-on: ubuntu-18.04
353+
354+
steps:
355+
- uses: actions/checkout@v2
356+
- name: Install
357+
uses: actions-rs/toolchain@v1
358+
with:
359+
toolchain: nightly-2021-03-25
360+
profile: minimal
361+
- run: cd packages/next/build/swc && cargo test
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
next-swc.*.node
Lines changed: 3 additions & 0 deletions
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`
Lines changed: 18 additions & 0 deletions
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+
}
Lines changed: 3 additions & 0 deletions
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`
Lines changed: 18 additions & 0 deletions
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+
}
Lines changed: 3 additions & 0 deletions
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`
Lines changed: 18 additions & 0 deletions
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+
}
Lines changed: 3 additions & 0 deletions
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)