-
Notifications
You must be signed in to change notification settings - Fork 828
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·85 lines (71 loc) · 2.43 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·85 lines (71 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env bash
set -euo pipefail
# Release script for @askjo/camofox-browser
# Usage: ./release.sh [patch|minor|major]
# Defaults to patch if no argument given.
#
# This script:
# 1. Runs pre-flight checks (clean tree, on master, up to date)
# 2. Runs tests locally
# 3. Bumps version via npm version (which syncs openclaw.plugin.json)
# 4. Pushes commit + tag to origin
# 5. GitHub Actions publishes to npm with provenance
#
# The actual npm publish happens in CI (.github/workflows/publish.yml).
BUMP="${1:-patch}"
if [[ "$BUMP" != "patch" && "$BUMP" != "minor" && "$BUMP" != "major" ]]; then
echo "Usage: ./release.sh [patch|minor|major]"
exit 1
fi
cd "$(dirname "$0")"
# --- Pre-flight checks ---
echo "🔍 Pre-flight checks..."
# Clean working tree
if [[ -n "$(git status --porcelain)" ]]; then
echo "❌ Working tree is dirty. Commit or stash changes first."
exit 1
fi
# On master
BRANCH=$(git branch --show-current)
if [[ "$BRANCH" != "master" ]]; then
echo "❌ Not on master (on $BRANCH). Switch to master first."
exit 1
fi
# Up to date with remote
git fetch origin master --quiet
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse origin/master)
if [[ "$LOCAL" != "$REMOTE" ]]; then
echo "❌ Local master ($LOCAL) differs from origin ($REMOTE). Pull/push first."
exit 1
fi
# --- Tests ---
echo ""
echo "🧪 Running tests..."
JEST_OUTPUT=$(NODE_OPTIONS='--experimental-vm-modules' npx jest --runInBand --forceExit --testPathPattern='tests/unit' 2>&1)
echo "$JEST_OUTPUT" | tail -5
if echo "$JEST_OUTPUT" | grep -q 'Tests:.*failed'; then
echo "❌ Tests failed"
exit 1
fi
echo ""
# --- Version bump ---
CURRENT=$(node -p "require('./package.json').version")
echo "📦 Current version: $CURRENT"
echo "📦 Bumping: $BUMP"
echo ""
# npm version bumps package.json, runs the "version" lifecycle script
# (which syncs openclaw.plugin.json), creates a git commit and tag
npm version "$BUMP" --message "v%s"
NEW_VERSION=$(node -p "require('./package.json').version")
echo ""
echo "📦 New version: $NEW_VERSION"
# --- Push (triggers CI publish) ---
echo ""
echo "📤 Pushing commit and tag (CI will publish to npm)..."
git push origin master --follow-tags
echo ""
echo "✅ Release v${NEW_VERSION} triggered"
echo " CI will publish @askjo/camofox-browser@${NEW_VERSION} with provenance"
echo " Watch: https://github.com/jo-inc/camofox-browser/actions"
echo " Package: https://www.npmjs.com/package/@askjo/camofox-browser"