From 22e4e82f09ab25bc0eb7a6e2f1b0bf0de3d0a6b9 Mon Sep 17 00:00:00 2001 From: Neal Date: Mon, 21 Oct 2024 13:29:51 -0700 Subject: [PATCH 01/11] update ts actions --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db942a1..6fdcf2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -426,8 +426,11 @@ jobs: uses: cashapp/activate-hermit@v1 with: cache: true - - name: Lint - # NOTE: only currently testing nodejs in the CI, not the browser + - name: Build WASM + run: | + cd bindings/tbdex_wasm + wasm-pack build --target nodejs --out-dir ../../bound/typescript/pkg + - name: Lint and Test run: | cd bound/typescript npm install From 8d8106b36bf9973952250cbe713a8f5d96e6dc07 Mon Sep 17 00:00:00 2001 From: Neal Date: Mon, 21 Oct 2024 13:34:57 -0700 Subject: [PATCH 02/11] update --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6fdcf2b..7ff55a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -426,6 +426,9 @@ jobs: uses: cashapp/activate-hermit@v1 with: cache: true + - name: Install wasm-pack + run: | + curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: Build WASM run: | cd bindings/tbdex_wasm @@ -438,3 +441,4 @@ jobs: npm run build npm run test:node:cjs npm run test:node:esm + From 264b7a1955de8d11bd3d17d25bcf6f40eb023bda Mon Sep 17 00:00:00 2001 From: Neal Date: Mon, 21 Oct 2024 13:40:12 -0700 Subject: [PATCH 03/11] update --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ff55a6..1d46d42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -419,16 +419,17 @@ jobs: path: test-results/rust-test-results.xml typescript: - runs-on: macos-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Init Hermit uses: cashapp/activate-hermit@v1 with: cache: true - - name: Install wasm-pack - run: | - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + - name: Setup + run: just setup + - name: Bind Wasm + run: just bind-typescript - name: Build WASM run: | cd bindings/tbdex_wasm @@ -440,5 +441,4 @@ jobs: npm run clean npm run build npm run test:node:cjs - npm run test:node:esm - + npm run test:node:esm \ No newline at end of file From 029d55fe7263b05f84298f604881cbb47a8b88c0 Mon Sep 17 00:00:00 2001 From: Neal Date: Mon, 21 Oct 2024 13:43:07 -0700 Subject: [PATCH 04/11] update justfile --- Justfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Justfile b/Justfile index 33123e5..f4fef02 100644 --- a/Justfile +++ b/Justfile @@ -31,6 +31,11 @@ lint: setup bind: setup just bind-kotlin + just bind-typescript + +test-bound: setup + just test-kotlin + just test-typescript bind-kotlin: setup cargo build --release --package tbdex_uniffi --target aarch64-apple-darwin @@ -45,13 +50,10 @@ bind-kotlin: setup sed -i '' 's/findLibraryName(componentName)/detectSystemTarget()/' target/bindgen-kotlin/tbdex/sdk/rust/tbdex.kt cp target/bindgen-kotlin/tbdex/sdk/rust/tbdex.kt bound/kt/src/main/kotlin/tbdex/sdk/rust/UniFFI.kt -test-bound: setup - just test-kotlin - test-kotlin: setup cd bound/kt && mvn clean verify -wasm: setup +bind-typescript: setup (cd bindings/tbdex_wasm; wasm-pack build --target nodejs --out-dir ../../bound/typescript/pkg) test-typescript: setup From 80d59a091e86e8fcdf801ff9fa3fde6707845b2f Mon Sep 17 00:00:00 2001 From: Neal Date: Mon, 21 Oct 2024 13:51:24 -0700 Subject: [PATCH 05/11] revert --- .github/workflows/ci.yml | 14 ++++---------- Justfile | 10 ++++------ 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d46d42..843112b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -419,22 +419,16 @@ jobs: path: test-results/rust-test-results.xml typescript: - runs-on: ubuntu-latest + runs-on: macos-latest steps: - uses: actions/checkout@v4 - name: Init Hermit uses: cashapp/activate-hermit@v1 with: cache: true - - name: Setup - run: just setup - - name: Bind Wasm - run: just bind-typescript - - name: Build WASM - run: | - cd bindings/tbdex_wasm - wasm-pack build --target nodejs --out-dir ../../bound/typescript/pkg - - name: Lint and Test + - name: Lint + # NOTE: only currently testing nodejs in the CI, not the browser + # The WASM binary is build with a script in npm run build run: | cd bound/typescript npm install diff --git a/Justfile b/Justfile index f4fef02..33123e5 100644 --- a/Justfile +++ b/Justfile @@ -31,11 +31,6 @@ lint: setup bind: setup just bind-kotlin - just bind-typescript - -test-bound: setup - just test-kotlin - just test-typescript bind-kotlin: setup cargo build --release --package tbdex_uniffi --target aarch64-apple-darwin @@ -50,10 +45,13 @@ bind-kotlin: setup sed -i '' 's/findLibraryName(componentName)/detectSystemTarget()/' target/bindgen-kotlin/tbdex/sdk/rust/tbdex.kt cp target/bindgen-kotlin/tbdex/sdk/rust/tbdex.kt bound/kt/src/main/kotlin/tbdex/sdk/rust/UniFFI.kt +test-bound: setup + just test-kotlin + test-kotlin: setup cd bound/kt && mvn clean verify -bind-typescript: setup +wasm: setup (cd bindings/tbdex_wasm; wasm-pack build --target nodejs --out-dir ../../bound/typescript/pkg) test-typescript: setup From c6d3e8a0d5cf7ab42bd86935d5425fee9f578b71 Mon Sep 17 00:00:00 2001 From: Neal Date: Mon, 21 Oct 2024 15:29:47 -0700 Subject: [PATCH 06/11] update --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 843112b..b0283ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -419,7 +419,7 @@ jobs: path: test-results/rust-test-results.xml typescript: - runs-on: macos-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Init Hermit From 22385d8787c59bceaa0c9f7311e3a005236587d2 Mon Sep 17 00:00:00 2001 From: Neal Date: Mon, 21 Oct 2024 16:01:53 -0700 Subject: [PATCH 07/11] updates --- .../{release.yml => release-kotlin.yml} | 0 .github/workflows/release-typescript.yml | 103 ++++++++++++++++++ bound/typescript/package.json | 9 +- 3 files changed, 111 insertions(+), 1 deletion(-) rename .github/workflows/{release.yml => release-kotlin.yml} (100%) create mode 100644 .github/workflows/release-typescript.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release-kotlin.yml similarity index 100% rename from .github/workflows/release.yml rename to .github/workflows/release-kotlin.yml diff --git a/.github/workflows/release-typescript.yml b/.github/workflows/release-typescript.yml new file mode 100644 index 0000000..a147231 --- /dev/null +++ b/.github/workflows/release-typescript.yml @@ -0,0 +1,103 @@ +name: Release TypeScript Package + +on: + workflow_dispatch: + inputs: + version: + description: 'Version of the TypeScript package to release and publish to npm. For example "1.0.0" or "1.3.7-beta-2". Required. Must not end in "-SNAPSHOT".' + required: true + +jobs: + # Job to set the version and create a git tag + set-version-and-tag: + runs-on: ubuntu-latest + outputs: + RELEASE_TAG: ${{ steps.set-version-and-tag.outputs.RELEASE_TAG }} + RELEASE_VERSION: ${{ steps.set-version-and-tag.outputs.RELEASE_VERSION }} + steps: + # Check out the repository with permissions to push + - uses: actions/checkout@v4 + with: + token: ${{ secrets.TBD_RELEASE_GITHUB_PERSONAL_ACCESS_TOKEN }} + + # Set Git configuration for committing + - name: Set Git Config + run: | + git config user.name "tbd-releases" + git config user.email "releases@tbd.email" + + # Update version, commit, and tag + - name: Set Version and Tag + id: set-version-and-tag + run: | + version="${{ github.event.inputs.version }}" + if [[ "$version" == *"-SNAPSHOT" ]]; then + echo "Error: The version for release must not end with \"-SNAPSHOT\": $version" + exit 1 + fi + cd bound/typescript + npm version "$version" --no-git-tag-version + git add package.json package-lock.json + git commit -m "[TBD Release Manager 🚀] Setting version to: $version" + tagName="ts-v$version" + git tag -a "$tagName" -m "Tag version: $tagName" + echo "RELEASE_TAG=$tagName" >> $GITHUB_OUTPUT + echo "RELEASE_VERSION=$version" >> $GITHUB_OUTPUT + git push origin "${GITHUB_REF#refs/heads/}" + git push origin "$tagName" + + # Job to build, test, and publish the package + build-and-publish: + name: Build and Publish TypeScript Package + needs: set-version-and-tag + runs-on: ubuntu-latest + steps: + # Check out the code at the release tag + - uses: actions/checkout@v4 + with: + ref: ${{ needs.set-version-and-tag.outputs.RELEASE_TAG }} + token: ${{ secrets.TBD_RELEASE_GITHUB_PERSONAL_ACCESS_TOKEN }} + + # Initialize Hermit environment + - name: Init Hermit + uses: cashapp/activate-hermit@v1 + with: + cache: true + + # Install dependencies + - name: Install Dependencies + run: | + cd bound/typescript + npm install + + # Build the package + - name: Build TypeScript Package + run: | + cd bound/typescript + npm run clean + npm run build + + # Run tests + - name: Run Tests + run: | + cd bound/typescript + npm run test:node:cjs + npm run test:node:esm + + # Publish to npm + - name: Publish to npm + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + cd bound/typescript + npm publish --access public + + # Create a GitHub release + - name: Create GitHub Release + uses: actions/create-release@v1.1.4 + with: + tag_name: ${{ needs.set-version-and-tag.outputs.RELEASE_TAG }} + release_name: ${{ needs.set-version-and-tag.outputs.RELEASE_TAG }} + body: "Release of TypeScript package version ${{ needs.set-version-and-tag.outputs.RELEASE_VERSION }}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/bound/typescript/package.json b/bound/typescript/package.json index 607c2b2..38f766e 100644 --- a/bound/typescript/package.json +++ b/bound/typescript/package.json @@ -1,5 +1,5 @@ { - "name": "tbdex", + "name": "@tbdex/sdk", "version": "0.1.0", "type": "module", "description": "", @@ -20,6 +20,13 @@ "require": "./dist/browser.js" } }, + "repository": { + "type": "git", + "url": "git+https://github.com/TBD54566975/tbdex-rs.git" + }, + "publishConfig": { + "access": "public" + }, "devDependencies": { "@types/chai": "4.3.0", "@types/mocha": "9.1.0", From f7191e2719ce0415562103a991e5128024ec70b0 Mon Sep 17 00:00:00 2001 From: Neal Date: Mon, 21 Oct 2024 16:21:38 -0700 Subject: [PATCH 08/11] works on linux --- bound/typescript/bundle-wasm/build.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bound/typescript/bundle-wasm/build.sh b/bound/typescript/bundle-wasm/build.sh index a716a3e..5ad09dc 100755 --- a/bound/typescript/bundle-wasm/build.sh +++ b/bound/typescript/bundle-wasm/build.sh @@ -24,8 +24,15 @@ echo "module.exports = \`$(base64 -i pkg/tbdex_wasm_bg.wasm)\`;" > pkg/tbdex_was # 1. Strip out the lines that load the WASM, add our new epilogue. # 2. Remove the imports of `TextDecoder` and `TextEncoder`. We rely on the global defaults. { - sed -e '/Text..coder.*= require(.util.)/d' \ - -e '/^const path = /,$d' pkg/tbdex_wasm.js + if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS version + sed -e '/Text..coder.*= require(.util.)/d' \ + -e '/^const path = /,$d' pkg/tbdex_wasm.js + else + # Linux (Ubuntu) version + sed -e '/Text..coder.*= require(.util.)/d' \ + -e '/^const path = /,$ d' pkg/tbdex_wasm.js + fi cat bundle-wasm/epilogue.js } > pkg/tbdex_wasm.js.new mv pkg/tbdex_wasm.js.new pkg/tbdex_wasm.js From b34ffbcab2e011d42a7367649e5495e4a7bc04ee Mon Sep 17 00:00:00 2001 From: Neal Date: Mon, 21 Oct 2024 16:22:55 -0700 Subject: [PATCH 09/11] update --- bound/typescript/bundle-wasm/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bound/typescript/bundle-wasm/build.sh b/bound/typescript/bundle-wasm/build.sh index 5ad09dc..d78c10f 100755 --- a/bound/typescript/bundle-wasm/build.sh +++ b/bound/typescript/bundle-wasm/build.sh @@ -18,7 +18,7 @@ set -e cd $(dirname "$0")/.. # Convert the Wasm into a JS file that exports the base64'ed Wasm. -echo "module.exports = \`$(base64 -i pkg/tbdex_wasm_bg.wasm)\`;" > pkg/tbdex_wasm_bg.wasm.js +echo "module.exports = \`$(base64 < pkg/tbdex_wasm_bg.wasm)\`;" > pkg/tbdex_wasm_bg.wasm.js # In the JavaScript: # 1. Strip out the lines that load the WASM, add our new epilogue. From 7d1d1aaed19ea82b358576c7d07e127c3c458aeb Mon Sep 17 00:00:00 2001 From: Neal Date: Mon, 21 Oct 2024 16:30:14 -0700 Subject: [PATCH 10/11] back to mac --- .github/workflows/ci.yml | 2 +- .github/workflows/release-typescript.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0283ce..843112b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -419,7 +419,7 @@ jobs: path: test-results/rust-test-results.xml typescript: - runs-on: ubuntu-latest + runs-on: macos-latest steps: - uses: actions/checkout@v4 - name: Init Hermit diff --git a/.github/workflows/release-typescript.yml b/.github/workflows/release-typescript.yml index a147231..0942e5e 100644 --- a/.github/workflows/release-typescript.yml +++ b/.github/workflows/release-typescript.yml @@ -50,7 +50,7 @@ jobs: build-and-publish: name: Build and Publish TypeScript Package needs: set-version-and-tag - runs-on: ubuntu-latest + runs-on: macos-latest steps: # Check out the code at the release tag - uses: actions/checkout@v4 From 78da8c050b67e3ac70f48236edb845f0653827c8 Mon Sep 17 00:00:00 2001 From: Neal Date: Mon, 21 Oct 2024 17:30:21 -0700 Subject: [PATCH 11/11] roll back build.sh --- bound/typescript/bundle-wasm/build.sh | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/bound/typescript/bundle-wasm/build.sh b/bound/typescript/bundle-wasm/build.sh index d78c10f..21bce5b 100755 --- a/bound/typescript/bundle-wasm/build.sh +++ b/bound/typescript/bundle-wasm/build.sh @@ -18,24 +18,17 @@ set -e cd $(dirname "$0")/.. # Convert the Wasm into a JS file that exports the base64'ed Wasm. -echo "module.exports = \`$(base64 < pkg/tbdex_wasm_bg.wasm)\`;" > pkg/tbdex_wasm_bg.wasm.js +echo "module.exports = \`$(base64 -i pkg/tbdex_wasm_bg.wasm)\`;" > pkg/tbdex_wasm_bg.wasm.js # In the JavaScript: # 1. Strip out the lines that load the WASM, add our new epilogue. # 2. Remove the imports of `TextDecoder` and `TextEncoder`. We rely on the global defaults. { - if [[ "$OSTYPE" == "darwin"* ]]; then - # macOS version - sed -e '/Text..coder.*= require(.util.)/d' \ - -e '/^const path = /,$d' pkg/tbdex_wasm.js - else - # Linux (Ubuntu) version - sed -e '/Text..coder.*= require(.util.)/d' \ - -e '/^const path = /,$ d' pkg/tbdex_wasm.js - fi + sed -e '/Text..coder.*= require(.util.)/d' \ + -e '/^const path = /,$d' pkg/tbdex_wasm.js cat bundle-wasm/epilogue.js } > pkg/tbdex_wasm.js.new mv pkg/tbdex_wasm.js.new pkg/tbdex_wasm.js # also extend the typescript -cat bundle-wasm/epilogue.d.ts >> pkg/tbdex_wasm.d.ts +cat bundle-wasm/epilogue.d.ts >> pkg/tbdex_wasm.d.ts \ No newline at end of file