@neferbyte/cherry-release-cli 1.0.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cherry-release +52 -24
- package/package.json +1 -1
package/bin/cherry-release
CHANGED
|
@@ -8,29 +8,47 @@ WORKTREE_DIR="/tmp/cherry-release-test"
|
|
|
8
8
|
WORKTREES_TO_CLEAN=()
|
|
9
9
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
10
10
|
|
|
11
|
-
# ─── Parse
|
|
11
|
+
# ─── Parse flags ──────────────────────────────────────────────────────────────
|
|
12
12
|
|
|
13
13
|
FORCE_ALL=false
|
|
14
14
|
FORCE_development=false
|
|
15
15
|
FORCE_staging=false
|
|
16
16
|
FORCE_production=false
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
BUMP_TYPE="patch"
|
|
18
|
+
|
|
19
|
+
while [[ $# -gt 0 ]]; do
|
|
20
|
+
case "$1" in
|
|
21
|
+
--force)
|
|
22
|
+
shift
|
|
23
|
+
if [[ $# -eq 0 || "$1" == --* ]]; then
|
|
24
|
+
FORCE_ALL=true
|
|
25
|
+
else
|
|
26
|
+
while [[ $# -gt 0 && "$1" != --* ]]; do
|
|
27
|
+
case "$1" in
|
|
28
|
+
development) FORCE_development=true ;;
|
|
29
|
+
staging) FORCE_staging=true ;;
|
|
30
|
+
production) FORCE_production=true ;;
|
|
31
|
+
*) echo -e "\033[1;31mError:\033[0m Unknown branch '$1'. Valid branches: development staging production" >&2; exit 1 ;;
|
|
32
|
+
esac
|
|
33
|
+
shift
|
|
34
|
+
done
|
|
35
|
+
fi
|
|
36
|
+
;;
|
|
37
|
+
--bump)
|
|
38
|
+
shift
|
|
39
|
+
if [[ $# -eq 0 ]]; then
|
|
40
|
+
echo -e "\033[1;31mError:\033[0m --bump requires an argument (major, minor, patch)" >&2; exit 1
|
|
41
|
+
fi
|
|
42
|
+
case "$1" in
|
|
43
|
+
major|minor|patch) BUMP_TYPE="$1"; shift ;;
|
|
44
|
+
*) echo -e "\033[1;31mError:\033[0m Invalid bump type '$1'. Must be major, minor, or patch" >&2; exit 1 ;;
|
|
29
45
|
esac
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
46
|
+
;;
|
|
47
|
+
*)
|
|
48
|
+
echo -e "\033[1;31mError:\033[0m Unknown option '$1'. Usage: cherry-release [--bump major|minor|patch] [--force [branch ...]]" >&2; exit 1
|
|
49
|
+
;;
|
|
50
|
+
esac
|
|
51
|
+
done
|
|
34
52
|
|
|
35
53
|
# ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
36
54
|
|
|
@@ -140,13 +158,23 @@ COMMITS_production=""
|
|
|
140
158
|
for branch in staging production; do
|
|
141
159
|
hashes=$(git cherry "origin/$branch" origin/development | grep '^+' | awk '{print $2}')
|
|
142
160
|
|
|
143
|
-
# Filter out version bump commits
|
|
161
|
+
# Filter out version bump commits and already-promoted commits
|
|
144
162
|
filtered=""
|
|
145
163
|
for hash in $hashes; do
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
164
|
+
subject=$(git log -1 --format="%s" "$hash")
|
|
165
|
+
|
|
166
|
+
# Skip version bump commits (commit-and-tag-version)
|
|
167
|
+
if [[ "$subject" =~ ^chore\(release\): ]]; then
|
|
168
|
+
continue
|
|
169
|
+
fi
|
|
170
|
+
|
|
171
|
+
# Skip commits whose subject already exists on the target branch
|
|
172
|
+
# (handles cases where git cherry misidentifies due to package.json/lockfile diffs)
|
|
173
|
+
if git log "origin/$branch" --format="%s" | grep -qFx "$subject"; then
|
|
174
|
+
continue
|
|
149
175
|
fi
|
|
176
|
+
|
|
177
|
+
filtered="$filtered $hash"
|
|
150
178
|
done
|
|
151
179
|
|
|
152
180
|
eval "COMMITS_${branch}=\"${filtered# }\""
|
|
@@ -214,7 +242,7 @@ if should_deploy "development" "$staging_count"; then
|
|
|
214
242
|
step "Deploying to development"
|
|
215
243
|
git checkout development
|
|
216
244
|
git pull --ff-only
|
|
217
|
-
"$SCRIPT_DIR/cherry-release-version"
|
|
245
|
+
"$SCRIPT_DIR/cherry-release-version" "$BUMP_TYPE"
|
|
218
246
|
git push --follow-tags origin development
|
|
219
247
|
echo -e " \033[1;32m✓\033[0m development released"
|
|
220
248
|
else
|
|
@@ -233,7 +261,7 @@ if should_deploy "staging" "${#staging_commits[@]}"; then
|
|
|
233
261
|
done
|
|
234
262
|
git push origin staging
|
|
235
263
|
fi
|
|
236
|
-
"$SCRIPT_DIR/cherry-release-version"
|
|
264
|
+
"$SCRIPT_DIR/cherry-release-version" "$BUMP_TYPE"
|
|
237
265
|
git push --follow-tags origin staging
|
|
238
266
|
echo -e " \033[1;32m✓\033[0m staging released"
|
|
239
267
|
else
|
|
@@ -252,7 +280,7 @@ if should_deploy "production" "${#production_commits[@]}"; then
|
|
|
252
280
|
done
|
|
253
281
|
git push origin production
|
|
254
282
|
fi
|
|
255
|
-
"$SCRIPT_DIR/cherry-release-version"
|
|
283
|
+
"$SCRIPT_DIR/cherry-release-version" "$BUMP_TYPE"
|
|
256
284
|
git push --follow-tags origin production
|
|
257
285
|
echo -e " \033[1;32m✓\033[0m production released"
|
|
258
286
|
else
|