-
Notifications
You must be signed in to change notification settings - Fork 446
ci(repo): add dispatched release path #8308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nikosdouvlis
wants to merge
8
commits into
main
Choose a base branch
from
nikos/release-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+325
−3
Open
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0e04c89
ci(repo): add dispatched release path
nikosdouvlis 46e097c
ci(repo): validate package names in dispatched release
nikosdouvlis 06477c6
ci(repo): relax engine check on dispatched install
nikosdouvlis 2c6c965
ci(repo): use npm install for dispatched legacy releases
nikosdouvlis 1f50cf1
ci(repo): pin npm to source_ref packageManager for ci install
nikosdouvlis 7eb76a2
ci(repo): document npm ci lockfile requirement on dispatched release
nikosdouvlis c42c0ab
ci(repo): fall back to npm install if npm ci rejects lockfile
nikosdouvlis d550fec
ci(repo): derive dist-tag from package name and version in dispatched…
nikosdouvlis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| #!/usr/bin/env bash | ||
| # Dispatch the Release workflow's legacy-release job for a single package. | ||
| # | ||
| # Usage: | ||
| # scripts/legacy-release.sh <package> <version> [--publish] | ||
| # | ||
| # Defaults to dry-run. Pass --publish to actually publish. | ||
| # Dist-tag is derived from convention: latest-<short>-v<major>. | ||
| # | ||
| # Examples: | ||
| # scripts/legacy-release.sh @clerk/nextjs 5.7.6 | ||
| # scripts/legacy-release.sh @clerk/nextjs 5.7.6 --publish | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| PKG="${1:-}" | ||
| VERSION="${2:-}" | ||
| MODE="${3:-}" | ||
|
|
||
| if [[ -z "$PKG" || -z "$VERSION" ]]; then | ||
| echo "Usage: $0 <package> <version> [--publish]" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ $# -gt 3 ]]; then | ||
| echo "Unexpected arguments: ${*:4}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! "$PKG" =~ ^@clerk/[a-z0-9][a-z0-9-]*$ ]]; then | ||
| echo "Package must be in the form @clerk/<name>, got: $PKG" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "Version must be semver <major>.<minor>.<patch>, got: $VERSION" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| DRY_RUN=true | ||
| if [[ "$MODE" == "--publish" ]]; then | ||
| DRY_RUN=false | ||
| elif [[ -n "$MODE" ]]; then | ||
| echo "Unknown mode: $MODE (expected --publish or nothing)" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| SHORT="${PKG#@clerk/}" | ||
| MAJOR="${VERSION%%.*}" | ||
| DIST_TAG="latest-${SHORT}-v${MAJOR}" | ||
|
|
||
| if ! command -v gh >/dev/null 2>&1; then | ||
| echo "gh CLI not found. Install: https://cli.github.com/" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! command -v jq >/dev/null 2>&1; then | ||
| echo "jq not found. Install: brew install jq" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
| if [[ "$BRANCH" == "HEAD" ]]; then | ||
| echo "Detached HEAD. Checkout a branch first." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! git ls-remote --exit-code --heads origin "$BRANCH" >/dev/null 2>&1; then | ||
| echo "Branch '$BRANCH' not pushed to origin. Push first." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| LOCAL_SHA=$(git rev-parse HEAD) | ||
| REMOTE_SHA=$(git rev-parse "origin/$BRANCH") | ||
| if [[ "$LOCAL_SHA" != "$REMOTE_SHA" ]]; then | ||
| echo "Local '$BRANCH' is out of sync with origin. Push first." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| PKG_JSON="./packages/$SHORT/package.json" | ||
| if [[ ! -f "$PKG_JSON" ]]; then | ||
| echo "No package.json at $PKG_JSON." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| PKG_VERSION=$(jq -r .version "$PKG_JSON") | ||
| if [[ "$PKG_VERSION" != "$VERSION" ]]; then | ||
| echo "$PKG_JSON has version $PKG_VERSION, expected $VERSION." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| PACKAGES=$(jq -c -n --arg n "$PKG" --arg v "$VERSION" --arg t "$DIST_TAG" \ | ||
| '[{name:$n, version:$v, dist_tag:$t}]') | ||
|
|
||
| cat <<EOF | ||
| Dispatching Release workflow: | ||
| package: $PKG | ||
| version: $VERSION | ||
| dist-tag: $DIST_TAG | ||
| branch: $BRANCH | ||
| source_ref: $LOCAL_SHA | ||
| dry_run: $DRY_RUN | ||
|
|
||
| EOF | ||
|
|
||
| read -r -p "Continue? [y/N] " yn | ||
| case "$yn" in | ||
| y|Y) ;; | ||
| *) echo "Aborted."; exit 0 ;; | ||
| esac | ||
|
|
||
| gh workflow run release.yml \ | ||
| --ref main \ | ||
| -f source_ref="$LOCAL_SHA" \ | ||
| -f packages="$PACKAGES" \ | ||
| -f dry_run="$DRY_RUN" | ||
|
|
||
| echo "" | ||
| echo "Dispatched. Approve at:" | ||
| echo " https://github.com/clerk/javascript/actions/workflows/release.yml" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.