Refactor release workflow for improved readability #61
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 | |
| permissions: {} | |
| jobs: | |
| release: | |
| name: ${{ matrix.channel }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| strategy: | |
| max-parallel: 1 | |
| matrix: | |
| channel: [latest, dev] | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22.17 | |
| cache: yarn | |
| # IMPORTANT: do NOT set registry-url here (avoid auth/.npmrc side effects) | |
| - name: Enable Corepack (Yarn) | |
| run: corepack enable | |
| - name: Upgrade npm (OIDC fixes ship in npm releases) | |
| run: npm i -g npm@latest | |
| - name: Configure npm registry (no token) | |
| run: | | |
| cat > ~/.npmrc <<'EOF' | |
| registry=https://registry.npmjs.org/ | |
| EOF | |
| - name: Debug npm auth config | |
| run: | | |
| npm -v | |
| echo "=== user npmrc ===" | |
| cat ~/.npmrc || true | |
| echo "=== any auth/token config? ===" | |
| npm config list -l | grep -iE 'auth|token|always-auth' || true | |
| - name: Install dependencies | |
| run: yarn install | |
| - name: Prepare release | |
| run: yarn prerelease | |
| - name: Create or update release PR | |
| if: matrix.channel == 'latest' | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| version: yarn changesetversion | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish to npm (OIDC) | |
| if: matrix.channel == 'latest' && steps.changesets.outputs.hasChangesets == 'false' | |
| run: yarn changeset publish | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Release to @dev channel | |
| if: matrix.channel == 'dev' | |
| run: | | |
| yarn changeset version --snapshot | |
| yarn changeset publish --tag dev | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |