summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2023-10-25 16:20:39 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2023-10-25 16:34:13 +0200
commit805fa8a52cebbc5412b7b755a009ae946c202913 (patch)
tree4c6ee43fecbb7c73baa9d8177538fb40b097f5c3
parent16d1d8e2a6fef61983c960573081b594bfcf257e (diff)
Prepare release: Initial script
-rwxr-xr-xprepare_release.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/prepare_release.sh b/prepare_release.sh
new file mode 100755
index 0000000..7ee8281
--- /dev/null
+++ b/prepare_release.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+set -e
+
+PROJECT_VERSION="$1"
+
+if [ -z "$1" ]; then
+ echo "No version supplied"
+ exit 1
+fi
+
+if ! command -v "black" &>/dev/null; then
+ echo "please install black for formatting the python wrapper"
+ exit 1
+fi
+
+if ! command -v "gofumpt" &>/dev/null; then
+ echo "please install gofumpt for formatting the go code"
+ exit 1
+fi
+
+if [ "$(git tag -l "${PROJECT_VERSION}")" ]; then
+ echo "Version: ${PROJECT_VERSION} already has a tag"
+ exit 1
+fi
+
+# First check if th
+if [[ $(git diff) ]]; then
+ echo "There are changes, commit them before releasing"
+ exit 1
+fi
+
+# Format all go files
+git ls-files | grep '.go$' | xargs -I {} gofumpt -w {} >/dev/null
+if [[ $(git diff) ]]; then
+ git add -u
+ git commit -m "Format: Run Gofumpt"
+fi
+
+# Format all Python files
+git ls-files | grep '.py$' | xargs -I {} black --quiet {} >/dev/null
+if [[ $(git diff) ]]; then
+ git add -u
+ git commit -m "Format: Run Black"
+fi
+
+# Replace version number
+# replace in internal/version
+sed -i "s/const Version = ".*"/const Version = \"${PROJECT_VERSION}\"/" internal/version/version.go
+sed -i "s/__version__ = ".*"/__version__ = \"${PROJECT_VERSION}\"/" wrappers/python/setup.py
+sed -i "s/__version__ = ".*"/__version__ = \"${PROJECT_VERSION}\"/" wrappers/python/eduvpn_common/__init__.py
+
+git add -u
+git commit -m "Version: Update to ${PROJECT_VERSION}"