aboutsummaryrefslogtreecommitdiffstats
path: root/VegaData/build_and_push.sh
diff options
context:
space:
mode:
authorivar <i@oiee.no>2025-10-06 12:06:46 +0200
committerivar <i@oiee.no>2025-10-06 12:06:46 +0200
commitf18f3fee8844df98a30c2d248dfca04643dd4365 (patch)
tree599c1b6a97777a84cdcd7fe8333f4718d2e55c85 /VegaData/build_and_push.sh
downloadvegadata-f18f3fee8844df98a30c2d248dfca04643dd4365.tar.xz
vegadata-f18f3fee8844df98a30c2d248dfca04643dd4365.zip
Initial
Diffstat (limited to 'VegaData/build_and_push.sh')
-rwxr-xr-xVegaData/build_and_push.sh87
1 files changed, 87 insertions, 0 deletions
diff --git a/VegaData/build_and_push.sh b/VegaData/build_and_push.sh
new file mode 100755
index 0000000..34b0ff1
--- /dev/null
+++ b/VegaData/build_and_push.sh
@@ -0,0 +1,87 @@
+#!/usr/bin/env bash
+
+set -Eueo pipefail
+
+CURRENT_DEV_VERSION=$(cat .version-dev)
+CURRENT_DEV_VERSION_INT=${CURRENT_DEV_VERSION//[!0-9]/}
+CURRENT_VERSION=$(cat .version)
+CURRENT_VERSION_INT=${CURRENT_VERSION//[!0-9]/}
+if [ ${1-prod} == "dev" ]; then
+ NEW_VERSION="v$((CURRENT_DEV_VERSION_INT + 1))-dev"
+else
+ NEW_VERSION="v$((CURRENT_VERSION_INT + 1))"
+fi
+IMAGE_NAME="vegadata/server"
+HUB_NAME="dr.ivar.systems/vegadata/server"
+
+# Check for uncommited changes and optionally commit them
+if [ "$(git status --untracked-files=no --porcelain)" ]; then
+ echo "Unclean git tree! press CTRL+C to exit or press ENTER to commit and push to the default branch"
+ read -n 1
+
+ read -p "Enter commit message: " COMMIT_MESSAGE
+ git add ..
+ git commit --quiet -m "$COMMIT_MESSAGE"
+fi
+
+if [ ${1-prod} == "dev" ]; then
+ echo $NEW_VERSION >|.version-dev
+ git add .version-dev
+else
+ echo $NEW_VERSION >|.version
+ git add .version
+fi
+
+echo "Starting build of $HUB_NAME:$NEW_VERSION at $(date -u)..."
+echo
+
+# Put version.txt inside of server
+pushd src/wwwroot
+echo "$NEW_VERSION" >version.txt
+git add version.txt
+popd
+
+git commit --quiet -m "chore(release): Bump version"
+
+read -p "Do you want to tag this build? (y/n) " -n 1 -r
+echo
+if [[ $REPLY =~ ^[Yy]$ ]]; then
+ read -p "Enter tag message (can be empty): " TAG_MESSAGE
+ git tag -am "$TAG_MESSAGE" $NEW_VERSION
+fi
+
+read -p "Do you want to push the latest commits and tags to origin? (y/n) " -n 1 -r
+echo
+if [[ $REPLY =~ ^[Yy]$ ]]; then
+ echo "Pushing latest changes to remotes..."
+ echo
+ git push --quiet --follow-tags
+fi
+
+# Build podman image
+echo "Building podman image"
+echo
+
+podman build -t $IMAGE_NAME:$NEW_VERSION .
+
+podman tag $IMAGE_NAME:$NEW_VERSION $HUB_NAME:$NEW_VERSION
+
+if [ ${1-prod} == "dev" ]; then
+ podman tag $IMAGE_NAME:$NEW_VERSION $HUB_NAME:latest-dev
+fi
+if [ ${1-prod} == "prod" ]; then
+ podman tag $IMAGE_NAME:$NEW_VERSION $HUB_NAME:latest
+fi
+
+# Optionally push images to podman registry
+echo "Press CTRL+C to exit or press ENTER to push podman image to registry"
+read -n 1
+podman push $HUB_NAME:$NEW_VERSION
+
+if [ ${1-prod} == "dev" ]; then
+ podman push $HUB_NAME:latest-dev
+fi
+
+if [ ${1-prod} == "prod" ]; then
+ podman push $HUB_NAME:latest
+fi