Skip to content

Commit 6dfdffe

Browse files
committed
ci(post-release-test): add workflow_dispatch trigger for manual testing
Allows manually triggering the post-release test with a specific version string to test previously released packages or conduct temporary script tests.
1 parent 6b6618c commit 6dfdffe

1 file changed

Lines changed: 35 additions & 20 deletions

File tree

.github/workflows/post-release-test.yml

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ name: Post-Release Test
33
permissions: {}
44

55
on:
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Version to test (e.g., 0.0.0-g12345678.20260228-1200)'
10+
required: true
11+
type: string
612
workflow_run:
713
workflows: ['Release']
814
types: [completed]
@@ -15,42 +21,51 @@ jobs:
1521
extract-version:
1622
name: Extract release version
1723
runs-on: ubuntu-latest
18-
if: github.event.workflow_run.conclusion == 'success'
24+
# For workflow_run: only run if the release succeeded
25+
# For workflow_dispatch: always run (manual trigger with explicit version)
26+
if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success'
1927
permissions:
2028
contents: read
2129
outputs:
2230
version: ${{ steps.version.outputs.version }}
2331
npm_tag: ${{ steps.version.outputs.npm_tag }}
2432
steps:
25-
- name: Find GitHub release for this commit
33+
- name: Resolve version
2634
id: version
2735
env:
2836
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2937
GH_REPO: ${{ github.repository }}
38+
MANUAL_VERSION: ${{ inputs.version }}
3039
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
3140
run: |
32-
# Find the release whose target_commitish matches the workflow run's head SHA
33-
RELEASE_JSON=$(gh api repos/$GH_REPO/releases --jq ".[] | select(.target_commitish == \"$HEAD_SHA\") | {tag_name, prerelease}" | head -1)
34-
if [ -z "$RELEASE_JSON" ]; then
35-
echo "Error: No GitHub release found for commit $HEAD_SHA"
36-
exit 1
37-
fi
41+
if [ -n "$MANUAL_VERSION" ]; then
42+
# Manual trigger: use the provided version directly
43+
echo "version=$MANUAL_VERSION" >> "$GITHUB_OUTPUT"
44+
echo "npm_tag=test" >> "$GITHUB_OUTPUT"
45+
echo "Using manually specified version: $MANUAL_VERSION"
46+
else
47+
# Automatic trigger: find the release by commit SHA
48+
RELEASE_JSON=$(gh api repos/$GH_REPO/releases --jq ".[] | select(.target_commitish == \"$HEAD_SHA\") | {tag_name, prerelease}" | head -1)
49+
if [ -z "$RELEASE_JSON" ]; then
50+
echo "Error: No GitHub release found for commit $HEAD_SHA"
51+
exit 1
52+
fi
3853
39-
TAG_NAME=$(echo "$RELEASE_JSON" | jq -r '.tag_name')
40-
PRERELEASE=$(echo "$RELEASE_JSON" | jq -r '.prerelease')
54+
TAG_NAME=$(echo "$RELEASE_JSON" | jq -r '.tag_name')
55+
PRERELEASE=$(echo "$RELEASE_JSON" | jq -r '.prerelease')
4156
42-
# Strip 'v' prefix to get version
43-
VERSION="${TAG_NAME#v}"
44-
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
57+
# Strip 'v' prefix to get version
58+
VERSION="${TAG_NAME#v}"
59+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
4560
46-
# Determine npm tag
47-
if [ "$PRERELEASE" = "true" ]; then
48-
echo "npm_tag=test" >> "$GITHUB_OUTPUT"
49-
else
50-
echo "npm_tag=latest" >> "$GITHUB_OUTPUT"
51-
fi
61+
if [ "$PRERELEASE" = "true" ]; then
62+
echo "npm_tag=test" >> "$GITHUB_OUTPUT"
63+
else
64+
echo "npm_tag=latest" >> "$GITHUB_OUTPUT"
65+
fi
5266
53-
echo "Found release: tag=$TAG_NAME version=$VERSION prerelease=$PRERELEASE"
67+
echo "Found release: tag=$TAG_NAME version=$VERSION prerelease=$PRERELEASE"
68+
fi
5469
5570
wait-for-npm-propagation:
5671
name: Wait for npm propagation

0 commit comments

Comments
 (0)