From bc4bae36258dba3a1fc690af96c717a0185b95e1 Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Sun, 4 Aug 2019 19:07:14 +0200 Subject: [PATCH] Add a script for making new releases --- .gitignore | 1 + README.md | 2 +- build.sh | 7 ++++++- release.sh | 40 ++++++++++++++++++++++++++++++++++++++++ test.sh | 1 + 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100755 release.sh diff --git a/.gitignore b/.gitignore index 1442ae0..927b64a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /moar +/moar-*-*-* diff --git a/README.md b/README.md index 6aed850..60d4c48 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Install (into `/usr/local/bin`) from source: Making a new Release -------------------- -FIXME: Go release instructions +Execute `release.sh` and follow instructions. TODO ---- diff --git a/build.sh b/build.sh index 11e6c78..6a66171 100755 --- a/build.sh +++ b/build.sh @@ -2,9 +2,14 @@ VERSION="$(git describe --tags --dirty)" +BINARY="moar" +if [ -n "$GOOS$GOARCH" ] ; then + BINARY="$BINARY-$VERSION-$GOOS-$GOARCH" +fi + # Linker flags trick below from here: # https://www.reddit.com/r/golang/comments/4cpi2y/question_where_to_keep_the_version_number_of_a_go/d1kbap7?utm_source=share&utm_medium=web2x # This line must be last in the script so that its return code # propagates properly to its caller -go build -ldflags="-X main.versionString=$VERSION" +go build -ldflags="-X main.versionString=$VERSION" -o "$BINARY" diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..a6ce61d --- /dev/null +++ b/release.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -e -o pipefail + +./test.sh + +# FIXME: Bail if we're on a dirty version + +# List existing version numbers... +echo +git tag | cat + +# ... and ask for a new version number. +echo +echo "Please provide a version number for the new release:" +read -r VERSION + +# FIXME: When asking for a release description, list +# changes since last release as inspiration + +# Make an annotated tag for this release +git tag --annotated "$VERSION" + +# NOTE: To get the version number right, these builds must +# be done after the above tagging. +# +# NOTE: Make sure this list matches the one in test.sh +GOOS=linux GOARCH=386 ./build.sh +GOOS=darwin GOARCH=amd64 ./build.sh + +# Push the newly built release tag +git push --tags + +# FIXME: Put the actual URL here, don't just refer to Github +# +# FIXME: Instead of asking the user to upload the binaries, +# upload them for the user. +echo +echo "Please upload the following binaries to the new release page on Github:" +find . -maxdepth 1 -name 'moar-*-*-*' -print0 | xargs -0 -n1 basename diff --git a/test.sh b/test.sh index a4bc5dc..677c5db 100755 --- a/test.sh +++ b/test.sh @@ -6,6 +6,7 @@ set -e -o pipefail go test github.com/walles/moar/m # Ensure we can cross compile +# NOTE: Make sure this list matches the one in release.sh GOOS=linux GOARCH=386 ./build.sh GOOS=darwin GOARCH=amd64 ./build.sh