-
Notifications
You must be signed in to change notification settings - Fork 0
/
version-bump.sh
40 lines (29 loc) · 1.13 KB
/
version-bump.sh
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
#!/bin/bash
set -e
if [ $# -eq 0 ]; then
echo "Usage $0 VERSION"
exit 1
fi
echo "Bumping versions to $1"
# GNU/BSD compat
sedi=(-i)
case "$(uname)" in
# For macOS, use two parameters
Darwin*) sedi=(-i "")
esac
git grep -l $(cat VERSION) -- ':!**/yarn.lock' ':!CHANGELOG.md' ':!Cargo.lock' ':!package.json' | \
xargs sed "${sedi[@]}" \
-e "s/$(cat VERSION)/$1/g"
# Potential for collisions in package.json files, handle those separately
# Replace only matching "version": "x.xx.x" and "@project-serum/anchor": "x.xx.x"
git grep -l $(cat VERSION) -- '**/package.json' | \
xargs sed "${sedi[@]}" \
-e "s/@project-serum\/anchor\": \"$(cat VERSION)\"/@project-serum\/anchor\": \"$1\"/g" \
-e "s/\"version\": \"$(cat VERSION)\"/\"version\": \"$1\"/g"
# Potential for collisions in Cargo.lock, use cargo update to update it
cargo update --workspace
# Insert version number into CHANGELOG.md
sed "${sedi[@]}" -e "s/## \[Unreleased\]/## [Unreleased]\n\n## [$1] - $(date '+%Y-%m-%d')/g" CHANGELOG.md
echo $1 > VERSION
echo "$(git diff --stat | tail -n1) files modified"
echo " $(cat VERSION) changeset generated, commit and tag"