make preview and release tag based

This commit is contained in:
Jonathan Shook 2023-01-23 21:18:53 -06:00
parent 027fc4a895
commit 0ae3bd0852
7 changed files with 98 additions and 11 deletions

View File

@ -9,8 +9,8 @@ on:
push:
branches:
- main
paths:
- PREVIEW_NOTES.md
tags:
- "[0-9]+.[0-9]+.[0-9]+-release"
jobs:
release:

View File

@ -7,10 +7,10 @@ name: release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+-release"
branches:
- main
paths:
- RELEASE_NOTES.**
jobs:
release:

View File

@ -18,5 +18,37 @@
set -e
export REVISION=$(mvn help:evaluate -Dexpression=revision -q -DforceStdout)
export PRERELEASE_REVISION=$(echo "${REVISION}" | cut -d'-' -f1)
printf "%s-preview\n" "${PRERELEASE_REVISION}"
if [[ $REVISION =~ ([0-9]+)\.([0-9]+)\.([0-9]+)-SNAPSHOT ]]
then
printf "The revision matches the format, continuing\n" 1>&2
set -- "${BASH_REMATCH[@]}"
VERSION_STRING="${@:2:3}"
else
printf "The revision format for '${REVISION}' does not match #.#.#-SNAPSHOT form. bailing out\n"
exit 3
fi
export TAG=$(git describe --exact-match --tags)
if [[ $TAG =~ ([0-9]+)\.([0-9]+)\.([0-9]+)(-preview)? ]]
then
printf "The tag format matches the version, continuing\n" 1>&2
set -- "${BASH_REMATCH[@]}"
TAG_STRING="${@:2:3}"
else
printf "The tag format for '${TAG}' does not match #.#.#-preview form. bailing out\n" 1>&2
exit 4
fi
printf "version(${VERSION_STRING}) tag(${TAG_STRING})\n" 1>&2
if [ "${VERSION_STRING}" == "${TAG_STRING}" ]
then
printf "version and tag match, continuing\n" 1>&2
else
printf "version and tag do not match: bailing out\n" 1>&2
exit 5
fi
printf "%s.%s.%s-preview\n" "${@:2:3}"

View File

@ -18,5 +18,37 @@
set -e
export REVISION=$(mvn help:evaluate -Dexpression=revision -q -DforceStdout)
export PRERELEASE_REVISION=$(echo "${REVISION}" | cut -d'-' -f1)
printf "%s\n" "${PRERELEASE_REVISION}"
if [[ $REVISION =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)-SNAPSHOT$ ]]
then
printf "The revision matches the format, continuing\n" 1>&2
set -- "${BASH_REMATCH[@]}"
VERSION_STRING="${@:2:3}"
else
printf "The revision format for '${REVISION}' does not match #.#.#-SNAPSHOT form. bailing out\n"
exit 3
fi
export TAG=$(git describe --exact-match --tags)
if [[ $TAG =~ ([0-9]+)\.([0-9]+)\.([0-9]+)(-release)? ]]
then
printf "The tag format matches the version, continuing\n" 1>&2
set -- "${BASH_REMATCH[@]}"
TAG_STRING="${@:2:3}"
else
printf "The tag format for '${TAG}' does not match #.#.#-release form. bailing out\n" 1>&2
exit 4
fi
printf "version(${VERSION_STRING}) tag(${TAG_STRING})\n" 1>&2
if [ "${VERSION_STRING}" == "${TAG_STRING}" ]
then
printf "version and tag match, continuing\n" 1>&2
else
printf "version and tag do not match: bailing out\n" 1>&2
exit 5
fi
printf "%s.%s.%s-release\n" "${@:2:3}"

View File

@ -1,14 +1,17 @@
#!/bin/bash
set -e
#RELEASE_NOTES_FILE=${RELEASE_NOTES_FILE:?RELEASE_NOTES_FILE must be provided}
git log --oneline --decorate --max-count=1000 > /tmp/gitlog.txt
readarray lines < /tmp/gitlog.txt
for line in "${lines[@]}"
do
if [[ $line =~ \(tag:\ nosqlbench-[0-9]+\.[0-9]+\.[0-9]+\).+ ]]
printf "line: %s\n" "${line}"
if [[ $line =~ \(tag:\ ([a-zA-z0-9]+-)?[0-9]+\.[0-9]+\.[0-9]+\)-preview.+ ]]
then
echo "PREVIEW"
elif [[ $line =~ \(tag:\ ([a-zA-Z0-9]+-)?[0-9]+\.[0-9]+\.[0-9]+\).+ ]]
then
echo "RELEASE"
# printf "no more lines after $line" 1>&2
break
elif [[ $line =~ \[maven-release-plugin\] ]]

10
scripts/tag-preview-build Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
cd mvn-defaults
set -x
CURRENT_VERSION=$(mvn help:evaluate -Dexpression=revision -q -DforceStdout)
RELEASE_VERSION=${CURRENT_VERSION%%-SNAPSHOT}
PREVIEW_TAG="${RELEASE_VERSION}-preview"
printf "preview tag: '%s'\n" "${PREVIEW_TAG}"
git tag "${PREVIEW_TAG}"

10
scripts/tag-release-build Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
cd mvn-defaults
set -x
CURRENT_VERSION=$(mvn help:evaluate -Dexpression=revision -q -DforceStdout)
RELEASE_VERSION=${CURRENT_VERSION%%-SNAPSHOT}
RELEASE_TAG="${RELEASE_VERSION}-release"
printf "release tag: '%s'\n" "${RELEASE_TAG}"
git tag "${RELEASE_TAG}"