Skip to content

Commit

Permalink
touch up release script
Browse files Browse the repository at this point in the history
  • Loading branch information
pcal43 committed Sep 6, 2022
1 parent 9602938 commit dc87128
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# simple stuff like this.
#

set -eu

if [ -n "$(git status --porcelain)" ]; then
echo "Working directory not clean, cannot release"
exit 1
Expand All @@ -18,6 +20,7 @@ if [ "${CURRENT_BRANCH}" != 'main' ]; then
exit 1
fi


CURRENT_VERSION=$(sed -rn 's/^mod_version.*=[ ]*([^\n]+)$/\1/p' gradle.properties)
echo "Current version is '$CURRENT_VERSION'"

Expand All @@ -27,17 +30,20 @@ if [ $CURRENT_VERSION = $RELEASE_VERSION ]; then
exit 1
fi
echo "Release version will be '$RELEASE_VERSION'"
sed -ie "s/^mod_version =.*/mod_version = $RELEASE_VERSION/" gradle.properties

git commit -am "Release ${RELEASE_VERSION}"
git tag "${RELEASE_VERSION}"
git push --tags
sed "s/^mod_version =.*/mod_version = $RELEASE_VERSION/" gradle.properties > gradle.properties.temp
rm gradle.properties
mv gradle.properties.temp gradle.properties

rm -rf build/libs
./gradlew remapJar


git commit -am "Release ${RELEASE_VERSION}"
#git tag "${RELEASE_VERSION}"
git push

# this is always creating a draft release for some reason
gh release create ${RELEASE_VERSION} build/libs/ --title "${RELEASE_VERSION}" --notes "release ${RELEASE_VERSION}"
gh release create --title "${RELEASE_VERSION}" --notes "release ${RELEASE_VERSION}" ${RELEASE_VERSION} build/libs/*

BUILD_METADATA=$(echo ${RELEASE_VERSION} | awk '{split($NF,v,/[+]/); $NF=v[2]}1')
BUILD_METADATA="${BUILD_METADATA}-prerelease"
Expand All @@ -46,6 +52,9 @@ NEXT_MOD_VERSION=$(echo ${RELEASE_VERSION} | awk '{split($NF,v,/[.]/); $NF=v[1]"
NEXT_VERSION="${NEXT_MOD_VERSION}+${BUILD_METADATA}"
echo "Next version is ${NEXT_VERSION}"

sed -ie "s/^mod_version =.*/mod_version = $NEXT_VERSION/" gradle.properties
sed "s/^mod_version =.*/mod_version = $NEXT_VERSION/" gradle.properties > gradle.properties.temp
rm gradle.properties
mv gradle.properties.temp gradle.properties

git commit -am "Prepare for next version ${NEXT_VERSION}"
git push

0 comments on commit dc87128

Please sign in to comment.