name: Publish on: push: branches: - main workflow_dispatch: permissions: {} jobs: version: if: github.event_name == 'push' runs-on: ubuntu-latest permissions: contents: write pull-requests: write steps: - uses: actions/checkout@v7 - uses: pnpm/action-setup@v6 - uses: actions/setup-node@v7 with: # Trusted publishing needs npm CLI >= 11.5.1; Node 24 ships with npm 11. node-version: 24 registry-url: https://registry.npmjs.org # Keep the release build independent of mutable dependency caches. package-manager-cache: false - name: Install dependencies run: pnpm install --frozen-lockfile - name: Create or update release PR id: changesets uses: changesets/action@v2 with: version-script: pnpm run version pr-title: 'ci: release packages' commit-message: 'ci: release packages' # The release PR is opened with the workflow token, so pull_request checks never run on it. # Report the combined effect of every pending change against the latest npm release here. - name: Set up Bun for bundle measurement if: steps.changesets.outputs['pr-number'] uses: oven-sh/setup-bun@v2 - name: Compare with the latest release id: release-report if: steps.changesets.outputs['pr-number'] continue-on-error: true working-directory: packages/sugar-high run: | node scripts/benchmark.mjs --markdown --perf --base npm:sugar-high@latest > release-report.md cat release-report.md >> "$GITHUB_STEP_SUMMARY" - name: Comment on release PR if: steps.release-report.outcome == 'success' continue-on-error: true uses: actions/github-script@v8 env: PULL_REQUEST: ${{ steps.changesets.outputs['pr-number'] }} with: script: | const fs = require('fs') const body = fs.readFileSync('packages/sugar-high/release-report.md', 'utf8') const { owner, repo } = context.repo const issue_number = Number(process.env.PULL_REQUEST) const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number, }) const previous = comments.find(comment => comment.user?.type === 'Bot' && comment.body?.includes('') ) if (previous) { await github.rest.issues.updateComment({ owner, repo, comment_id: previous.id, body }) } else { await github.rest.issues.createComment({ owner, repo, issue_number, body }) } publish: if: github.event_name == 'workflow_dispatch' concurrency: group: npm-publish cancel-in-progress: false runs-on: ubuntu-latest permissions: contents: write id-token: write env: NPM_CONFIG_PROVENANCE: "true" steps: - uses: actions/checkout@v7 - uses: pnpm/action-setup@v6 - uses: actions/setup-node@v7 with: node-version: 24 registry-url: https://registry.npmjs.org package-manager-cache: false - name: Install dependencies run: pnpm install --frozen-lockfile - name: Publish packages and create GitHub releases uses: changesets/action@v2 with: publish-script: pnpm release create-github-releases: true