|
1 | | -on: |
2 | | - workflow_dispatch: |
3 | | - pull_request: |
4 | | - types: [opened, synchronize] |
5 | | - paths: |
6 | | - - 'packages/next/build/swc/**' |
| 1 | +on: workflow_dispatch |
7 | 2 |
|
8 | 3 | name: Build next-swc native binaries |
9 | 4 |
|
10 | 5 | jobs: |
11 | | - build: |
| 6 | + build-native: |
12 | 7 | strategy: |
13 | 8 | matrix: |
14 | 9 | 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 |
17 | 23 | runs-on: ${{ matrix.os }} |
18 | 24 |
|
19 | 25 | steps: |
20 | 26 | - uses: actions/checkout@v2 |
21 | | - |
22 | 27 | - name: Setup node |
23 | 28 | uses: actions/setup-node@v2 |
24 | 29 | with: |
25 | 30 | node-version: 14 |
26 | 31 | check-latest: true |
27 | | - |
28 | 32 | - name: Install |
29 | 33 | uses: actions-rs/toolchain@v1 |
30 | 34 | with: |
31 | | - toolchain: stable |
32 | 35 | profile: minimal |
33 | | - |
| 36 | + toolchain: nightly-2021-03-25 |
| 37 | + target: ${{ matrix.target }} |
34 | 38 | - name: Cache cargo registry |
35 | 39 | uses: actions/cache@v1 |
36 | 40 | with: |
37 | 41 | path: ~/.cargo/registry |
38 | 42 | key: stable-${{ matrix.os }}-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }} |
39 | | - |
40 | 43 | - name: Cache cargo index |
41 | 44 | uses: actions/cache@v1 |
42 | 45 | with: |
43 | 46 | path: ~/.cargo/git |
44 | 47 | 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 |
48 | 51 | 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/**') }} |
55 | 54 | - 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 }} |
57 | 57 | env: |
58 | 58 | 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 |
97 | 60 | - name: Upload artifact |
98 | 61 | uses: actions/upload-artifact@v2 |
99 | 62 | with: |
100 | 63 | name: next-swc-binaries |
101 | | - path: packages/next/native |
102 | | - |
| 64 | + path: packages/next/native/next-swc.*.node |
103 | 65 | - name: Clear the cargo caches |
104 | 66 | run: | |
105 | 67 | cargo install cargo-cache --no-default-features --features ci-autoclean |
106 | 68 | cargo-cache |
107 | | -
|
108 | 69 | commit: |
109 | | - needs: [build, build-apple-silicon] |
| 70 | + needs: build-native |
110 | 71 | runs-on: ubuntu-18.04 |
111 | 72 |
|
112 | 73 | steps: |
113 | 74 | - uses: actions/checkout@v2 |
114 | | - if: ${{ github.event_name == 'workflow_dispatch' }} |
115 | 75 | - uses: actions/download-artifact@v2 |
116 | 76 | with: |
117 | 77 | name: next-swc-binaries |
118 | 78 | path: packages/next/native |
119 | | - if: ${{ github.event_name == 'workflow_dispatch' }} |
120 | 79 | - uses: EndBug/add-and-commit@v7 |
121 | 80 | with: |
122 | 81 | add: 'packages/next/native --force' |
123 | 82 | 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' }} |
0 commit comments