Skip to content

Commit bbdef9c

Browse files
scolladonclaude
andcommitted
refactor: make publish wait generic for dev and release
- Add status_context input to e2e workflow for flexibility - Add commit status reporting to publish-release job - Update on-main-push.yml to pass SHA and wait for npm-publish-release - Both dev and release e2e tests now wait for their respective publish Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ae39341 commit bbdef9c

4 files changed

Lines changed: 50 additions & 6 deletions

File tree

.github/workflows/npm-publisher.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ jobs:
4242
if: github.event_name == 'repository_dispatch' && github.event.action == 'npm-publish-release'
4343
runs-on: ubuntu-latest
4444
steps:
45+
- name: Set pending commit status
46+
if: ${{ github.event.client_payload.ref != '' }}
47+
env:
48+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
SHA: ${{ github.event.client_payload.ref }}
50+
run: |
51+
gh api repos/${{ github.repository }}/statuses/$SHA \
52+
-f state=pending \
53+
-f context=npm-publish-release \
54+
-f description="Publishing release to npm..." \
55+
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
56+
4557
- name: Checkout sources
4658
uses: actions/checkout@v6
4759

@@ -62,6 +74,30 @@ jobs:
6274
NPM_TAG: ${{ github.event.client_payload.tag || 'latest-rc' }}
6375
run: npm publish --provenance --access public --tag "$NPM_TAG"
6476

77+
- name: Set success commit status
78+
if: ${{ success() && github.event.client_payload.ref != '' }}
79+
env:
80+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
SHA: ${{ github.event.client_payload.ref }}
82+
run: |
83+
gh api repos/${{ github.repository }}/statuses/$SHA \
84+
-f state=success \
85+
-f context=npm-publish-release \
86+
-f description="Release published to npm" \
87+
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
88+
89+
- name: Set failure commit status
90+
if: ${{ failure() && github.event.client_payload.ref != '' }}
91+
env:
92+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93+
SHA: ${{ github.event.client_payload.ref }}
94+
run: |
95+
gh api repos/${{ github.repository }}/statuses/$SHA \
96+
-f state=failure \
97+
-f context=npm-publish-release \
98+
-f description="Failed to publish release" \
99+
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
100+
65101
publish-dev:
66102
if: github.event_name == 'repository_dispatch' && github.event.action == 'npm-publish-dev'
67103
runs-on: ubuntu-latest

.github/workflows/on-main-push.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ jobs:
4141
with:
4242
token: ${{ secrets.RELEASE_PAT }}
4343
event-type: npm-publish-release
44-
client-payload: '{"tag": "latest-rc"}'
44+
client-payload: '{"tag": "latest-rc", "ref": "${{ github.sha }}"}'
4545

4646
test-release:
4747
uses: ./.github/workflows/run-e2e-tests.yml
4848
needs: [prepare-release, release]
4949
with:
5050
channel: ${{ needs.prepare-release.outputs.version }}
51+
commit_sha: ${{ github.sha }}
52+
status_context: npm-publish-release
5153
secrets: inherit

.github/workflows/on-pull-request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,5 @@ jobs:
145145
with:
146146
channel: ${{ needs.publish-dev.outputs.devChannel }}
147147
commit_sha: ${{ github.event.pull_request.head.sha }}
148+
status_context: npm-publish-dev
148149
secrets: inherit

.github/workflows/run-e2e-tests.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ on:
88
default: latest-rc
99
commit_sha:
1010
type: string
11-
description: "Commit SHA to wait for publish status (optional)"
11+
description: "Commit SHA to wait for publish status"
12+
required: false
13+
status_context:
14+
type: string
15+
description: "Commit status context to wait for (e.g., npm-publish-dev, npm-publish-release)"
1216
required: false
1317

1418
jobs:
@@ -42,15 +46,16 @@ jobs:
4246
run: npm install -g @salesforce/cli
4347

4448
- name: Wait for npm publish to complete
45-
if: ${{ inputs.commit_sha != '' }}
49+
if: ${{ inputs.commit_sha != '' && inputs.status_context != '' }}
4650
shell: bash
4751
env:
4852
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4953
COMMIT_SHA: ${{ inputs.commit_sha }}
54+
STATUS_CONTEXT: ${{ inputs.status_context }}
5055
run: |
51-
echo "Waiting for npm-publish-dev status on $COMMIT_SHA (timeout: 30s)..."
56+
echo "Waiting for $STATUS_CONTEXT status on $COMMIT_SHA (timeout: 30s)..."
5257
for i in $(seq 1 6); do
53-
STATUS=$(gh api repos/${{ github.repository }}/commits/$COMMIT_SHA/status --jq '.statuses[] | select(.context == "npm-publish-dev") | .state' 2>/dev/null || echo "")
58+
STATUS=$(gh api "repos/${{ github.repository }}/commits/$COMMIT_SHA/status" --jq ".statuses[] | select(.context == \"$STATUS_CONTEXT\") | .state" 2>/dev/null || echo "")
5459
echo "Attempt $i/6 - Status: ${STATUS:-not found}"
5560
if [ "$STATUS" = "success" ]; then
5661
echo "Publish succeeded!"
@@ -61,7 +66,7 @@ jobs:
6166
fi
6267
sleep 5
6368
done
64-
echo "Timeout waiting for npm-publish-dev status"
69+
echo "Timeout waiting for $STATUS_CONTEXT status"
6570
exit 1
6671
6772
- name: Install new plugin version

0 commit comments

Comments
 (0)