ci: set pnpm publish branch #29
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: 🦋 Changesets Release | |
| on: | |
| push: | |
| branches: | |
| - release | |
| - "release-*" | |
| - "!release-experimental" | |
| - "!release-experimental-*" | |
| - "!release-manual" | |
| - "!release-manual-*" | |
| permissions: | |
| id-token: write # to use OpenID Connect token for trusted publishing (changesets/action) | |
| pull-requests: write # to create pull request (changesets/action) | |
| contents: write # to create release (changesets/action) | |
| issues: write # to post issue comments (changesets/action) | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| release: | |
| name: 🦋 Changesets Release | |
| if: github.repository == 'mcansh/packages' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| published: ${{ steps.changesets.outputs.published }} | |
| steps: | |
| - name: ⬇️ Checkout repo | |
| uses: actions/checkout@v5 | |
| - name: 🟧 Get pnpm version | |
| id: pnpm-version | |
| shell: bash | |
| run: | | |
| # get pnpm version from package.json packageManager field | |
| VERSION=$(node -e "console.log(require('./package.json').packageManager.replace(/pnpm@/, ''))") | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| - name: ⎔ Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: ".node-version" | |
| - name: 🟧 Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: ${{ steps.pnpm-version.outputs.VERSION }} | |
| run_install: | | |
| - recursive: true | |
| args: [--frozen-lockfile, --strict-peer-dependencies] | |
| cwd: ./ | |
| - name: 🟧 Set publish-branch to current branch | |
| run: | | |
| echo "publish-branch=$(git branch --show-current)" >> ~/.npmrc | |
| # This action has two responsibilities. The first time the workflow runs | |
| # (initial push to a `release-*` branch) it will create a new branch and | |
| # then open a PR with the related changes for the new version. After the | |
| # PR is merged, the workflow will run again and this action will build + | |
| # publish to npm & github packages. | |
| - name: 🚀 PR / Publish | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| version: pnpm run changeset:version | |
| commit: "chore: Update version for release" | |
| title: "chore: Update version for release" | |
| publish: pnpm run changeset:release | |
| createGithubReleases: true | |
| comment: | |
| name: 📝 Comment on issues and pull requests | |
| if: github.repository == 'mcansh/http-helmet' && needs.release.outputs.published == 'true' | |
| needs: [release] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: ⬇️ Checkout repo | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: 📝 Comment on issues | |
| uses: remix-run/release-comment-action@v0.4.2 | |
| with: | |
| DIRECTORY_TO_CHECK: "./packages" | |
| PACKAGE_NAME: "@mcansh/http-helmet" |