Skip to content

Commit

Permalink
Test and sign
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M committed Jun 27, 2023
1 parent 17d94c0 commit b4e348a
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 49 deletions.
93 changes: 56 additions & 37 deletions .github/workflows/bindings-nodejs-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,62 +6,63 @@ env:
CARGO_INCREMENTAL: 0

jobs:
publish-nodejs:
runs-on: ubuntu-latest
# publish-nodejs:
# runs-on: ubuntu-latest

defaults:
run:
working-directory: bindings/nodejs
# defaults:
# run:
# working-directory: bindings/nodejs

steps:
- uses: actions/checkout@v3
# steps:
# - uses: actions/checkout@v3

- name: Set up Rust
uses: ./.github/actions/setup-rust
# - 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
# # 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: 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 Yarn
# run: npm i -g yarn

- name: Install JS dependencies
run: yarn
# - name: Install JS dependencies
# run: yarn

- name: Build project
run: yarn build
# - 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: 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: 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
# - 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
# 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: [ubuntu-20.04, macos-13, windows-2019]
os: [macos-13]
node-version: ["18.x"]

steps:
Expand Down Expand Up @@ -119,6 +120,10 @@ jobs:
run: echo "MACOSX_DEPLOYMENT_TARGET=10.13" >> $GITHUB_ENV
if: matrix.os == 'macos-13'

- name: Set deployment target (macOS)
if: matrix.os == 'macos-13'
run: rustup target add aarch64-apple-darwin

- name: Get current date
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
if: matrix.os == 'macos-13' || ${{ startsWith(matrix.os, 'ubuntu') }}
Expand Down Expand Up @@ -169,13 +174,27 @@ jobs:
working-directory: bindings/nodejs

- name: Build Node.js prebuild (x64)
if: ${{ !startsWith(matrix.os, 'macos') }}
run: yarn run prebuild-x64
working-directory: bindings/nodejs

- name: Build Node.js prebuild (arm64)
run: yarn run prebuild-arm64
if: ${{ !startsWith(matrix.os, 'macos') }}
run: |
yarn run prebuild-arm64
working-directory: bindings/nodejs

- name: Build Node.js prebuild (darwin-x64+arm64)
if: ${{ startsWith(matrix.os, 'macos') }}
run: |
yarn run prebuild-darwin-x64+arm64
working-directory: bindings/nodejs

- name: Sign index.node (arm64)
if: ${{ startsWith(matrix.os, 'macos') }}
working-directory: bindings/nodejs/build/Release
run: codesign -s - index.node

- name: Upload prebuild to GitHub release
run: npx prebuild --upload-all ${{ secrets.GITHUB_TOKEN }} --tag-prefix iota-sdk-nodejs-v
working-directory: bindings/nodejs
43 changes: 33 additions & 10 deletions bindings/nodejs/binding.gyp
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
{
"targets": [
{
"target_name": "index",
'defines': [
"NAPI_VERSION=<(napi_build_version)",
],
"win_delay_load_hook": "true",
}
]
}
"targets": [
{
"target_name": "index",
'defines': [
"NAPI_VERSION=<(napi_build_version)",
],
"win_delay_load_hook": "true",
"conditions": [
["OS == 'mac'", {
"cflags+": ["-fvisibility=hidden"],
"xcode_settings": {
# -fvisibility=hidden
"GCC_SYMBOLS_PRIVATE_EXTERN": "YES",

# Set minimum target version because we're building on newer
# Same as https://github.com/nodejs/node/blob/v11.0.0/common.gypi#L464
"MACOSX_DEPLOYMENT_TARGET": "10.7",

# Build universal binary to support M1 (Apple silicon)
"OTHER_CFLAGS": [
"-arch x86_64",
"-arch arm64"
],
"OTHER_LDFLAGS": [
"-arch x86_64",
"-arch arm64"
]
}
}]
]
}
]
}
5 changes: 3 additions & 2 deletions bindings/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
"format": "prettier --ignore-path .eslintignore -w \"{,*/**/}*.{ts,js,json}\"",
"format-check": "prettier --ignore-path .eslintignore -c \"{,*/**/}*.{ts,js,json}\"",
"build": "node scripts/neon-build && tsc",
"build:neon": "cargo-cp-artifact -ac iota-sdk-nodejs ./index.node -- cargo build --release --message-format=json-render-diagnostics",
"build:neon": "cargo-cp-artifact -ac iota-sdk-nodejs ./index.node -- cargo build --release --message-format=json-render-diagnostics --target aarch64-apple-darwin",
"docs-wiki-build": "typedoc --githubPages false --disableSources --excludePrivate --excludeInternal --excludeNotDocumented --plugin typedoc-plugin-markdown --theme markdown --hideBreadcrumbs --entryDocument api_ref.md --readme none --hideGenerator --sort source-order --exclude ./**/src/index.ts --out ../../documentation/sdk/docs/references/nodejs ./lib/index.ts ",
"prebuild-x64": "prebuild --runtime napi --target 6 --prepack scripts/neon-build.js --strip --arch x64",
"prebuild-arm64": "prebuild --runtime napi --target 6 --prepack scripts/neon-build.js --strip --arch arm64",
"prebuild-darwin-x64+arm64": "prebuild --runtime napi --target 6 --prepack scripts/neon-build.js --strip --arch x64+arm64",
"rebuild": "node scripts/neon-build && tsc && node scripts/strip.js",
"install": "prebuild-install --runtime napi --tag-prefix='iota-sdk-nodejs-v' && tsc || npm run rebuild",
"test": "jest --forceExit"
Expand Down Expand Up @@ -54,7 +55,7 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/iotaledger/iota-sdk.git"
"url": "git+https://github.com/Thoralf-M/iota-sdk.git"
},
"binary": {
"napi_versions": [
Expand Down

0 comments on commit b4e348a

Please sign in to comment.