#!/usr/bin/env bash # Copyright 2023 Uber Technologies, Inc. # Licensed under the Apache License, Version 2.0 set -xeuo pipefail sign=(-u motiejus@jakstys.lt) [[ $1 == "--nosign" ]] && { sign=(); shift; } _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]+))?(-rc([0-9]+))?$ ]] || \ _err "arg1 accepts the following formats: v1.0 v1.0.0 v1.0-rc1 v1.0.1-rc1" git tag | grep -q "^$1$" && _err "tag $1 already exists" last_tag=$(git -c 'versionsort.suffix=-' tag -l --sort=v:refname | tail -1) { echo bazel-zig-cc "$1" echo echo Changelog since "$last_tag": git log --pretty=format:"- [%an] %s" "$last_tag"..HEAD | \ grep -v "Update release notes for $last_tag" } | git tag "${sign[@]+"${sign[@]}"}" -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 > .README.md mv .README.md README.md git add README.md git commit -m "Update release notes for $1"