-
Notifications
You must be signed in to change notification settings - Fork 41
254 lines (206 loc) · 9.15 KB
/
bindings-nodejs-publish.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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
name: Node.js publish to NPM
on: workflow_dispatch
env:
CARGO_INCREMENTAL: 0
jobs:
# publish-nodejs:
# runs-on: ubuntu-latest
# defaults:
# run:
# working-directory: bindings/nodejs
# steps:
# - uses: actions/checkout@v3
# - name: Set up Rust
# uses: ./.github/actions/setup-rust
# # Required for ledger-nano
# - name: Install required packages
# run: |
# sudo apt-get update
# sudo apt-get install libudev-dev libusb-1.0-0-dev
# - name: Set up Node.js
# uses: actions/setup-node@v2
# with:
# node-version: "18.x"
# registry-url: "https://registry.npmjs.org"
# - name: Install Yarn
# run: npm i -g yarn
# - name: Install JS dependencies
# run: yarn
# - name: Build project
# run: yarn build
# - name: Update Cargo.toml with git
# run: sed -i 's#path = "../core"#git = "https://github.com/iotaledger/iota-sdk", rev = "'$GITHUB_SHA'"#g' Cargo.toml
# - name: Print Cargo.toml
# run: cat Cargo.toml
# - name: Publish nodejs bindings to NPM
# shell: sh
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# run: npm publish --access public
nodejs-binding-prebuild:
runs-on: ${{ matrix.os }}
# needs: publish-nodejs
strategy:
fail-fast: false
matrix:
# The GitHub hosted Windows 2022 image comes with Visual Studio 2022, but node-gyp
# (which is used by neon-sys) sadly fails to recognize it. As a mitigation, we still run the
# tests on Windows 2019, until we can figure out a way to fix the problem.
# os: [ubuntu-20.04, macos-13, windows-2019]
os: [macos-13]
node-version: ["18.x"]
steps:
- uses: actions/checkout@v3
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install Yarn
run: npm i -g yarn
- name: Select Xcode
uses: maxim-lobanov/setup-xcode@v1
if: matrix.os == 'macos-13'
with:
xcode-version: '14.3'
# Temporary fix for "ValueError: invalid mode: 'rU' while trying to load binding.gyp"
# This can be removed when "prebuild" updates "node-gyp"
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
# This step can be removed as soon as official Windows arm64 builds are published:
# https://github.com/nodejs/build/issues/2450#issuecomment-705853342
- name: Install Windows arm64 node.lib
if: ${{ matrix.os == 'windows-2019' }}
run: |
$NodeVersion = (node --version) -replace '^.'
$NodeFallbackVersion = "16.19.0"
& .\scripts\download-node-lib-win-arm64.ps1 $NodeVersion $NodeFallbackVersion
working-directory: bindings/nodejs
- name: Install LLVM and Clang (Windows) # required for bindgen to work, see https://github.com/rust-lang/rust-bindgen/issues/1797
uses: KyleMayes/install-llvm-action@32c4866ebb71e0949e8833eb49beeebed48532bd
if: matrix.os == 'windows-2019'
with:
version: "11.0"
directory: ${{ runner.temp }}/llvm
- name: Set LIBCLANG_PATH (Windows)
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
if: matrix.os == 'windows-2019'
- name: Install gon (macOS)
# https://github.com/mitchellh/gon
run: brew install mitchellh/gon/gon
if: ${{ startsWith(matrix.os, 'macos') }}
- name: Set deployment target (macOS)
run: echo "MACOSX_DEPLOYMENT_TARGET=10.13" >> $GITHUB_ENV
if: matrix.os == 'macos-13'
- name: Set deployment target (macOS)
if: ${{ startsWith(matrix.os, 'macos') }}
run: rustup target add aarch64-apple-darwin
- name: Set deployment target (linux)
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: rustup target add aarch64-unknown-linux-gnu
- name: Set deployment target (windows)
if: ${{ startsWith(matrix.os, 'windows') }}
run: rustup target add aarch64-pc-windows-msvc
- name: Get current date
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
if: matrix.os == 'macos-13' || ${{ startsWith(matrix.os, 'ubuntu') }}
- name: Get current date
if: matrix.os == 'windows-2019'
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install required packages (Ubuntu)
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt-get update
sudo apt-get install libudev-dev libusb-1.0-0-dev
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
# Add date to the cache to keep it up to date
key: ${{ matrix.os }}-stable-cargo-registry-${{ hashFiles('**/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.os }}-stable-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
${{ matrix.os }}-stable-cargo-registry-
- name: Cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
# Add date to the cache to keep it up to date
key: ${{ matrix.os }}-stable-cargo-index-${{ hashFiles('**/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.os }}-stable-cargo-index-${{ hashFiles('**/Cargo.lock') }}
${{ matrix.os }}-stable-cargo-index-
# This step is required to support macOS 10.13
# - name: Patch librocksdb-sys (macOS)
# if: ${{ startsWith(matrix.os, 'macos') }}
# run: |
# cargo install cargo-patch
# cp ${{ github.workspace }}/.patches/rocksdb_faligned_allocation.patch .
# git apply --ignore-space-change --ignore-whitespace ${{ github.workspace }}/.patches/macos_cargo_toml.patch
# cat Cargo.toml
# cargo patch
- name: Install dependencies
run: yarn install --frozen-lockfile
working-directory: bindings/nodejs
# - name: Build Node.js prebuild (x64)
# run: yarn run prebuild-x64
# working-directory: bindings/nodejs
- name: Build Node.js prebuild (macos, arm64)
if: ${{ startsWith(matrix.os, 'macos') }}
run: yarn run prebuild-macos-arm64
working-directory: bindings/nodejs
# - name: Build Node.js prebuild (ubuntu/linux, arm64)
# if: ${{ startsWith(matrix.os, 'ubuntu') }}
# run: |
# yarn run prebuild-linux-arm64
# working-directory: bindings/nodejs
# - name: Build Node.js prebuild (windows, arm64)
# if: ${{ startsWith(matrix.os, 'windows') }}
# run: |
# yarn run prebuild-windows-arm64
# working-directory: bindings/nodejs
- name: Import code signing assets (macOS)
# Based on https://github.com/Apple-Actions/import-codesign-certs/blob/master/src/security.ts
run: |
security create-keychain -p $KEYCHAIN_PASSWORD signing.keychain
security set-keychain-settings -lut 3600 signing.keychain
security unlock-keychain -p $KEYCHAIN_PASSWORD signing.keychain
echo $MAC_CERT_BASE64 | base64 -D -o signing.p12
security import signing.p12 -k signing.keychain -f pkcs12 -T "/usr/bin/codesign" -T "/usr/bin/security" -P $MAC_CERT_PASSWORD
rm signing.p12
security -q set-key-partition-list -S apple-tool:,apple: -k $KEYCHAIN_PASSWORD signing.keychain > /dev/null
security -v list-keychains -s signing.keychain
security find-identity -vp codesigning
env:
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
MAC_CERT_BASE64: ${{ secrets.MAC_CERT_BASE64 }}
MAC_CERT_PASSWORD: ${{ secrets.MAC_CERT_PASSWORD }}
if: ${{ startsWith(matrix.os, 'macos') }}
- name: Sign and notarize index.node binary (macOS)
run: |
ls -lh prebuilds/@iota/
# unpack to only get the index.node
tar -xvf prebuilds/@iota/sdk-v1.0.0-rc.2-napi-v6-darwin-arm64.tar.gz
ls -lh build/Release/
gon gon-config.json
unzip -o binary.zip
mkdir -p build/Release
mv -f index.node build/Release/index.node
ls -lh build/Release/
tar -czf prebuilds/@iota/sdk-v1.0.0-rc.2-napi-v6-darwin-arm64.tar.gz build/Release/index.node
env:
AC_USERNAME: ${{ secrets.ASC_APPLE_ID }}
AC_PASSWORD: ${{ secrets.ASC_PASSWORD }}
if: ${{ startsWith(matrix.os, 'macos') }}
working-directory: bindings/nodejs
- name: Upload prebuild to GitHub release
run: npx prebuild --upload-all ${{ secrets.GITHUB_TOKEN }} --tag-prefix iota-sdk-nodejs-v
working-directory: bindings/nodejs