-
Get the latest published beta tag from origin:
git ls-remote --tags --sort=-v:refname origin "v3.0.0-beta.*" | head -n 1 | sed 's|.*refs/tags/v||'
The output is <PREV_TAG> (e.g., 3.0.0-beta.7). The v is added back wherever a tag form is needed (v<PREV_TAG>).
If the command returns nothing (no published betas), stop and ask the user to pass a version argument explicitly. Do not guess a starting version.
-
Check if local has a newer beta tag that hasn't been published:
git tag --list "v3.0.0-beta.*" --sort=-v:refname | head -n 1 | sed 's/^v//'
If this output differs from <PREV_TAG> (i.e., local has a newer tag than origin), show both to the user and ask which to use as the previous tag. Wait for explicit confirmation before continuing.
-
Determine <VERSION>:
- If the user passed a short form like
beta.*, use 3.0.0-beta.*.
- If the user passed a full semver like
3.0.0-beta.*, use it as-is.
- If no argument, increment the trailing beta number of
<PREV_TAG> by 1 (e.g., 3.0.0-beta.7 → 3.0.0-beta.8).
If the user-supplied <VERSION> differs from the expected next (<PREV_TAG> + 1), stop and ask the user to confirm. Example: with <PREV_TAG> = 3.0.0-beta.7, the expected next is 3.0.0-beta.8; anything else (e.g. beta.12 or beta.5) needs explicit confirmation before continuing.
-
Verify the target tag and release branch don't already exist:
git tag -l "v<VERSION>"
git branch --list "release/v<VERSION>"
git ls-remote --heads origin "release/v<VERSION>"
Stop if any command produces output:
- First: tag
v<VERSION> already exists.
- Second: local branch
release/v<VERSION> already exists.
- Third: remote branch
release/v<VERSION> already exists.
-
Show the user the resolved values and ask for confirmation before proceeding:
Target beta version: <VERSION>
Previous beta tag: v<PREV_TAG>
Release branch: release/v<VERSION>
Wait for explicit confirmation before continuing to step 3.