summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjannfis <jann@mistrust.net>2020-12-06 17:11:20 +0100
committerGitHub <noreply@github.com>2020-12-06 17:11:20 +0100
commit69fbb79d64a60ab07ce2f65e494d55965a3c0b8c (patch)
tree404f0863bdee8923e4028324563c3a00e069feca
parentfed5246080d3818234392550b326f362f0730054 (diff)
chore: add some release creation scripts (#131)
* chore: add some release creation scripts Signed-off-by: jannfis <jann@mistrust.net> * exclude hack from spelling Signed-off-by: jannfis <jann@mistrust.net> * exclude hack from spelling Signed-off-by: jannfis <jann@mistrust.net>
-rw-r--r--.github/actions/spelling/excludes.txt1
-rwxr-xr-xhack/release.sh64
-rwxr-xr-xhack/upload-release-assets.sh26
3 files changed, 91 insertions, 0 deletions
diff --git a/.github/actions/spelling/excludes.txt b/.github/actions/spelling/excludes.txt
index af56473..c2c9527 100644
--- a/.github/actions/spelling/excludes.txt
+++ b/.github/actions/spelling/excludes.txt
@@ -1,6 +1,7 @@
^\.github/
^go\.(?:sum|mod)$
\/mocks\/
+^hack\/
ignore$
\.png$
^\.config/
diff --git a/hack/release.sh b/hack/release.sh
new file mode 100755
index 0000000..9819f10
--- /dev/null
+++ b/hack/release.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+# Simple script to do a release
+
+TARGET_REMOTE=upstream
+TARGET_VERSION="$1"
+set -eu
+set -o pipefail
+
+if test "${TARGET_VERSION}" = ""; then
+ echo "USAGE: $0 <version>" >&2
+ exit 1
+fi
+
+TARGET_TAG="v${TARGET_VERSION}"
+
+if ! echo "${TARGET_VERSION}" | egrep -q '^[0-9]\.[0-9]\.[0-9]$'; then
+ echo "Error: Target version '${TARGET_VERSION}' is not well-formed. Must be X.Y.Z" >&2
+ exit 1
+fi
+
+echo "*** checking for current git branch"
+RELEASE_BRANCH=$(git rev-parse --abbrev-ref HEAD || true)
+if [[ $RELEASE_BRANCH = release-* ]]; then
+ echo "*** branch is $RELEASE_BRANCH"
+ IMAGE_TAG=${TARGET_TAG}
+else
+ echo "Error: Branch $RELEASE_BRANCH is not release branch" >&2
+ exit 1
+fi
+
+if ! test -f VERSION; then
+ echo "Error: You should be in repository root." >&2
+ exit 1
+fi
+
+echo "${TARGET_VERSION}" > VERSION
+
+echo "*** checking for existance of git tag ${TARGET_TAG}"
+if git tag -l "${TARGET_VERSION}" | grep -q "${TARGET_TAG}"; then
+ echo "Error: Tag with version ${TARGET_TAG} already exists." >&2
+ exit 1
+fi
+
+echo "*** generating new manifests"
+export IMAGE_TAG="${TARGET_TAG}"
+make manifests
+
+echo "*** performing release commit"
+git commit -S -s -m "Release ${TARGET_TAG}" VERSION manifests/
+git tag ${TARGET_TAG}
+
+echo "*** build docker image"
+make image
+
+echo
+echo "*** done"
+echo
+echo "If everything is fine, push changes to GitHub and Docker Hub:"
+echo
+echo " git push ${TARGET_REMOTE} $RELEASE_BRANCH ${TARGET_TAG}"
+echo " make IMAGE_TAG='${TARGET_TAG}' image-push"
+echo
+echo "Then, create release tag and execute upload-release-assets.sh"
diff --git a/hack/upload-release-assets.sh b/hack/upload-release-assets.sh
new file mode 100755
index 0000000..cd3693d
--- /dev/null
+++ b/hack/upload-release-assets.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+set -eu
+set -o pipefail
+
+if ! test -f VERSION; then
+ echo "Error: VERSION file not found" >&2
+fi
+
+TARGET_VERSION="v$(cat VERSION)"
+
+echo "*** extracting release assets for $TARGET_VERSION"
+
+TEMP_DIR=$(mktemp -d /tmp/argocd-image-updater.${TARGET_VERSION}.XXXXXXX)
+TARGET_BIN=argocd-image-updater_${TARGET_VERSION}_linux-amd64
+
+cid=$(docker create argoprojlabs/argocd-image-updater:${TARGET_VERSION})
+docker cp $cid:/usr/local/bin/argocd-image-updater ${TEMP_DIR}/${TARGET_BIN}
+docker rm -v ${cid}
+
+echo "*** uploading release assets"
+echo "*** ${TARGET_BIN}"
+gh release upload ${TARGET_VERSION} ${TEMP_DIR}/${TARGET_BIN}
+
+echo "*** deleting temp directory"
+rm -rf "${TEMP_DIR}"