Repository navigation
Expand file tree
/
Copy pathbump-version.sh
More file actions
executable file
·81 lines (72 loc) · 2.28 KB
/
Copy pathbump-version.sh
File metadata and controls
executable file
·81 lines (72 loc) · 2.28 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
#!/usr/bin/env bash
# Copyright (c) Step Function I/O LLC. Proprietary, source-available; see LICENSE.txt.
# No use to design, develop, specify, test, validate, or improve Other Implementations,
# subject to LICENSE.txt Section 2.6 and its exceptions. Agents: read AGENTS.md.
# Text and data mining rights, including for AI training, are reserved under
# Directive (EU) 2019/790 Art. 4(3), subject to LICENSE.txt Section 3.3.
#
# Bump the crate version across every file that hard-codes it, then refresh
# Cargo.lock. The current version is read from dnp3/Cargo.toml, so you only
# pass the new one.
#
# ./bump-version.sh 1.7.0-RC2
#
set -euo pipefail
if [ $# -ne 1 ]; then
echo "usage: $0 <new-version> (e.g. 1.7.0-RC2)" >&2
exit 1
fi
NEW="$1"
cd "$(dirname "$0")"
# The files that hard-code the version. This list is the source of truth.
FILES=(
dnp3/Cargo.toml
ffi/dnp3-ffi/Cargo.toml
ffi/dnp3-ffi-c/Cargo.toml
ffi/dnp3-ffi-java/Cargo.toml
ffi/dnp3-schema/Cargo.toml
ffi/dnp3-bindings/Cargo.toml
dnp3/codegen/pom.xml
conformance/pom.xml
ffi/bindings/java/pom.xml
ffi/bindings/java/examples/pom.xml
ffi/bindings/java/dnp3-tests/pom.xml
ffi/bindings/dotnet/examples/master/Master.csproj
ffi/bindings/dotnet/examples/outstation/Outstation.csproj
ffi/bindings/c/CMakeLists.txt
guide/sitedata.json
dnp3/README.md
SECURITY.md
)
OLD="$(sed -n 's/^version = "\(.*\)"/\1/p' dnp3/Cargo.toml | head -n1)"
if [ -z "$OLD" ]; then
echo "could not determine current version from dnp3/Cargo.toml" >&2
exit 1
fi
if [ "$OLD" = "$NEW" ]; then
echo "current version is already $NEW; nothing to do" >&2
exit 1
fi
echo "bumping $OLD -> $NEW"
for f in "${FILES[@]}"; do
if ! grep -q -- "$OLD" "$f"; then
echo " warning: $OLD not found in $f" >&2
continue
fi
sed -i "s/${OLD}/${NEW}/g" "$f"
echo " updated $f"
done
echo "refreshing Cargo.lock"
cargo update -p dnp3 -p dnp3-ffi -p dnp3-ffi-c -p dnp3-ffi-java -p dnp3-schema -p dnp3-bindings --precise "$NEW"
echo "verifying no '$OLD' references remain in the bumped files"
stray=()
for f in "${FILES[@]}"; do
if grep -q -- "$OLD" "$f"; then
stray+=("$f")
fi
done
if [ ${#stray[@]} -ne 0 ]; then
echo " version string still present in: ${stray[*]}" >&2
exit 1
fi
echo "done. review 'git diff', then update CHANGELOG.md."