You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if ! echo "$BRANCH" | grep -Eq '^release-v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'; then
42
+
echo "Error: Branch '$BRANCH' must match 'release-v<semver>' (e.g., release-v1.2.3)." >&2
43
+
exit 1
44
+
fi
45
+
46
+
# 2) NEW_VERSION must be valid semver
47
+
node -e "const v=process.env.NEW_VERSION; const semver=/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?$/; if(!semver.test(v)){ console.error('Error: NEW_VERSION is not valid semver:', v); process.exit(1); }"
48
+
if [ $? -ne 0 ]; then
49
+
exit 1
50
+
fi
51
+
52
+
# 3) NEW_VERSION must differ from CURRENT_VERSION
53
+
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
54
+
echo "Error: NEW_VERSION equals CURRENT_VERSION ($CURRENT_VERSION). Nothing to release." >&2
55
+
exit 1
56
+
fi
57
+
58
+
- name: Replace version in files
59
+
env:
60
+
NEW_VERSION: ${{ env.NEW_VERSION }}
61
+
run: |
62
+
echo "Current version: $CURRENT_VERSION"
63
+
echo "New version: $NEW_VERSION"
64
+
65
+
# Update package.json version field manually
66
+
yarn workspace @openzeppelin-compact/contracts version "$NEW_VERSION"
67
+
68
+
# Escape special characters for sed
69
+
ESCAPED_CURRENT=$(printf '%s' "$CURRENT_VERSION" | sed -e 's/[\/&]/\\&/g')
70
+
ESCAPED_NEW=$(printf '%s' "$NEW_VERSION" | sed -e 's/[\/&]/\\&/g')
71
+
72
+
# Replace version in contracts/src/
73
+
find ./contracts/src/ -type d -name '.*' -prune -o \
74
+
-type f -exec sed -i "s#$ESCAPED_CURRENT#$ESCAPED_NEW#g" {} +
75
+
76
+
# Replace version in docs/, excluding package-lock.json
77
+
find ./docs/ -type d -name '.*' -prune -o \
78
+
-type f ! -name 'package-lock.json' -exec sed -i "s#$ESCAPED_CURRENT#$ESCAPED_NEW#g" {} +
0 commit comments