-
Notifications
You must be signed in to change notification settings - Fork 17
184 lines (154 loc) · 5.13 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Release
on:
workflow_dispatch:
release:
types:
- published
jobs:
build:
name: Build Node.JS binding
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
arch: x86_64
compiler: gnu
platform: unknown-linux
# TODO: Enable build for arm64 linux gnu
# - os: ubuntu-latest
# arch: aarch64
# node_arch: arm64
# compiler: gnu
# platform: unknown-linux
# build_dependencies:
# - gcc-aarch64-linux-gnu
# - binutils-aarch64-linux-gnu
# - clang
- os: ubuntu-latest
arch: x86_64
compiler: musl
platform: unknown-linux
build_dependencies:
- musl-tools
- os: ubuntu-latest
arch: aarch64
node_arch: arm64
compiler: musl
platform: unknown-linux
- os: macos-11
arch: x86_64
platform: apple-darwin
- os: macos-11
arch: aarch64
node_arch: arm64
platform: apple-darwin
runs-on: ${{ matrix.os }}
steps:
- name: Check out repo
uses: actions/checkout@v2
- name: Setup Node.JS
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install NPM deps
run: npm ci
- name: Set target name
uses: actions/github-script@v5
id: set-target
with:
script: |
let target = '${{ matrix.arch }}-${{ matrix.platform }}';
if ('${{ matrix.compiler }}') {
target += '-${{ matrix.compiler }}';
}
core.info(`Set target ${target}`);
return target;
result-encoding: string
- name: Install build deps
if: ${{ matrix.os == 'ubuntu-latest' && matrix.build_dependencies && matrix.build_dependencies[0] }}
run: |
sudo apt-get update
sudo apt-get install ${{ join(matrix.build_dependencies, ' ') }}
- name: Fix missing "musl-g++" for x86_64-unknown-linux-musl # https://github.com/rust-lang/cargo/issues/3359
if: ${{ steps.set-target.outputs.result == 'x86_64-unknown-linux-musl' }}
run: sudo ln -s /bin/g++ /bin/musl-g++
- name: Setup Rust toolchain and target
if: ${{ steps.set-target.outputs.result != 'aarch64-unknown-linux-musl' }}
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
target: ${{ steps.set-target.outputs.result }}
- name: Set defualt target to cargo config
uses: DamianReeves/[email protected]
with:
path: .cargo/config.toml
write-mode: append
contents: |
[build]
target = "${{ steps.set-target.outputs.result }}"
- name: Set LIBC env
uses: actions/github-script@v5
id: set-libc
with:
script: |
let env = '';
if (${{ matrix.compiler == 'musl' }}) {
env = 'musl'
}
core.info(`Set LIBC env to "${env}"`);
return env;
result-encoding: string
- name: Run tests
run: npm test
if: ${{ steps.set-target.outputs.result != 'aarch64-unknown-linux-musl' && steps.set-target.outputs.result != 'aarch64-apple-darwin' }}
env:
LIBC: ${{ steps.set-libc.outputs.result }}
ARCH: ${{ matrix.node_arch }} # Overwrite current arch with target one
- name: Build aarch64-unknown-linux-musl
if: ${{ steps.set-target.outputs.result == 'aarch64-unknown-linux-musl' }}
uses: docker://messense/rust-musl-cross:aarch64-musl
with:
workdir: /github/workspace/
entrypoint: node-grove/docker/build-aarch64-unknown-linux-musl.sh
- name: Build
if: ${{ steps.set-target.outputs.result != 'aarch64-unknown-linux-musl' }}
run: npm run build:release
env:
LIBC: ${{ steps.set-libc.outputs.result }}
ARCH: ${{ matrix.node_arch }} # Overwrite current arch with target one
- name: Upload prebuild artifacts
uses: actions/upload-artifact@v2
with:
name: prebuilds
path: prebuilds/
publish:
name: Publish NPM Package
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Check package version matches tag
uses: geritol/[email protected]
env:
TAG_PREFIX: v
- name: Setup Node.JS
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install NPM deps
run: npm ci
- name: Download prebuild artifacts
uses: actions/download-artifact@v2
with:
name: prebuilds
path: prebuilds
- name: List prebuilds
run: ls -laR prebuilds
- name: Publish NPM package
uses: JS-DevTools/npm-publish@v1
with:
access: public
token: ${{ secrets.NPM_TOKEN }}