Skip to content

Commit 15046e0

Browse files
authored
Allow passing a different CLI version (#48)
1 parent e01367f commit 15046e0

2 files changed

Lines changed: 71 additions & 12 deletions

File tree

RELEASING.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ For example:
2727

2828
The version must follow `MAJOR.MINOR.PATCH` format (e.g., `0.10.0`, `1.0.0`).
2929

30+
By default the script sets the `cli_version` default to match the action version. When the two have drifted — for example, an action-only release while the CLI stays behind — pass the CLI version explicitly:
31+
32+
```bash
33+
./scripts/release.sh 0.14.4 --cli-version 0.14.1
34+
```
35+
3036
## What happens
3137

3238
The release script (`scripts/release.sh`) and CI workflows handle the full process:
@@ -68,4 +74,4 @@ The Release workflow then:
6874

6975
- Consumers reference this action as `linear/linear-release-action@v0` (the floating major tag), so the major-tag move is the load-bearing step. Without it, consumers stay on whichever commit the major tag previously pointed to.
7076
- The source of truth for the action's version is [`VERSION`](./VERSION); the auto-tag workflow fails if the branch name and `VERSION` file disagree.
71-
- The script bumps the `cli_version` default to match the action version. If you need a release where these diverge, edit the release branch by hand before merging the PR — the auto-tag workflow validates the `VERSION` file, not `cli_version`.
77+
- The script bumps the `cli_version` default to match the action version unless you pass `--cli-version`. The auto-tag workflow validates the `VERSION` file, not `cli_version`, so the two are free to diverge.

scripts/release.sh

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,68 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
VERSION="${1:-}"
4+
usage() {
5+
echo "Usage: $0 <version> [--cli-version <version>]"
6+
echo "Example: $0 0.10.0"
7+
echo "Example: $0 0.14.4 --cli-version 0.14.1 # action and CLI versions drift"
8+
}
9+
10+
validate_version() {
11+
echo "$1" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'
12+
}
13+
14+
VERSION=""
15+
CLI_VERSION=""
16+
17+
while [ $# -gt 0 ]; do
18+
case "$1" in
19+
--cli-version|--cli)
20+
if [ $# -lt 2 ]; then echo "Error: $1 requires a value"; usage; exit 1; fi
21+
CLI_VERSION="${2#v}"
22+
shift 2
23+
;;
24+
--cli-version=*|--cli=*)
25+
CLI_VERSION="${1#*=}"
26+
CLI_VERSION="${CLI_VERSION#v}"
27+
shift
28+
;;
29+
-h|--help)
30+
usage
31+
exit 0
32+
;;
33+
-*)
34+
echo "Error: Unknown flag '$1'"
35+
usage
36+
exit 1
37+
;;
38+
*)
39+
if [ -n "$VERSION" ]; then echo "Error: Unexpected argument '$1'"; usage; exit 1; fi
40+
VERSION="${1#v}"
41+
shift
42+
;;
43+
esac
44+
done
545

646
# --- Usage ---
747
if [ -z "$VERSION" ]; then
8-
echo "Usage: $0 <version>"
9-
echo "Example: $0 0.10.0"
48+
usage
1049
exit 1
1150
fi
1251

13-
# --- Validate version format ---
14-
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
52+
# The CLI default tracks the action version unless an explicit drift is requested.
53+
if [ -z "$CLI_VERSION" ]; then
54+
CLI_VERSION="$VERSION"
55+
fi
56+
57+
# --- Validate version formats ---
58+
if ! validate_version "$VERSION"; then
1559
echo "Error: Invalid version format '$VERSION'. Expected MAJOR.MINOR.PATCH (e.g., 0.10.0)"
1660
exit 1
1761
fi
62+
if ! validate_version "$CLI_VERSION"; then
63+
echo "Error: Invalid CLI version format '$CLI_VERSION'. Expected MAJOR.MINOR.PATCH (e.g., 0.10.0)"
64+
exit 1
65+
fi
1866

1967
# --- Preflight checks ---
2068

@@ -75,13 +123,13 @@ git checkout -b "$BRANCH"
75123
echo "Updating VERSION to $VERSION..."
76124
echo "$VERSION" > VERSION
77125

78-
echo "Updating cli_version default in action.yml..."
79-
sed -i.bak -E "s/^( default: v)[0-9]+\.[0-9]+\.[0-9]+\$/\1$VERSION/" action.yml
80-
sed -i.bak -E "s/(Linear Release CLI version to install \(e\.g\., \"v)[0-9]+\.[0-9]+\.[0-9]+(\"\))/\1$VERSION\2/" action.yml
126+
echo "Updating cli_version default in action.yml to v$CLI_VERSION..."
127+
sed -i.bak -E "s/^( default: v)[0-9]+\.[0-9]+\.[0-9]+\$/\1$CLI_VERSION/" action.yml
128+
sed -i.bak -E "s/(Linear Release CLI version to install \(e\.g\., \"v)[0-9]+\.[0-9]+\.[0-9]+(\"\))/\1$CLI_VERSION\2/" action.yml
81129
rm action.yml.bak
82130

83-
echo "Updating cli_version reference in README.md..."
84-
sed -i.bak -E "s/(\`v)[0-9]+\.[0-9]+\.[0-9]+(\` \| Linear Release CLI)/\1$VERSION\2/" README.md
131+
echo "Updating cli_version reference in README.md to v$CLI_VERSION..."
132+
sed -i.bak -E "s/(\`v)[0-9]+\.[0-9]+\.[0-9]+(\` \| Linear Release CLI)/\1$CLI_VERSION\2/" README.md
85133
rm README.md.bak
86134

87135
git add VERSION action.yml README.md
@@ -92,9 +140,14 @@ echo "Pushing branch..."
92140
git push -u origin "$BRANCH"
93141

94142
echo "Creating pull request..."
143+
if [ "$CLI_VERSION" = "$VERSION" ]; then
144+
PR_BODY="Bumps the action and default CLI version to v$VERSION."
145+
else
146+
PR_BODY="Bumps the action to v$VERSION (default CLI version stays at v$CLI_VERSION)."
147+
fi
95148
PR_URL=$(gh pr create \
96149
--title "Release v$VERSION" \
97-
--body "Bumps the action and default CLI version to v$VERSION.
150+
--body "$PR_BODY
98151
99152
After this PR is merged, the \`v$VERSION\` tag will be created automatically, triggering the [Release workflow](./.github/workflows/release.yml)." \
100153
--base main)

0 commit comments

Comments
 (0)