-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbump_version
executable file
·44 lines (35 loc) · 1.17 KB
/
bump_version
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
#!/bin/bash
set -e
function check_prog {
if ! hash "$1" >/dev/null 2>&1; then
echo "Command not found: $1.$2 Aborting..."
exit 1
fi
}
function check_git_clean {
if [ -n "$(git status --porcelain)" ]; then
echo "git working directory not clean. Aborting..."
exit 1
fi
}
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <new_version>"
exit 1
fi
check_prog flatpak-cargo-generator.py " Please get it from https://github.com/flatpak/flatpak-builder-tools/blob/master/cargo/flatpak-cargo-generator.py and put it in your \$PATH."
check_git_clean
NEW_VERSION=$1
shift
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
cd "${SCRIPT_DIR}"
sed -i "s/^version = \".*\"/version = \"${NEW_VERSION}\"/" Cargo.toml
cargo update
flatpak-cargo-generator.py ./Cargo.lock -o cargo-sources.json && printf '\n' >> cargo-sources.json
TAG_NAME="v${NEW_VERSION}"
# Run twice to ignore the changes made by the first run (and its possible non-zero exit code)
pre-commit run --all-files || pre-commit run --all-files
git add Cargo.toml Cargo.lock cargo-sources.json
git commit -m "chore: bump version to ${NEW_VERSION}"
git tag "$TAG_NAME"
git push origin
git push origin "$TAG_NAME"