#!/bin/sh if [[ "$1" != *.*.* ]]; then echo "Invalid version string '$1'" exit 1 fi currentbranch=$(git branch --show-current) if [ "$currentbranch" != "main" ]; then echo "'main' branch should be checked out (currently '$currentbranch')" exit 1 fi if [ -n "$2" ]; then SKIP_BUMP=1 SKIP_TAG=1 SKIP_CARGO=1 SKIP_DOCKER=1 if [[ "$2" == "bump" ]]; then unset SKIP_BUMP; fi if [[ "$2" == "tag" ]]; then unset SKIP_TAG; fi if [[ "$2" == "cargo" ]]; then unset SKIP_CARGO; fi if [[ "$2" == "docker" ]]; then unset SKIP_DOCKER; fi fi echo $SKIP_BUMP $SKIP_TAG $SKIP_CARGO $SKIP_DOCKER if [ -z $SKIP_BUMP ]; then echo "# Bumping version to '$1'" git checkout main sed -i 's/^version.*$/version = "'"$1"'"/' Cargo.toml cargo generate-lockfile git add Cargo.toml Cargo.lock git commit -m "Bump version to $1" git push origin main fi if [ -z $SKIP_TAG ]; then eval $(ssh-agent) git tag v$1 -m "Version $1" git push origin "v$1" fi if [ -z $SKIP_CARGO ]; then cargo publish --allow-dirty fi if [ -z $SKIP_DOCKER ]; then set -e docker pull rust:alpine docker pull alpine:latest buildx build \ --platform linux/arm64/v8,linux/amd64 \ -t "quay.io/vijfhoek/empede:latest" \ -t "quay.io/vijfhoek/empede:$1" \ -t "docker.io/vijfhoek/empede:latest" \ -t "docker.io/vijfhoek/empede:$1" \ . docker push "quay.io/vijfhoek/empede:latest" docker push "quay.io/vijfhoek/empede:$1" docker push "docker.io/vijfhoek/empede:latest" docker push "docker.io/vijfhoek/empede:$1" set +e fi