diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index 5fa7178..715c06c 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -42,18 +42,22 @@ jobs: - name: Copy LICENSE into package run: cp LICENSE.md wasm-edge/pkg/LICENSE.md - - name: Set package name - # wasm-pack derives the npm name from the crate name, ignoring any custom package.json. - # Patch the generated pkg/package.json to use the correct published name. + - name: Set package name and version + # wasm-pack derives the npm name and version from the crate — patch both so the + # published package always matches the git tag (e.g. refs/tags/v0.1.5 → 0.1.5). run: | + TAG_VERSION="${GITHUB_REF_NAME#v}" node -e " const fs = require('fs'); const path = 'wasm-edge/pkg/package.json'; const pkg = JSON.parse(fs.readFileSync(path, 'utf8')); pkg.name = 'recached-edge'; + pkg.version = process.env.TAG_VERSION; fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + '\n'); - console.log('Package name set to:', pkg.name); + console.log('Package:', pkg.name, pkg.version); " + env: + TAG_VERSION: ${{ github.ref_name }} - name: Publish to NPM env: