From c17eb431cb81321189f0a4130af7a227a19d7fce Mon Sep 17 00:00:00 2001 From: MatiasManevi Date: Tue, 24 Feb 2026 16:58:32 -0300 Subject: [PATCH] Move publish step to sh file --- .github/workflows/build_steps.sh | 19 ++++++++++++++++ .github/workflows/publish-wasm.yml | 36 +++--------------------------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build_steps.sh b/.github/workflows/build_steps.sh index 6a6889bc..fc290633 100755 --- a/.github/workflows/build_steps.sh +++ b/.github/workflows/build_steps.sh @@ -230,6 +230,25 @@ build_test_wasm() { npm run test --prefix ./wasm } +package_wasm() { + mkdir -p wasm/dist + cp wasm/package.npm.json wasm/dist/package.json + cp wasm/README.md wasm/dist/README.md || true + + VERSION=${GITHUB_REF#refs/tags/} + npm --prefix wasm/dist version "${VERSION}" --no-git-tag-version + + if [ -z "${NPM_TOKEN}" ]; then + echo "NPM_TOKEN is not set or is invalid; aborting publish" + exit 1 + fi + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc + + npm pack --dry-run ./wasm/dist + + npm publish ./wasm/dist --access public +} + package_mjx() { echo "Packaging MJX..." diff --git a/.github/workflows/publish-wasm.yml b/.github/workflows/publish-wasm.yml index 0e481ead..d4eeadf9 100644 --- a/.github/workflows/publish-wasm.yml +++ b/.github/workflows/publish-wasm.yml @@ -28,38 +28,8 @@ jobs: - name: Build WASM bindings run: bash ./.github/workflows/build_steps.sh build_test_wasm - - - name: Prepare clean package manifest in dist - run: | - if [ -f wasm/package.npm.json ]; then - mkdir -p wasm/dist - cp wasm/package.npm.json wasm/dist/package.json - echo "Copied wasm/package.npm.json -> wasm/dist/package.json" - else - echo "No wasm/package.npm.json found; aborting" - exit 1 - fi - - - name: Prepare README for dist - run: | - mkdir -p wasm/dist - cp wasm/README.md wasm/dist/README.md - - - - name: Sync version with tag (dist) - run: | - VERSION=${GITHUB_REF#refs/tags/} - echo "Setting package version to: ${VERSION}" - npm --prefix wasm/dist version "${VERSION}" --no-git-tag-version - - - name: Configure npm auth + - name: Package WASM bindings env: NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} - run: | - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc - - - name: Preview package (dist) - run: npm pack --dry-run ./wasm/dist - - - name: Publish package (dist) - run: npm publish ./wasm/dist --access public + GITHUB_REF: ${{ github.ref }} + run: bash ./.github/workflows/build_steps.sh package_wasm