Skip to content

Commit 64f793d

Browse files
kamal-kaur04claude
andcommitted
Reject non-canonical versions; create the GitHub release in the workflow
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 020db02 commit 64f793d

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
required: true
1313
default: latest
1414
type: string
15+
release_notes:
16+
description: GitHub release notes (markdown). The release is created only for the latest dist-tag
17+
required: false
18+
type: string
1519

1620
permissions:
1721
contents: read
@@ -28,10 +32,12 @@ jobs:
2832
steps:
2933
- name: Validate inputs
3034
run: |
35+
num='(0|[1-9][0-9]*)'
36+
id='(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)'
3137
if [ "$NPM_TAG" = latest ]; then
32-
pattern='^[0-9]+\.[0-9]+\.[0-9]+$'
38+
pattern="^$num\\.$num\\.$num\$"
3339
else
34-
pattern='^[0-9]+\.[0-9]+\.[0-9]+-[0-9A-Za-z.-]+$'
40+
pattern="^$num\\.$num\\.$num-$id(\\.$id)*\$"
3541
fi
3642
if ! [[ "$VERSION" =~ $pattern ]]; then
3743
echo "::error::version '$VERSION' does not match $pattern for dist-tag '$NPM_TAG'"
@@ -68,3 +74,10 @@ jobs:
6874
branch="release-$(date +%s)"
6975
git push --follow-tags origin "HEAD:refs/heads/$branch"
7076
echo "Open the version bump PR: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/compare/$GITHUB_REF_NAME...$branch?expand=1" | tee -a "$GITHUB_STEP_SUMMARY"
77+
78+
- name: Create GitHub release
79+
if: inputs.npm_tag == 'latest' && inputs.release_notes != ''
80+
env:
81+
GH_TOKEN: ${{ github.token }}
82+
RELEASE_NOTES: ${{ inputs.release_notes }}
83+
run: gh release create "v$VERSION" --verify-tag --title "Public Beta v$VERSION" --notes "$RELEASE_NOTES"

0 commit comments

Comments
 (0)