Release #72
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: | |
| workflow_run: | |
| workflows: ["CI"] | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| - "*-[0-9]+.x" # Package maintenance branches (e.g., swarm-wasp-1.x, swarm-2.x) | |
| permissions: | |
| contents: write | |
| pull-requests: | |
| write | |
| # Needed for workflow_run | |
| packages: write | |
| actions: write | |
| id-token: write | |
| jobs: | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.workflow_run.conclusion == 'success' && (github.event.workflow_run.head_branch == 'main' || endsWith(github.event.workflow_run.head_branch, '-[0-9]+.x')) }} | |
| env: | |
| RELEASE_COMMIT_MESSAGE: "chore: version packages" | |
| RELEASE_PR_TITLE: "Release Packages" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.PAT_TOKEN }} | |
| # Checkout the branch to get the latest commit which includes | |
| # any changesets that were committed during the CI workflow | |
| ref: ${{ github.event.workflow_run.head_branch }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build packages | |
| run: pnpm run build | |
| - name: Set Git user name and email | |
| run: | | |
| git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git config --global user.name "github-actions[bot]" | |
| - name: Fetch latest commits | |
| run: | | |
| BRANCH="${{ github.event.workflow_run.head_branch }}" | |
| git fetch origin "$BRANCH" | |
| git checkout "$BRANCH" | |
| echo "Latest commit: $(git log -1 --oneline)" | |
| - name: Determine release tag | |
| id: release-tag | |
| run: | | |
| BRANCH="${{ github.event.workflow_run.head_branch }}" | |
| if [[ "$BRANCH" =~ ^(.+)-([0-9]+)\.x$ ]]; then | |
| # Maintenance branch: <package>-N.x | |
| MAJOR="${BASH_REMATCH[2]}" | |
| echo "tag=v${MAJOR}" >> $GITHUB_OUTPUT | |
| echo "is_maintenance=true" >> $GITHUB_OUTPUT | |
| echo "pr_suffix= [${BRANCH}]" >> $GITHUB_OUTPUT | |
| echo "Publishing to 'v${MAJOR}' tag (maintenance branch: ${BRANCH})" | |
| else | |
| # Main branch or other | |
| echo "tag=" >> $GITHUB_OUTPUT | |
| echo "is_maintenance=false" >> $GITHUB_OUTPUT | |
| echo "pr_suffix=" >> $GITHUB_OUTPUT | |
| echo "Publishing to 'latest' tag" | |
| fi | |
| - name: Create Release PR or Publish to NPM | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| commit: "${{ env.RELEASE_COMMIT_MESSAGE }}${{ steps.release-tag.outputs.pr_suffix }}" | |
| title: "${{ env.RELEASE_PR_TITLE }}${{ steps.release-tag.outputs.pr_suffix }}" | |
| version: pnpm changeset:version | |
| publish: pnpm release ${{ steps.release-tag.outputs.tag != '' && format('--tag {0}', steps.release-tag.outputs.tag) || '' }} | |
| createGithubReleases: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
| NODE_AUTH_TOKEN: "" | |
| - name: Format Release PR | |
| if: ${{ steps.changesets.outputs.pullRequestNumber != '' }} | |
| env: | |
| PR_NUMBER: ${{ steps.changesets.outputs.pullRequestNumber }} | |
| GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| run: node .github/scripts/format-release-pr.js | |
| - name: Update Subrepo Dependencies | |
| if: steps.changesets.outputs.published == 'true' && steps.release-tag.outputs.is_maintenance == 'false' | |
| run: node .github/scripts/update-subrepo-deps.js | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
| PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.publishedPackages }} |