npm publish from PR #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: npm publish from PR | |
on: | |
workflow_dispatch: | |
inputs: | |
# source: | |
# description: 'source ref: `google/zx/main/0cba...f9`' | |
repo: | |
description: 'source gh repo, like `google/zx`' | |
# branch: | |
# description: 'target branch' | |
commit: | |
description: 'commit id' | |
# cmd: | |
# description: 'build cmd' | |
# default: 'npm ci && npm run build' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Use Node.js 23 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 23 | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.event.inputs.repo }} | |
ref: ${{ github.event.inputs.commit }} | |
- name: Build | |
run: | | |
npm ci | |
npm run build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: build-pr-${{ github.run_id }} | |
path: | | |
target | |
package.json | |
README.md | |
buildstamp.json | |
retention-days: 1 | |
publish: | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
checks: read | |
statuses: write | |
contents: write | |
packages: write | |
id-token: write | |
steps: | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: build-pr-${{ github.run_id }} | |
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- run: | | |
npm version $(node --eval="process.stdout.write(require('./package.json').version)")-pr.${{ github.run_id }} --no-git-tag-version | |
npm publish --provenance --access=public --no-git-tag-version --tag pr |