Workflow file for this run
This file contains hidden or 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: Release (npm with provenance) | |
| on: | |
| push: | |
| tags: | |
| - "[0-9]+.[0-9]+.[0-9]+" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org | |
| - name: Enable corepack (Yarn) | |
| run: corepack enable | |
| - name: Install dependencies | |
| run: yarn install --immutable | |
| - name: Unit tests (skip cross-repo data tests) | |
| run: yarn test:unit | |
| env: | |
| PUID_SKIP_DATA_TESTS: "1" | |
| - name: Check if version already published | |
| id: check_published | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "Version: $VERSION" | |
| EXISTS=$(npm view puid-js versions --json | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>{const v=JSON.parse(s); console.log(v.includes(process.env.VERSION)?'yes':'no')})") | |
| if [ "$EXISTS" = "yes" ]; then | |
| echo "Version $VERSION already on npm; skipping publish" | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| VERSION: ${{ steps.meta.outputs.version }} | |
| - name: Publish to npm (with provenance) | |
| if: steps.check_published.outputs.skip != 'true' | |
| run: npm publish --provenance --tag latest --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |