feature/fix-ci-sdk-pypi-rubygem
claude/smbcloud-github-app-k9641p
development
feature/apps
feature/build-release
feature/ci-docs
feature/ci-ruby-gems
feature/cicd
feature/completion
feature/dist-nuget
feature/fix-ci-sdk-pypi-rubygem
feature/fix-clippy-on-stable-channel
feature/fix-deployment-script
feature/github-email
feature/gresiq-v1
feature/project-new-structure
feature/rsync-deploy
feature/ruby-runner
feature/sdk-npm
feature/sdk-workflows
feature/smbcloud-cli-release-npm
feature/smbcloud-deploy
feature/wasm
main
release/v0.7.4
| 1 | name: SDK npm Release |
| 2 | |
| 3 | # Publishes @smbcloud/sdk-auth (WASM) to npm. |
| 4 | # WASM is a single universal target — no platform matrix needed. |
| 5 | # |
| 6 | # Required secrets: |
| 7 | # NPM_TOKEN — npm access token with publish rights to @smbcloud/sdk-auth |
| 8 | |
| 9 | on: |
| 10 | workflow_dispatch: |
| 11 | inputs: |
| 12 | tag: |
| 13 | description: "Release tag (e.g. v0.3.35)" |
| 14 | required: true |
| 15 | |
| 16 | permissions: |
| 17 | contents: read |
| 18 | |
| 19 | env: |
| 20 | CARGO_TERM_COLOR: always |
| 21 | CLI_CLIENT_SECRET: ${{ secrets.CLI_CLIENT_SECRET }} |
| 22 | |
| 23 | jobs: |
| 24 | publish-sdk-npm: |
| 25 | name: Publish @smbcloud/sdk-auth to npm |
| 26 | runs-on: ubuntu-latest |
| 27 | |
| 28 | steps: |
| 29 | - name: Checkout |
| 30 | uses: actions/checkout@v6 |
| 31 | with: |
| 32 | ref: ${{ github.event.inputs.tag || github.ref }} |
| 33 | |
| 34 | - name: Set the release version |
| 35 | shell: bash |
| 36 | run: | |
| 37 | if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then |
| 38 | release_version="${GITHUB_REF_NAME#v}" |
| 39 | else |
| 40 | release_version="${{ github.event.inputs.tag }}" |
| 41 | release_version="${release_version#v}" |
| 42 | fi |
| 43 | |
| 44 | echo "RELEASE_VERSION=${release_version}" >> "$GITHUB_ENV" |
| 45 | |
| 46 | - name: Read Rust toolchain |
| 47 | shell: bash |
| 48 | run: | |
| 49 | rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)" |
| 50 | if [ -z "$rust_toolchain" ]; then |
| 51 | echo "Failed to read Rust toolchain from rust-toolchain.toml" >&2 |
| 52 | exit 1 |
| 53 | fi |
| 54 | |
| 55 | echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV" |
| 56 | |
| 57 | - name: Install toolkit with wasm32 target |
| 58 | uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 |
| 59 | with: |
| 60 | toolchain: ${{ env.RUST_TOOLCHAIN }} |
| 61 | targets: wasm32-unknown-unknown |
| 62 | |
| 63 | - name: Setup Rust cache |
| 64 | uses: Swatinem/rust-cache@v2 |
| 65 | with: |
| 66 | key: sdk-npm |
| 67 | |
| 68 | - name: Verify Cargo.toml version matches tag |
| 69 | shell: bash |
| 70 | run: | |
| 71 | CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 \ |
| 72 | | jq -r '.packages[] | select(.name == "smbcloud-auth-sdk-wasm") | .version') |
| 73 | |
| 74 | echo "Cargo.toml version : ${CARGO_VERSION}" |
| 75 | echo "Release tag version: ${RELEASE_VERSION}" |
| 76 | |
| 77 | if [[ "${CARGO_VERSION}" != "${RELEASE_VERSION}" ]]; then |
| 78 | echo "::error::Version mismatch — bump version in crates/smbcloud-auth-sdk-wasm/Cargo.toml before releasing." |
| 79 | exit 1 |
| 80 | fi |
| 81 | |
| 82 | # wasm-pack drives the wasm32 compilation and wasm-bindgen code generation. |
| 83 | # prepare-package.mjs calls wasm-pack internally and also enforces that |
| 84 | # sdk/npm/smbcloud-auth/package.json version matches the Cargo.toml version. |
| 85 | - name: Install wasm-pack |
| 86 | run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh |
| 87 | |
| 88 | - name: Install Node.js |
| 89 | uses: actions/setup-node@v6 |
| 90 | with: |
| 91 | node-version-file: .nvmrc |
| 92 | registry-url: "https://registry.npmjs.org" |
| 93 | |
| 94 | - name: Check whether release already exists on npm |
| 95 | id: npm-check |
| 96 | shell: bash |
| 97 | run: | |
| 98 | if npm view "@smbcloud/sdk-auth@${RELEASE_VERSION}" version >/dev/null 2>&1; then |
| 99 | echo "@smbcloud/sdk-auth@${RELEASE_VERSION} already exists on npm, skipping publish" |
| 100 | echo "exists=true" >> "$GITHUB_OUTPUT" |
| 101 | else |
| 102 | echo "exists=false" >> "$GITHUB_OUTPUT" |
| 103 | fi |
| 104 | |
| 105 | - name: Build and prepare package |
| 106 | if: steps.npm-check.outputs.exists != 'true' |
| 107 | working-directory: sdk/npm/smbcloud-auth |
| 108 | run: node ./prepare-package.mjs |
| 109 | |
| 110 | - name: Publish to npm |
| 111 | if: steps.npm-check.outputs.exists != 'true' |
| 112 | working-directory: sdk/npm/smbcloud-auth |
| 113 | env: |
| 114 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 115 | run: npm publish --access public |