Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
Add release tagging script.
Browse files Browse the repository at this point in the history
Signed-off-by: James Peach <[email protected]>
  • Loading branch information
jpeach committed Jan 3, 2021
1 parent e4b8897 commit 00ba86c
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions hack/make-release-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#! /usr/bin/env bash

# make-release-tag.sh: Tag main with a release version.

readonly PROGNAME=$(basename "$0")
readonly OLDVERS="$1"
readonly NEWVERS="$2"

if [ -z "$OLDVERS" ] || [ -z "$NEWVERS" ]; then
printf "Usage: %s OLDVERS NEWVERS\n" "$PROGNAME"
exit 1
fi

set -o errexit
set -o nounset
set -o pipefail

git tag -F - "$NEWVERS" <<EOF
Tag $NEWVERS release.
$(git shortlog "$OLDVERS..HEAD")
EOF

printf "Created tag '%s'\n" "$NEWVERS"

# People set up their remotes in different ways, so we need to check
# which one to dry run against. Choose a remote name that pushes to the
# projectcontour org repository (i.e. not the user's Github fork).
readonly REMOTE=$(git remote -v | awk '$2~/projectcontour\/lint/ && $3=="(push)" {print $1}' | head -n 1)
if [ -z "$REMOTE" ]; then
printf "%s: unable to determine remote for %s\n" "$PROGNAME" "projectcontour/lint"
exit 1
fi

readonly BRANCH=$(git branch --show-current)

printf "Testing whether commit can be pushed\n"
git push --dry-run "$REMOTE" "$BRANCH"

printf "Testing whether tag '%s' can be pushed\n" "$NEWVERS"
git push --dry-run "$REMOTE" "$NEWVERS"

printf "Run 'git push %s %s' to push the commit and then 'git push %s %s' to push the tag if you are happy\n" "$REMOTE" "$BRANCH" "$REMOTE" "$NEWVERS"

0 comments on commit 00ba86c

Please sign in to comment.