From 3df05e2cb3f9fb6f3d54e68a90862e7fa07ae7ea Mon Sep 17 00:00:00 2001 From: Patrick Roza Date: Fri, 14 Aug 2026 08:28:51 +0200 Subject: [PATCH] ci: run Changesets version in parallel with snapshot publish The reusable CI workflow included Publish Snapshot, so the version job waited on pkg.pr.new. Snapshot now lives in its own reusable workflow: PRs still publish after build, and on main snapshot is a sibling of version after lint/build/test. --- .changeset/version-independent-snapshot.md | 5 ++ .github/workflows/ci.yml | 100 +++------------------ .github/workflows/publish-snapshot.yml | 100 +++++++++++++++++++++ .github/workflows/release.yaml | 12 +++ 4 files changed, 131 insertions(+), 86 deletions(-) create mode 100644 .changeset/version-independent-snapshot.md create mode 100644 .github/workflows/publish-snapshot.yml diff --git a/.changeset/version-independent-snapshot.md b/.changeset/version-independent-snapshot.md new file mode 100644 index 000000000..439a300d9 --- /dev/null +++ b/.changeset/version-independent-snapshot.md @@ -0,0 +1,5 @@ +--- + +--- + +Run Changesets version in parallel with pkg.pr.new snapshot publish on main. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00eeb9bd3..08ea1c32d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,11 @@ on: pull_request: branches: [main] workflow_call: + inputs: + publish_snapshot: + description: Run snapshot publish inside this reusable workflow + type: boolean + default: false workflow_dispatch: env: @@ -142,95 +147,18 @@ jobs: - name: Run tests run: pnpm test + # On main, Changesets calls this workflow and then runs `version` with + # `needs: [ci]`. Keep snapshot out of that reusable path so version does + # not wait for pkg.pr.new. Main snapshot runs as a sibling in release.yaml. snapshot: name: Publish Snapshot needs: [build] if: | - (github.event_name == 'push' && github.ref == 'refs/heads/main' && github.actor != 'github-actions[bot]' && !contains(github.event.head_commit.message, 'chore: update versions')) || + inputs.publish_snapshot || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'workflow_dispatch' - timeout-minutes: 20 - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: latest - - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - name: Setup pnpm cache - uses: actions/cache@v4 - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install --frozen-lockfile - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Download build artifacts - uses: actions/download-artifact@v4 - with: - name: build-output - path: packages/ - - - name: Publish snapshots to pkg.pr.new - id: publish - run: pnpm exec pkg-pr-new publish --pnpm ./packages/* - - - name: Write snapshot usage summary - id: usage - shell: bash - run: | - PACKAGE_LOCATORS="${{ steps.publish.outputs.packages }}" - PACKAGE_URLS="${{ steps.publish.outputs.urls }}" - PUBLISHED_SHA="${{ steps.publish.outputs.sha }}" - if [ -z "$PACKAGE_LOCATORS" ] || [ -z "$PACKAGE_URLS" ] || [ -z "$PUBLISHED_SHA" ]; then - echo "pkg-pr-new did not return expected outputs (packages/urls/sha)" >&2 - exit 1 - fi - - { - echo "## Snapshot publish complete" - echo - echo "- SHA: \`${PUBLISHED_SHA}\`" - echo - echo "Published via pkg.pr.new." - echo - echo "### Install package locators" - echo "\`\`\`bash" - echo "$PACKAGE_LOCATORS" - echo "\`\`\`" - echo - echo "### Package URLs" - echo "\`\`\`text" - echo "$PACKAGE_URLS" - echo "\`\`\`" - } >> "$GITHUB_STEP_SUMMARY" - - { - echo "package_locators<> "$GITHUB_OUTPUT" + uses: ./.github/workflows/publish-snapshot.yml + permissions: + contents: read + pull-requests: write + secrets: inherit diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml new file mode 100644 index 000000000..25cb9bdfb --- /dev/null +++ b/.github/workflows/publish-snapshot.yml @@ -0,0 +1,100 @@ +name: Publish Snapshot + +on: + workflow_call: + +permissions: + contents: read + pull-requests: write + +env: + CI: true + +jobs: + snapshot: + name: Publish Snapshot + timeout-minutes: 20 + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: latest + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install --frozen-lockfile + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-output + path: packages/ + + - name: Publish snapshots to pkg.pr.new + id: publish + run: pnpm exec pkg-pr-new publish --pnpm ./packages/* + + - name: Write snapshot usage summary + id: usage + shell: bash + run: | + PACKAGE_LOCATORS="${{ steps.publish.outputs.packages }}" + PACKAGE_URLS="${{ steps.publish.outputs.urls }}" + PUBLISHED_SHA="${{ steps.publish.outputs.sha }}" + if [ -z "$PACKAGE_LOCATORS" ] || [ -z "$PACKAGE_URLS" ] || [ -z "$PUBLISHED_SHA" ]; then + echo "pkg-pr-new did not return expected outputs (packages/urls/sha)" >&2 + exit 1 + fi + + { + echo "## Snapshot publish complete" + echo + echo "- SHA: \`${PUBLISHED_SHA}\`" + echo + echo "Published via pkg.pr.new." + echo + echo "### Install package locators" + echo "\`\`\`bash" + echo "$PACKAGE_LOCATORS" + echo "\`\`\`" + echo + echo "### Package URLs" + echo "\`\`\`text" + echo "$PACKAGE_URLS" + echo "\`\`\`" + } >> "$GITHUB_STEP_SUMMARY" + + { + echo "package_locators<> "$GITHUB_OUTPUT" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ebf056acc..6985df6b1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -18,6 +18,18 @@ jobs: ci: uses: ./.github/workflows/ci.yml + snapshot: + name: Publish Snapshot + needs: [ci] + if: | + github.actor != 'github-actions[bot]' && + !contains(github.event.head_commit.message, 'chore: update versions') + uses: ./.github/workflows/publish-snapshot.yml + permissions: + contents: read + pull-requests: write + secrets: inherit + version: needs: [ci] timeout-minutes: 15