-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·46 lines (35 loc) · 1.42 KB
/
Copy pathupdate.sh
File metadata and controls
executable file
·46 lines (35 loc) · 1.42 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
#!/usr/bin/env sh
# This script is used to update the version of the project in Cargo.toml and README.md
# Commit the changes and push them to the repository
# Builds the docker image and pushes it to Docker Hub
# Usage: ./update.sh <new_version_string>
set -e
DOCKER_REPO="sycration/cz4r"
if [ -z "$1" ]; then
echo "Usage: ./update.sh <new_version_string>"
exit 1
fi
NEW_VERSION="$1"
echo "Updating version to $NEW_VERSION..."
# Update version in Cargo.toml
sed -i.bak -E "s|^version = \".*\"|version = \"$NEW_VERSION\"|" Cargo.toml
rm -f Cargo.toml.bak
# Update version in README.md
sed -i.bak -E "s|[0-9]+\.[0-9]+\.[0-9]+|$NEW_VERSION|g" README.md
rm -f README.md.bak
# Update Cargo.lock to reflect the new version
cargo update -p cz4r --precise "$NEW_VERSION" 2>/dev/null || true
# Commit and push the changes, unless there is nothing to commit
# (e.g. because the script was already run but the docker step failed)
git add Cargo.toml Cargo.lock README.md
if git status --porcelain | grep -q '^M'; then
git commit -m "Bump version to $NEW_VERSION"
git push
else
echo "No changes to commit, skipping git commit/push."
fi
# Build and push the docker image
sudo docker build -t "$DOCKER_REPO:$NEW_VERSION" -t "$DOCKER_REPO:latest" .
sudo docker push "$DOCKER_REPO:$NEW_VERSION"
sudo docker push "$DOCKER_REPO:latest"
echo "Successfully updated to version $NEW_VERSION and pushed docker image $DOCKER_REPO:$NEW_VERSION"