77 workflow_dispatch :
88 inputs :
99 package_name :
10- description : ' The package name to release ( e.g., xrpl, ripple-address-codec)'
10+ description : ' Package folder (Name of the package directory under packages/ folder. e.g., xrpl, ripple-address-codec)'
1111 required : true
1212 release_branch :
1313 description : ' Release branch the release is generated from'
5050 echo "✅ No Internal Artifactory URL found"
5151 fi
5252
53+ # validate dist tag
54+ NPM_DIST_TAG="${{ github.event.inputs.npmjs_dist_tag }}"
55+
56+ # Empty → default to 'latest'
57+ if [ -z "$NPM_DIST_TAG" ]; then
58+ NPM_DIST_TAG="latest"
59+ echo "ℹ️ npmjs_dist_tag empty → defaulting to 'latest'."
60+ fi
61+
62+ # Must start with a lowercase letter; then [a-z0-9._-]; max 128 chars
63+ if ! [[ "$NPM_DIST_TAG" =~ ^[a-z][a-z0-9._-]{0,127}$ ]]; then
64+ echo "❌ Invalid npm dist-tag '$NPM_DIST_TAG'. Must start with a lowercase letter and contain only [a-z0-9._-], max 128 chars." >&2
65+ exit 1
66+ fi
67+
68+ # Disallow version-like prefixes (avoid semver/range confusion)
69+ if [[ "$NPM_DIST_TAG" =~ ^v[0-9] || "$NPM_DIST_TAG" =~ ^[0-9] ]]; then
70+ echo "❌ Invalid npm dist-tag '$NPM_DIST_TAG'. Must not start with 'v' + digit or a digit (e.g., 'v1', '1.2.3')." >&2
71+ exit 1
72+ fi
73+
74+ echo "✅ npmjs_dist_tag '$NPM_DIST_TAG' is valid."
75+
5376 - name : Get package version from package.json
5477 id : get_version
5578 run : |
@@ -275,16 +298,15 @@ jobs:
275298 echo "🔎 Checking if a PR already exists for $RELEASE_BRANCH → main…"
276299 OWNER="${REPO%%/*}"
277300
278- # List open PRs with base=main and head=OWNER:RELEASE_BRANCH
279- PRS_JSON="$(gh api \
280- -H 'Accept: application/vnd.github+json' \
301+ # Find existing OPEN PR: base=main, head=OWNER:RELEASE_BRANCH
302+ PRS_JSON="$(gh api -H 'Accept: application/vnd.github+json' \
281303 "/repos/$REPO/pulls?state=open&base=main&head=${OWNER}:${RELEASE_BRANCH}")"
282304
283305 PR_NUMBER="$(printf '%s' "$PRS_JSON" | jq -r '.[0].number // empty')"
284306 PR_URL="$(printf '%s' "$PRS_JSON" | jq -r '.[0].html_url // empty')"
285307
286308 if [ -n "${PR_NUMBER:-}" ]; then
287- echo "ℹ️ PR already exists : #$PR_NUMBER"
309+ echo "ℹ️ Found existing PR : #$PR_NUMBER ($PR_URL) "
288310 else
289311 echo "📝 Creating PR for release $VERSION from $RELEASE_BRANCH → main"
290312 CREATE_JSON="$(jq -n \
@@ -294,25 +316,16 @@ jobs:
294316 --arg body "Automated PR for release **$VERSION** from **$RELEASE_BRANCH** → **main**. Workflow Run: https://github.com/$REPO/actions/runs/${{ github.run_id }}" \
295317 '{title:$title, head:$head, base:$base, body:$body}')"
296318
297- RESP="$(gh api \
298- -H 'Accept: application/vnd.github+json' \
299- --method POST \
300- /repos/$REPO/pulls \
301- --input <(printf '%s' "$CREATE_JSON"))"
319+ RESP="$(gh api -H 'Accept: application/vnd.github+json' \
320+ --method POST /repos/$REPO/pulls --input <(printf '%s' "$CREATE_JSON"))"
302321
303322 PR_NUMBER="$(printf '%s' "$RESP" | jq -r '.number')"
304323 PR_URL="$(printf '%s' "$RESP" | jq -r '.html_url')"
305-
306- # (Optional) add a label to the PR (labels are an Issues API)
307- gh api \
308- -H 'Accept: application/vnd.github+json' \
309- --method POST \
310- "/repos/$REPO/issues/$PR_NUMBER/labels" \
311- --input <(jq -n --arg l "release" '{labels:[$l]}') >/dev/null || true
312324 fi
313325
314- echo "PR_URL=$PR_URL" >> "$GITHUB_ENV"
315- echo "✅ PR URL: $PR_URL"
326+ # Expose as step outputs (use these in later steps)
327+ echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"
328+ echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
316329
317330 - name : Release summary for review
318331 env :
@@ -327,6 +340,7 @@ jobs:
327340 GITHUB_ACTOR : ${{ github.actor }}
328341 GITHUB_TRIGGERING_ACTOR : ${{ github.triggering_actor }}
329342 RUN_URL : https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
343+ PR_URL : ${{ steps.ensure_pr.outputs.pr_url }}
330344
331345 run : |
332346 set -euo pipefail
@@ -387,11 +401,11 @@ jobs:
387401 fi
388402
389403 if [ "$INCLUDE_PR_LINE" = true ]; then
390- STEP2_LINE="2. Review the package update PR and provide two approvals. DO NOT MERGE - ${EXECUTOR} will verify the package on npm registry and merge this approved PR."
404+ STEP2_LINE="2. Review the package update PR and provide two approvals. DO NOT MERGE - ${EXECUTOR} will verify the package on npm registry and merge this approved PR. ${PR_URL} "
391405 printf -v MESSAGE '%s is releasing %s@%s. At least two approvers from (%s) need to take following actions:\n1. Review the release artifacts and approve/reject the release. (%s)\n%s' \
392406 "$EXECUTOR" "$PACKAGE_NAME" "$PACKAGE_VERSION" "$REVIEWERS" "$RUN_URL" "$STEP2_LINE"
393407 else
394- printf -v MESSAGE '%s is releasing %s@%s. At least two approvers from (%s) need to take following actions:\n1. Review the release artifacts and approve/reject the release. (%s)' \
408+ printf -v MESSAGE '%s is releasing %s@%s. At least two approvers from (%s) need to take following actions:\nReview the release artifacts and approve/reject the release. (%s)' \
395409 "$EXECUTOR" "$PACKAGE_NAME" "$PACKAGE_VERSION" "$REVIEWERS" "$RUN_URL"
396410 fi
397411
0 commit comments