From bc45a6563d8a388e789a75f3877f90e90042d370 Mon Sep 17 00:00:00 2001 From: nitro-neal <5314059+nitro-neal@users.noreply.github.com> Date: Tue, 22 Oct 2024 09:54:24 -0500 Subject: [PATCH] update ts actions (#143) * update ts actions * update * update * update justfile * revert * update * updates * works on linux * update * back to mac * roll back build.sh --- .github/workflows/ci.yml | 3 +- .../{release.yml => release-kotlin.yml} | 0 .github/workflows/release-typescript.yml | 103 ++++++++++++++++++ bound/typescript/bundle-wasm/build.sh | 2 +- bound/typescript/package.json | 9 +- 5 files changed, 114 insertions(+), 3 deletions(-) rename .github/workflows/{release.yml => release-kotlin.yml} (100%) create mode 100644 .github/workflows/release-typescript.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db942a1d..843112b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -428,10 +428,11 @@ jobs: cache: true - 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 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 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 00000000..0942e5e7 --- /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: macos-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/bundle-wasm/build.sh b/bound/typescript/bundle-wasm/build.sh index a716a3e3..21bce5b7 100755 --- a/bound/typescript/bundle-wasm/build.sh +++ b/bound/typescript/bundle-wasm/build.sh @@ -31,4 +31,4 @@ echo "module.exports = \`$(base64 -i pkg/tbdex_wasm_bg.wasm)\`;" > pkg/tbdex_was 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 diff --git a/bound/typescript/package.json b/bound/typescript/package.json index 607c2b28..38f766e4 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",