Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script to release binary to github #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions release-github-binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash


set -u -e -o pipefail

TAG="${1:-}"

if [[ -z "$TAG" ]] ; then
echo "ERROR: No release tag specified" >&2
exit 1
fi

if [[ -z "$GITHUB_TOKEN" ]] ; then
echo "ERROR: Env variable GITHUB_TOKEN not set. Get one in GH account Settings -> Developer settings -> Personal access tokens (use 'public_repo' scope)" >&2
exit 1
fi

if [[ ! -x "custom-prometheus-exporter" ]] ; then
echo "ERROR: Missing binary, please build it" >&2
exit 1
fi

echo "Getting ghr"

go get github.com/tcnksm/ghr

echo "Creating archive"
rm -rf dist/
mkdir dist
tar -czf "dist/custom-prometheus-exporter-$TAG-amd64.tar.gz" custom-prometheus-exporter LICENSE README.md
sha256sum dist/*.tar.gz > dist/sha256sums.txt

echo "Upload to Github"

ghr -parallel 1 -u marckhouzam -r custom-prometheus-exporter --replace "$TAG" dist/

echo "Done"