diff --git a/release b/release index 26a915e..e37f571 100755 --- a/release +++ b/release @@ -1,13 +1,13 @@ #!/bin/bash -set -euo pipefail +set -xeuo pipefail _err(){ >&2 echo "ERROR: $*"; exit 1; } git status --porcelain | grep -q "" && _err "working tree is dirty, commit your changes first." -[[ "$1" =~ ^v([0-9]+)\.([0-9]+)(\.([0-9]+))?$ ]] || \ - _err "arg1 accepts the following formats: v1.0 v1.0.0" +[[ "$1" =~ ^([0-9]+)\.([0-9]+)(\.([0-9]+))?$ ]] || \ + _err "arg1 accepts the following formats: 1.0 1.0.0" git tag | grep -q "^$1$" && _err "tag $1 already exists" @@ -20,3 +20,11 @@ last_tag=$(git tag | tail -1) echo Changelog since "$last_tag": git log --pretty=format:"- [%cn] %s" "$last_tag"..HEAD } | git tag -u motiejus@jakstys.lt -F - "$1" + +shasum=$(git archive --prefix="bazel-zig-cc-$1/" --format=tar "$1" | \ + gzip -n | sha256sum | cut -f1 -d" ") + +./relnotes.awk -v tag="$1" -v sha256sum="$shasum" README.md | sponge README.md + +git add README.md +git commit -m "Update release notes for $1" diff --git a/relnotes.awk b/relnotes.awk new file mode 100755 index 0000000..3ac8a2f --- /dev/null +++ b/relnotes.awk @@ -0,0 +1,34 @@ +#!/usr/bin/awk -f + +BEGIN {stage=0}; + +!/```/ && stage==0 { + print +} + +/```/ && stage==0 { + print "```" + print "BAZEL_ZIG_CC_VERSION = \""tag"\"" + print "" + print "http_archive(" + print " name = \"bazel-zig-cc\"," + print " sha256 = \""sha256sum"\"," + print " strip_prefix = \"bazel-zig-cc-{}\".format(BAZEL_ZIG_CC_VERSION)," + print " urls = [\"https://git.sr.ht/~motiejus/bazel-zig-cc/archive/{}.tar.gz\".format(BAZEL_ZIG_CC_VERSION)]," + print ")" + stage=1 + next +} + +!/^)$/ && stage==1 { + next +}; + +/^)$/ && stage==1 { + stage=2 + next +}; + +stage==2 { + print; +};