-
-
Notifications
You must be signed in to change notification settings - Fork 416
228 lines (177 loc) · 6.26 KB
/
npm.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
name: Publish to NPM
on:
workflow_dispatch:
inputs:
dry_run:
description: "Just build, don't publish"
default: false
required: false
type: boolean
npm_tag:
description: 'NPM tag'
required: true
default: 'latest'
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest]
include:
- os: macos-latest
rust-cross-target: x86_64-apple-darwin
- os: windows-latest
rust-cross-target: aarch64-pc-windows-msvc
# Ubuntu binaries are built using Docker, below
timeout-minutes: 45
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
- name: Checking run eligibility
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const dryRun = ${{ inputs.dry_run }};
const refType = '${{ github.ref_type }}';
const refName = '${{ github.ref_name }}';
console.log(dryRun
? `Running in 'dry run' mode on '${refName}' ${refType}`
: `Running on '${refName}' ${refType}`);
if (refType !== 'tag' && !dryRun) {
core.setFailed("the action should either be launched on a tag or with a 'dry run' switch");
}
- run: rustup toolchain install $(cat rust-toolchain) --profile minimal --target ${{ matrix.rust-cross-target }}
# install nasm compiler for boring
- name: (Windows) Install nasm
if: startsWith(matrix.os, 'windows')
run: choco install nasm
shell: cmd
- run: choco install protoc
if: startsWith(matrix.os, 'windows')
- run: brew install protobuf
if: startsWith(matrix.os, 'macos')
- run: cargo +stable install dump_syms --no-default-features --features cli
- name: Get Node version from .nvmrc
id: get-nvm-version
shell: bash
run: echo "node-version=$(cat .nvmrc)" >> $GITHUB_OUTPUT
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.24
with:
node-version-file: '.nvmrc'
- run: npx yarn install --frozen-lockfile
working-directory: node
- name: Build for arm64
run: npx prebuildify --napi -t ${{ steps.get-nvm-version.outputs.node-version }} --arch arm64
working-directory: node
- name: Save arm64 debug info
run: mv build/Release/*-debuginfo.* .
working-directory: node
shell: bash
- name: Build for x64
run: npx prebuildify --napi -t ${{ steps.get-nvm-version.outputs.node-version }} --arch x64
working-directory: node
- name: Save x64 debug info
run: mv build/Release/*-debuginfo.* .
working-directory: node
shell: bash
- name: Upload library
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: libsignal_client (${{matrix.os}})
path: node/prebuilds/*
- name: Upload debug info
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: Debug info (${{matrix.os}})
path: |
node/*-debuginfo.*
!node/*.sha256
build-docker:
name: Build (Ubuntu via Docker)
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
- run: node/docker-prebuildify.sh
- name: Upload library
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: libsignal_client (ubuntu-docker)
path: node/prebuilds/*
- name: Upload debug info
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: Debug info (ubuntu-docker)
path: |
node/*-debuginfo.*
!node/*.sha256
verify-rust:
name: Verify Node bindings
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
- run: rustup toolchain install $(cat rust-toolchain) --profile minimal
- run: sudo apt-get update && sudo apt-get install protobuf-compiler
- name: Verify that the Node bindings are up to date
run: rust/bridge/node/bin/gen_ts_decl.py --verify
publish:
name: Publish
permissions:
# Needed for ncipollo/release-action.
contents: 'write'
runs-on: ubuntu-latest
needs: [build, build-docker, verify-rust]
timeout-minutes: 45
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org/'
- name: Download built libraries
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
pattern: libsignal_client*
path: node/prebuilds
merge-multiple: true
- name: Download debug info
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
pattern: Debug info*
path: debuginfo
merge-multiple: true
- run: yarn install --frozen-lockfile
working-directory: node
- run: yarn tsc
working-directory: node
- run: yarn lint
working-directory: node
- run: yarn format -c
working-directory: node
- run: yarn test
working-directory: node
env:
PREBUILDS_ONLY: 1
- run: npm publish --tag ${{ github.event.inputs.npm_tag }} --access public ${{ inputs.dry_run && '--dry-run' || ''}}
working-directory: node
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# This step is expected to fail if not run on a tag.
- name: Upload debug info to release
uses: ncipollo/release-action@66b1844f0b7ef940787c9d128846d5ac09b3881f # v1.14
if: ${{ !inputs.dry_run }}
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: debuginfo/*-debuginfo.*