2022-07-27 23:33:53 +03:00
|
|
|
#!/usr/bin/env bash
|
2023-03-02 23:42:35 +02:00
|
|
|
|
|
|
|
# Copyright 2023 Uber Technologies, Inc.
|
|
|
|
# Licensed under the Apache License, Version 2.0
|
|
|
|
|
2021-10-18 15:41:52 +03:00
|
|
|
set -xeuo pipefail
|
2021-10-18 15:12:31 +03:00
|
|
|
|
2022-04-18 12:35:14 +03:00
|
|
|
sign=(-u motiejus@jakstys.lt)
|
|
|
|
[[ $1 == "--nosign" ]] && { sign=(); shift; }
|
|
|
|
|
2021-10-18 15:12:31 +03:00
|
|
|
_err(){ >&2 echo "ERROR: $*"; exit 1; }
|
|
|
|
|
|
|
|
git status --porcelain | grep -q "" &&
|
|
|
|
_err "working tree is dirty, commit your changes first."
|
|
|
|
|
2021-12-13 03:26:23 +02:00
|
|
|
[[ "$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"
|
2021-10-18 15:12:31 +03:00
|
|
|
|
|
|
|
git tag | grep -q "^$1$" &&
|
|
|
|
_err "tag $1 already exists"
|
|
|
|
|
2023-03-06 11:11:44 +02:00
|
|
|
last_tag=$(git -c 'versionsort.suffix=-' tag -l --sort=v:refname | tail -1)
|
2021-10-18 15:12:31 +03:00
|
|
|
|
|
|
|
{
|
|
|
|
echo bazel-zig-cc "$1"
|
|
|
|
echo
|
|
|
|
echo Changelog since "$last_tag":
|
2022-04-09 00:18:46 +03:00
|
|
|
git log --pretty=format:"- [%an] %s" "$last_tag"..HEAD | \
|
|
|
|
grep -v "Update release notes for $last_tag"
|
2023-03-06 17:32:48 +02:00
|
|
|
} | git tag "${sign[@]+"${sign[@]}"}" -F - "$1"
|
2021-10-18 15:41:52 +03:00
|
|
|
|
|
|
|
shasum=$(git archive --prefix="bazel-zig-cc-$1/" --format=tar "$1" | \
|
|
|
|
gzip -n | sha256sum | cut -f1 -d" ")
|
|
|
|
|
2023-03-06 17:32:48 +02:00
|
|
|
./relnotes.awk -v tag="$1" -v sha256sum="$shasum" README.md > .README.md
|
|
|
|
mv .README.md README.md
|
2021-10-18 15:41:52 +03:00
|
|
|
|
|
|
|
git add README.md
|
|
|
|
git commit -m "Update release notes for $1"
|