Merge pull request #623 from preactjs/jovi/npm-staged-publishing #426
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: Release | |
| runs-on: ubuntu-latest | |
| outputs: | |
| has_changesets: ${{ steps.changesets.outputs.hasChangesets }} | |
| has_unpublished_packages: ${{ steps.unpublished.outputs.has_unpublished }} | |
| permissions: | |
| contents: write | |
| issues: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | |
| with: | |
| package-manager-cache: false | |
| node-version: 22 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Update npm | |
| run: npm install -g npm@11.15.0 | |
| - name: Check for unpublished package versions | |
| id: unpublished | |
| run: node .github/scripts/has-unpublished-packages.mjs | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3 | |
| with: | |
| version: 11.0.0 | |
| run_install: false | |
| - name: Install Dependencies | |
| run: pnpm install --frozen-lockfile false | |
| - name: Create Release Pull Request | |
| id: changesets | |
| uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3 | |
| with: | |
| version: pnpm run version | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish: | |
| name: Publish | |
| needs: release | |
| if: needs.release.outputs.has_changesets == 'false' && needs.release.outputs.has_unpublished_packages == 'true' | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: npm | |
| url: https://www.npmjs.com/search?q=%40prefresh | |
| permissions: | |
| contents: write | |
| id-token: write | |
| issues: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | |
| with: | |
| package-manager-cache: false | |
| node-version: 22 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Update npm | |
| run: npm install -g npm@11.15.0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3 | |
| with: | |
| version: 11.0.0 | |
| run_install: false | |
| - name: Install Dependencies | |
| run: pnpm install --frozen-lockfile false | |
| - name: Publish packages | |
| uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3 | |
| with: | |
| publish: node .github/scripts/stage-packages.mjs | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |