From 43abbdec5f97090b1192c6cea083a3a6f8bd2739 Mon Sep 17 00:00:00 2001 From: Mike Ball Date: Tue, 25 Oct 2022 09:59:36 -0400 Subject: [PATCH] create make target ensuring unique version --- Makefile | 5 ++++- scripts/ensure-unique-version.sh | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 scripts/ensure-unique-version.sh diff --git a/Makefile b/Makefile index 13d5ba3..00574a9 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,10 @@ fmtcheck: test -z $(shell go fmt $(SOURCE)) .PHONY: fmtcheck -tag: +check-tag: + ./scripts/ensure-unique-version.sh "$(VERSION)" + +tag: check-tag echo "creating git tag $(VERSION)" git tag $(VERSION) git push origin $(VERSION) diff --git a/scripts/ensure-unique-version.sh b/scripts/ensure-unique-version.sh new file mode 100755 index 0000000..8ee738a --- /dev/null +++ b/scripts/ensure-unique-version.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +version="${1}" +repo="mdb/gh-dispatch" + +result="$(curl \ + --header "Accept: application/vnd.github.v3+json" \ + --write "%{http_code}" \ + --out "/dev/null" \ + "https://api.github.com/repos/${repo}/releases/tags/${version}")" + +if [ "${result}" = "404" ]; then + exit 0 +fi + +echo "${version} is an existing ${repo} release" +exit 1