fix(release): retry npm visibility check #9
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 | |
| release: | |
| types: | |
| - published | |
| workflow_dispatch: | |
| inputs: | |
| job: | |
| description: "Release job to run" | |
| required: true | |
| type: choice | |
| options: | |
| - verify | |
| - publish | |
| permissions: | |
| contents: read | |
| jobs: | |
| verify: | |
| name: verify | |
| if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.job == 'verify') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Setup Node | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 | |
| with: | |
| node-version: 24 | |
| package-manager-cache: false | |
| - name: Enable pnpm | |
| run: | | |
| corepack enable | |
| corepack prepare pnpm@10.20.0 --activate | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run release check | |
| run: pnpm run release:check | |
| env: | |
| CI: true | |
| publish: | |
| name: publish | |
| if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.job == 'publish') | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: npm-publish | |
| url: https://www.npmjs.com/package/@async/dispatch | |
| permissions: | |
| contents: read | |
| id-token: write | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN || secrets.npm_token }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Setup Node | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 | |
| with: | |
| node-version: 24 | |
| package-manager-cache: false | |
| - name: Use current npm | |
| run: npm install -g npm@11.16.0 | |
| - name: Enable pnpm | |
| run: | | |
| corepack enable | |
| corepack prepare pnpm@10.20.0 --activate | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run release check | |
| run: pnpm run release:check | |
| env: | |
| CI: true | |
| - name: Configure npm token | |
| if: env.NODE_AUTH_TOKEN != '' | |
| run: npm config set //registry.npmjs.org/:_authToken "$NODE_AUTH_TOKEN" | |
| - name: Publish to npm | |
| run: npm publish --access public --provenance --registry=https://registry.npmjs.org | |
| - name: Ensure public npm access | |
| run: npm access set status=public @async/dispatch --registry=https://registry.npmjs.org | |
| - name: Verify npm visibility | |
| run: | | |
| version="$(node -p "JSON.parse(require('node:fs').readFileSync('package.json', 'utf8')).version")" | |
| for attempt in 1 2 3 4 5 6; do | |
| if npm view "@async/dispatch@$version" version bin dist.tarball --json --registry=https://registry.npmjs.org; then | |
| exit 0 | |
| fi | |
| echo "npm visibility check failed for @async/dispatch@$version on attempt $attempt; waiting for propagation" | |
| sleep 10 | |
| done | |
| exit 1 |