Skip to content

Commit

Permalink
Test with signing
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M committed Jul 5, 2023
1 parent f586312 commit 3b53e67
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 51 deletions.
169 changes: 121 additions & 48 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 @@ -115,10 +116,27 @@ jobs:
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') }}
Expand Down Expand Up @@ -155,25 +173,80 @@ jobs:
${{ 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: 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
# - 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 (arm64)
run: yarn run prebuild-arm64
# - 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
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ crate-type = [ "cdylib" ]
doc = false

[dependencies]
iota-sdk-bindings-core = { path = "../core", default-features = false, features = [ "events", "ledger_nano", "storage", "stronghold", "participation", "rocksdb", "mqtt" ] }
iota-sdk-bindings-core = { path = "../core", default-features = false, features = [ "events", "mqtt" ] }

log = { version = "0.4.18", default-features = false }
neon = { version = "0.10.1", default-features = false, features = [ "napi-6", "event-queue-api", "promise-api" ] }
Expand Down
13 changes: 13 additions & 0 deletions bindings/nodejs/gon-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"source": ["./build/Release/index.node"],
"bundle_id": "org.iota.cli-wallet",
"apple_id": {
"password": "@env:AC_PASSWORD"
},
"sign": {
"application_identity": "Developer ID Application: IOTA Stiftung (UG77RJKZHH)"
},
"zip": {
"output_path": "./binary.zip"
}
}
9 changes: 7 additions & 2 deletions bindings/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iota/sdk",
"version": "1.0.0-rc.1",
"version": "1.0.0-rc.2",
"description": "Node.js binding to the IOTA SDK library",
"main": "out/index.js",
"types": "out/index.d.ts",
Expand All @@ -10,8 +10,13 @@
"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",
"prebuild-linux-x64": "prebuild --runtime napi --target 6 --prepack 'npm run neon-build-linux-x64' --strip --arch x64",
"neon-build-linux-x64": "cargo-cp-artifact -ac iota-sdk-nodejs ./index.node -- cargo build --release --message-format=json-render-diagnostics && node -e \"require('./scripts/move-artifact.js')()\"",
"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-macos-arm64": "prebuild --runtime napi --target 6 --prepack 'yarn run neon-build-macos-arm64' --strip --arch arm64",
"neon-build-macos-arm64": "cargo-cp-artifact -ac iota-sdk-nodejs ./index.node -- cargo build --release --message-format=json-render-diagnostics --target aarch64-apple-darwin && node -e \"require('./scripts/move-artifact.js')()\"",
"prebuild-linux-arm64": "prebuild --runtime napi --target 6 --prepack 'cargo-cp-artifact -ac iota-sdk-nodejs ./index.node -- cargo build --release --message-format=json-render-diagnostics --target aarch64-unknown-linux-gnu' --strip --arch arm64",
"prebuild-windows-arm64": "prebuild --runtime napi --target 6 --prepack 'cargo-cp-artifact -ac iota-sdk-nodejs ./index.node -- cargo build --release --message-format=json-render-diagnostics --target aarch64-pc-windows-msvc' --strip --arch 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"
Expand Down
1 change: 1 addition & 0 deletions bindings/nodejs/scripts/move-artifact.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const moveArtifact = () => {
mkdirSync(path, { recursive: true });
}
renameSync(resolve(__dirname, '../index.node'), resolve(path, 'index.node'));
console.log("moved file")
};

module.exports = moveArtifact;

0 comments on commit 3b53e67

Please sign in to comment.