From cf87627ed15da5a0525be0781ddb30550ef7ef3d Mon Sep 17 00:00:00 2001 From: Tycho Bellers Date: Thu, 4 Aug 2022 22:06:58 -0700 Subject: [PATCH] Update create-release.sh --- tools/create-release.sh | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/tools/create-release.sh b/tools/create-release.sh index 7821dab..c1a7b4e 100644 --- a/tools/create-release.sh +++ b/tools/create-release.sh @@ -1,8 +1,25 @@ # # Builds and uploads docker images to GitHub container registry for a new release using the latest commit from the master branch. # + currentDirectory=$(dirname "$0") +isWindows() { + if [[ "$(uname)" == MINGW32_NT* ]]; then + return 0 + elif [[ "$(uname)" == MINGW64_NT* ]]; then + return 0 + fi + return 1 +} + +isDockerRunning() { + if docker version >/dev/null 2>&1; then + return 0 + fi + return 1 +} + personalAccessToken=$1 if [ -z "${personalAccessToken}" ]; then echo "Missing GitHub personal access token! Visit https://github.com/settings/tokens/new to create one. Must have \"write:packages\" permission." @@ -58,6 +75,19 @@ fi scriptDirectory="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" &>/dev/null && pwd 2>/dev/null)" projectDirectory="$(cd "$scriptDirectory/../" && pwd)" +# Make sure docker is running +if isWindows; then + if ! isDockerRunning; then + echo "Docker not running! Starting it now..." + "/c/Program Files/Docker/Docker/Docker Desktop.exe" & + while ! isDockerRunning; do + echo "Waiting for Docker..." + sleep 5 + done + echo "Done." + fi +fi + # Build and push docker image docker buildx build \ --platform linux/amd64,linux/arm64/v8,linux/arm/v7 \ @@ -69,6 +99,8 @@ docker buildx build \ # Tag the commit with the version number echo "Tagging commit with version code..." -git tag v"$currentVersion" "$hash" +tagName=v"$currentVersion" +git tag "$tagName" "$hash" +git push origin "$tagName" -echo "Done!" \ No newline at end of file +echo "Done!"