forked from firecracker-microvm/firecracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbump-version.sh
executable file
·74 lines (60 loc) · 2.01 KB
/
bump-version.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
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
#!/usr/bin/env bash
# Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
set -eu -o pipefail
shopt -s lastpipe
FC_TOOLS_DIR=$(dirname $(realpath $0))
source "$FC_TOOLS_DIR/functions"
FC_ROOT_DIR=$FC_TOOLS_DIR/..
if [ $# -ne 1 ]; then
cat <<EOF
$0 <version>
Example: $0 1.4.0-dev
Bump Firecracker release version:
1. Updates Cargo.toml / Cargo.lock
2. Runs 'cargo update'
EOF
exit 1
fi
version=$1
function check_snapshot_version {
local version=$1
local snap_version=$(echo $version |cut -f-2 -d. |tr . _)
if ! grep -s FC_V${snap_version}_SNAP_VERSION src/vmm/src/version_map.rs; then
die "I couldn't find FC_V${snap_version}_SNAP_VERSION in src/vmm/src/version_map.rs"
fi
}
check_snapshot_version "$version"
# Get current version from the swagger spec.
prev_ver=$(get_swagger_version)
say "Updating from $prev_ver to $version ..."
# Update version in files.
files_to_change=(
"$FC_ROOT_DIR/src/api_server/swagger/firecracker.yaml"
"$FC_ROOT_DIR/src/firecracker/Cargo.toml"
"$FC_ROOT_DIR/src/jailer/Cargo.toml"
"$FC_ROOT_DIR/src/rebase-snap/Cargo.toml"
"$FC_ROOT_DIR/src/seccompiler/Cargo.toml"
"$FC_ROOT_DIR/src/cpu-template-helper/Cargo.toml"
)
say "Updating source files:"
for file in "${files_to_change[@]}"; do
say "- $file"
if [[ "$file" =~ .+\.toml$ ]]; then
# For TOML
sed -i "s/^version = \"$prev_ver\"/version = \"$version\"/" "$file"
elif [[ "$file" =~ .+\.yaml$ ]]; then
# For YAML
sed -i "s/version: $prev_ver/version: $version/" "$file"
else
echo "ERROR: Unrecognized file '$file'"
exit 1
fi
done
# Run `cargo check` to update firecracker and jailer versions in all
# `Cargo.lock`.
# NOTE: This will break if it finds paths with spaces in them
find . -path ./build -prune -o -name Cargo.lock -print |while read -r cargo_lock; do
say "Updating $cargo_lock ..."
(cd "$(dirname "$cargo_lock")"; cargo check; cargo update)
done