Release Please #105
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 Please | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - next | |
| workflow_dispatch: | |
| env: | |
| NODE_VERSION: lts/jod | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| release-please: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1️⃣ Checkout the repo | |
| - uses: actions/checkout@v4 | |
| # 2️⃣ Setup pnpm | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10.8.0 | |
| # 3️⃣ Setup Node | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/jod | |
| cache: "pnpm" | |
| # 4️⃣ Install dependencies | |
| - run: pnpm install --frozen-lockfile | |
| # 5️⃣ Build all packages (using turbo) | |
| - run: pnpm turbo run build --filter=./packages/** | |
| # 6️⃣ Run release-please | |
| - uses: googleapis/release-please-action@v4 | |
| id: release | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| target-branch: ${{ github.ref_name }} | |
| config-file: .release-please-config.json | |
| manifest-file: .release-please-manifest.json | |
| prerelease: ${{ github.ref_name == 'next' }} | |
| # 7️⃣ Determine npm tag based on version and branch | |
| - name: Determine npm tag | |
| id: npm_tag | |
| if: steps.release.outputs.releases_created == 'true' | |
| run: | | |
| # Get the first package version from release outputs | |
| VERSION=$(echo '$RELEASE_OUTPUTS' | jq -r '.[] | select(type == "string" and test("^[0-9]")) | select(. != null)' | head -n1) | |
| # On 'next' branch, always use 'next' tag | |
| if [[ "${{ github.ref_name }}" == "next" ]]; then | |
| echo "tag=next" >> $GITHUB_OUTPUT | |
| echo "Publishing from next branch with tag: next" | |
| # On 'main' branch, check if version is prerelease | |
| elif [[ "$VERSION" =~ -rc\.|-.+\. ]] || [[ "$VERSION" =~ -rc$|-(alpha|beta|next|canary) ]]; then | |
| echo "tag=next" >> $GITHUB_OUTPUT | |
| echo "Publishing as prerelease with tag: next" | |
| else | |
| echo "tag=latest" >> $GITHUB_OUTPUT | |
| echo "Publishing as stable release with tag: latest" | |
| fi | |
| env: | |
| RELEASE_OUTPUTS: ${{ toJSON(steps.release.outputs) }} | |
| # 8️⃣ Setup npm auth | |
| - name: Setup npm auth | |
| if: steps.release.outputs.releases_created == 'true' | |
| run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| # 9️⃣ Publish changed packages | |
| - name: Publish changed packages | |
| if: steps.release.outputs.releases_created == 'true' | |
| run: pnpm publish -r --filter="./packages/**" --tag $TAG --no-git-checks | |
| env: | |
| TAG: ${{ steps.npm_tag.outputs.tag }} |