-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbump-version.sh
More file actions
executable file
·119 lines (98 loc) · 5.13 KB
/
bump-version.sh
File metadata and controls
executable file
·119 lines (98 loc) · 5.13 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env bash
# bump-version.sh
# One-click script to update the TornadoVM version across all files.
#
# Usage:
# ./bump-version.sh <new-version>
# ./bump-version.sh 2.2.0
#
# What it updates:
# - build.sh (TAG_VERSION=)
# - push.sh (tag=)
# - push-intel.sh (tag=)
# - polyglotImages/buildDocker.sh (TAG_VERSION=)
# - dockerFiles/Dockerfile.* (git checkout tags/v)
# - polyglotImages/**/Dockerfile.* (git checkout tags/v)
# - example/pom.xml (tornado-api / tornado-matrices versions)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# ── helpers ──────────────────────────────────────────────────────────────────
usage() {
echo "Usage: $0 <new-version>"
echo ""
echo " new-version SemVer string, e.g. 2.2.0"
echo ""
echo "Current version detected from build.sh: $(grep 'TAG_VERSION=' build.sh | head -1 | cut -d'=' -f2)"
exit 1
}
die() { echo "ERROR: $*" >&2; exit 1; }
replace_in_file() {
local file="$1" old="$2" new="$3"
if grep -qF "$old" "$file"; then
sed -i "s|${old}|${new}|g" "$file"
echo " [updated] $file"
else
echo " [skip] $file (pattern not found)"
fi
}
# ── validate args ─────────────────────────────────────────────────────────────
[[ $# -lt 1 ]] && usage
NEW_VERSION="$1"
# Validate semver-ish (digits and dots only)
# Allow X.Y.Z or X.Y.Z-suffix (e.g., -jdk21)
if ! [[ "$NEW_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then
die "Version must be X.Y.Z or X.Y.Z-suffix (e.g. 2.2.0 or 2.2.0-jdk21), got: $NEW_VERSION"
fi
# Auto-detect current version from build.sh
CURRENT_VERSION=$(grep 'TAG_VERSION=' build.sh | head -1 | cut -d'=' -f2 | tr -d '[:space:]')
[[ -z "$CURRENT_VERSION" ]] && die "Could not detect current version from build.sh"
if [[ "$CURRENT_VERSION" == "$NEW_VERSION" ]]; then
echo "Already at version $NEW_VERSION — nothing to do."
exit 0
fi
echo "Bumping: $CURRENT_VERSION → $NEW_VERSION"
echo ""
# ── build / push scripts ──────────────────────────────────────────────────────
replace_in_file "build.sh" "TAG_VERSION=${CURRENT_VERSION}" "TAG_VERSION=${NEW_VERSION}"
replace_in_file "push.sh" "tag=${CURRENT_VERSION}" "tag=${NEW_VERSION}"
replace_in_file "push-intel.sh" "tag=${CURRENT_VERSION}" "tag=${NEW_VERSION}"
replace_in_file "polyglotImages/buildDocker.sh" "TAG_VERSION=${CURRENT_VERSION}" "TAG_VERSION=${NEW_VERSION}"
# ── Dockerfiles ───────────────────────────────────────────────────────────────
DOCKERFILES=(
dockerFiles/Dockerfile.nvidia.jdk21
dockerFiles/Dockerfile.nvidia.graalvm.jdk21
dockerFiles/Dockerfile.nvidia.graalvm.ptx.jdk17
dockerFiles/Dockerfile.oneapi.intel.jdk21
dockerFiles/Dockerfile.oneapi.intel.graalvm.jdk21
polyglotImages/polyglot-graalpy/Dockerfile.intel.oneapi.graalpy.jdk21
polyglotImages/polyglot-graalpy/Dockerfile.nvidia.opencl.graalpy.jdk21
polyglotImages/polyglot-graaljs/Dockerfile.nvidia.opencl.graaljs.jdk21
polyglotImages/polyglot-truffleruby/Dockerfile.nvidia.opencl.truffleruby.jdk21
)
for f in "${DOCKERFILES[@]}"; do
replace_in_file "$f" "checkout tags/v${CURRENT_VERSION}" "checkout tags/v${NEW_VERSION}"
done
# ── example/pom.xml ───────────────────────────────────────────────────────────
# Only touch the tornado-api and tornado-matrices <version> blocks.
POM="example/pom.xml"
if grep -q "<version>${CURRENT_VERSION}</version>" "$POM"; then
# Multi-line sed: for each TornadoVM artifact, replace the following <version> line.
for artifact in tornado-api tornado-matrices; do
sed -i "/<artifactId>${artifact}<\/artifactId>/{
n
s|<version>${CURRENT_VERSION}</version>|<version>${NEW_VERSION}</version>|
}" "$POM"
done
echo " [updated] $POM"
else
echo " [skip] $POM (pattern not found)"
fi
# ── done ──────────────────────────────────────────────────────────────────────
echo ""
echo "Done. All files updated to $NEW_VERSION."
echo ""
echo "Next steps:"
echo " Build all images : ./buildAll.sh intel OR ./buildAll.sh nvidia"
echo " Push all images : ./push.sh"
echo " Push Intel only : ./push-intel.sh"