Skip to content

Commit

Permalink
create make target ensuring unique version
Browse files Browse the repository at this point in the history
  • Loading branch information
mdb committed Oct 25, 2022
1 parent 4086a3e commit 43abbde
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Makefile
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions 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

0 comments on commit 43abbde

Please sign in to comment.