fix: fail fast without npm trusted publishing #64
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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| release: | |
| name: Test & Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22.14.0 | |
| - name: Use npm trusted-publishing capable CLI | |
| run: npm install -g npm@11 | |
| - name: Install dev dependencies | |
| run: npm ci | |
| - name: Run tests | |
| run: npm run test:gsdd | |
| - name: Audit packed tarball surface | |
| run: npm pack --dry-run --json | |
| - name: Verify npm trusted publisher | |
| run: | | |
| OIDC_TOKEN=$(curl -fsSL \ | |
| -H "Authorization: Bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \ | |
| "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=npm:registry.npmjs.org" \ | |
| | jq -r '.value') | |
| STATUS=$(curl -sS \ | |
| -o /tmp/npm-oidc.json \ | |
| -w "%{http_code}" \ | |
| -X POST "https://registry.npmjs.org/-/npm/v1/oidc/token/exchange/package/gsdd-cli" \ | |
| -H "Authorization: Bearer ${OIDC_TOKEN}") | |
| if [ "${STATUS}" != "200" ]; then | |
| cat /tmp/npm-oidc.json | |
| echo "::error::npm trusted publishing is not configured for gsdd-cli. Configure npm package trusted publisher for PatrickSys/workspine using .github/workflows/release.yml before running semantic-release." | |
| exit 1 | |
| fi | |
| - name: Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_CONFIG_PROVENANCE: "true" | |
| run: npx semantic-release |