diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..97b6b09 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,41 @@ +name: Publish + +on: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + environment: npm-publish + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + # DO NOT use registry-url — it interferes with OIDC + + - name: Upgrade npm (OIDC requires >= 11.5.1) + run: npm install -g npm@latest + + - name: Configure npm registry + run: npm config set registry https://registry.npmjs.org/ + + - run: pnpm install --frozen-lockfile + + - run: pnpm run build + + - run: pnpm test + + - name: Set version from release tag + run: npm version "${GITHUB_REF_NAME#v}" --no-git-tag-version + + - name: Publish to npm via OIDC + run: npm publish --access public --provenance