Skip to content

Commit 56a2e37

Browse files
committed
ci: simplify and fix arm64 build
Use Github Actions arm runner instead of cross-compiling. Avoid built-in container feature due to actions/runner#801
1 parent 49ee5fc commit 56a2e37

File tree

3 files changed

+37
-158
lines changed

3 files changed

+37
-158
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ on:
99
branches:
1010
- '**'
1111
jobs:
12-
build_x86_64:
13-
name: Build x86_64
12+
build:
13+
name: Build
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
os: [macos-13, ubuntu-22.04, ubuntu-24.04, windows-2022]
18+
os: [macos-13, ubuntu-22.04, ubuntu-24.04, ubuntu-24.04-arm, windows-2022]
1919
node: [18, 20, 22, 24]
2020
steps:
2121
- name: Checkout repository
@@ -29,94 +29,40 @@ jobs:
2929
node-version: ${{ matrix.node }}
3030

3131
- name: Install dependencies
32-
run: npm install
33-
34-
- name: Package prebuild
35-
run: npm run build
36-
37-
build_musl_x86_64:
38-
name: Build x86_64 (musl)
39-
runs-on: ubuntu-latest
40-
container:
41-
image: node:${{ matrix.node }}-alpine
42-
strategy:
43-
fail-fast: false
44-
matrix:
45-
node: [18, 20, 22, 24]
46-
steps:
47-
- name: Setup env with Node v${{ matrix.node }}
48-
run: |
49-
apk add --update
50-
apk add --no-cache ca-certificates git curl build-base python3 g++ make
51-
52-
- name: Checkout repository
53-
uses: actions/checkout@v4
54-
with:
55-
submodules: true
56-
57-
- name: Install dependencies
58-
run: npm install
32+
run: npm install --build-from-source
5933

6034
- name: Package prebuild
6135
run: npm run build
6236

63-
build_aarch64_linux:
64-
name: Prebuild aarch64 Linux
65-
runs-on: ubuntu-24.04
37+
build_musl:
38+
name: Build musl
39+
runs-on: ${{ matrix.os }}
6640
strategy:
6741
fail-fast: false
6842
matrix:
43+
os: [ubuntu-latest, ubuntu-24.04-arm]
6944
node: [18, 20, 22, 24]
7045
steps:
7146
- name: Checkout repository
7247
uses: actions/checkout@v4
7348
with:
7449
submodules: true
7550

76-
- name: Install Node v${{ matrix.node }}
77-
uses: actions/setup-node@v3
78-
with:
79-
node-version: ${{ matrix.node }}
80-
81-
- name: Install dependencies
82-
run: npm install --build-from-source
83-
84-
- name: Package prebuild
51+
# Workaround https://github.com/actions/runner/issues/801
52+
- name: Setup container
8553
run: |
86-
sudo apt update -y && sudo apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
87-
CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ npx node-pre-gyp --target_arch=arm64 configure build package
54+
docker run --name runner --rm -it -d -v $PWD:/node-opus -w /node-opus node:${{ matrix.node }}-alpine
8855
89-
build_musl_aarch64:
90-
name: Prebuild aarch64 (musl)
91-
runs-on: ubuntu-latest
92-
container:
93-
image: node:${{ matrix.node }}-alpine
94-
strategy:
95-
fail-fast: false
96-
matrix:
97-
node: [18, 20, 22, 24]
98-
steps:
9956
- name: Setup env with Node v${{ matrix.node }}
10057
run: |
101-
apk add --update
102-
apk add --no-cache ca-certificates git curl build-base python3 g++ make
103-
104-
- name: Checkout repository
105-
uses: actions/checkout@v4
106-
with:
107-
submodules: true
108-
109-
- name: Setup musl cross compiler
110-
run: |
111-
curl -OL https://musl.cc/aarch64-linux-musl-cross.tgz
112-
tar -xzvf aarch64-linux-musl-cross.tgz
113-
$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc --version
58+
docker exec runner apk add --update
59+
docker exec runner apk add --no-cache ca-certificates git curl build-base python3 g++ make
11460
11561
- name: Install dependencies
116-
run: npm install --unsafe-perm --build-from-source
62+
run: docker exec runner npm install --build-from-source
11763

11864
- name: Package prebuild
119-
run: |
120-
CC=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc \
121-
CXX=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-g++ \
122-
npx node-pre-gyp --target_arch=arm64 configure build package
65+
run: docker exec runner npm run build
66+
67+
- name: Stop container
68+
run: docker rm -f runner

.github/workflows/release.yml

Lines changed: 18 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ on:
33
release:
44
types: [published]
55
jobs:
6-
build_x86_64:
7-
name: Prebuild x86_64
6+
build:
7+
name: Prebuild
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
os: [macos-13, ubuntu-22.04, ubuntu-24.04, windows-2022]
12+
os: [macos-13, ubuntu-22.04, ubuntu-24.04, ubuntu-24.04-arm, windows-2022]
1313
node: [18, 20, 22, 24]
1414
steps:
1515
- name: Checkout repository
@@ -23,40 +23,7 @@ jobs:
2323
node-version: ${{ matrix.node }}
2424

2525
- name: Install dependencies
26-
run: npm install
27-
28-
- name: Package prebuild
29-
run: npm run build
30-
31-
- name: Upload prebuild asset
32-
uses: icrawl/action-artifact@v2
33-
env:
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35-
with:
36-
path: 'build/stage/**/*.tar.gz'
37-
38-
build_musl_x86_64:
39-
name: Prebuild x86_64 (musl)
40-
runs-on: ubuntu-latest
41-
container:
42-
image: node:${{ matrix.node }}-alpine
43-
strategy:
44-
fail-fast: false
45-
matrix:
46-
node: [18, 20, 22, 24]
47-
steps:
48-
- name: Setup env with Node v${{ matrix.node }}
49-
run: |
50-
apk add --update
51-
apk add --no-cache ca-certificates git curl build-base python3 g++ make
52-
53-
- name: Checkout repository
54-
uses: actions/checkout@v4
55-
with:
56-
submodules: true
57-
58-
- name: Install dependencies
59-
run: npm install
26+
run: npm install --build-from-source
6027

6128
- name: Package prebuild
6229
run: npm run build
@@ -68,73 +35,38 @@ jobs:
6835
with:
6936
path: 'build/stage/**/*.tar.gz'
7037

71-
build_aarch64_linux:
72-
name: Prebuild aarch64 Linux
73-
runs-on: ubuntu-24.04
38+
build_musl:
39+
name: Prebuild musl
40+
runs-on: ${{ matrix.os }}
7441
strategy:
7542
fail-fast: false
7643
matrix:
44+
os: [ubuntu-latest, ubuntu-24.04-arm]
7745
node: [18, 20, 22, 24]
7846
steps:
7947
- name: Checkout repository
8048
uses: actions/checkout@v4
8149
with:
8250
submodules: true
8351

84-
- name: Install Node v${{ matrix.node }}
85-
uses: actions/setup-node@v3
86-
with:
87-
node-version: ${{ matrix.node }}
88-
89-
- name: Install dependencies
90-
run: npm install --build-from-source
91-
92-
- name: Package prebuild
52+
# Workaround https://github.com/actions/runner/issues/801
53+
- name: Setup container
9354
run: |
94-
sudo apt update -y && sudo apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
95-
CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ npx node-pre-gyp --target_arch=arm64 configure build package
96-
97-
- name: Upload prebuild asset
98-
uses: icrawl/action-artifact@v2
99-
env:
100-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101-
with:
102-
path: 'build/stage/**/*.tar.gz'
55+
docker run --name runner --rm -it -d -v $PWD:/node-opus -w /node-opus node:${{ matrix.node }}-alpine
10356
104-
build_musl_aarch64:
105-
name: Prebuild aarch64 (musl)
106-
runs-on: ubuntu-latest
107-
container:
108-
image: node:${{ matrix.node }}-alpine
109-
strategy:
110-
fail-fast: false
111-
matrix:
112-
node: [18, 20, 22, 24]
113-
steps:
11457
- name: Setup env with Node v${{ matrix.node }}
11558
run: |
116-
apk add --update
117-
apk add --no-cache ca-certificates git curl build-base python3 g++ make
118-
119-
- name: Checkout repository
120-
uses: actions/checkout@v4
121-
with:
122-
submodules: true
123-
124-
- name: Setup musl cross compiler
125-
run: |
126-
curl -OL https://musl.cc/aarch64-linux-musl-cross.tgz
127-
tar -xzvf aarch64-linux-musl-cross.tgz
128-
$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc --version
59+
docker exec runner apk add --update
60+
docker exec runner apk add --no-cache ca-certificates git curl build-base python3 g++ make
12961
13062
- name: Install dependencies
131-
run: npm install --unsafe-perm --build-from-source
63+
run: docker exec runner npm install --build-from-source
13264

13365
- name: Package prebuild
134-
run: |
135-
CC=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc \
136-
CXX=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-g++ \
137-
npx node-pre-gyp --target_arch=arm64 configure build package
66+
run: docker exec runner npm run build
67+
68+
- name: Stop container
69+
run: docker rm -f runner
13870

13971
- name: Upload prebuild asset
14072
uses: icrawl/action-artifact@v2

deps/binding.gyp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@
218218
"include_dirs": [
219219
"opus",
220220
],
221+
"defines": ["OPUS_ARM_MAY_HAVE_NEON_INTR"],
221222
}
222223
],
223224
],

0 commit comments

Comments
 (0)