|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +echo "Beginning" |
| 6 | +while [[ -n "${1-}" ]] ; do |
| 7 | + case "${1}" in |
| 8 | + --old-version*) |
| 9 | + OLD_VERSION=${1#*=} |
| 10 | + ;; |
| 11 | + --new-version*) |
| 12 | + NEW_VERSION=${1#*=} |
| 13 | + ;; |
| 14 | + --repository-username*) |
| 15 | + SONATYPE_USERNAME=${1#*=} |
| 16 | + ;; |
| 17 | + --repository-password*) |
| 18 | + SONATYPE_PASSWORD=${1#*=} |
| 19 | + ;; |
| 20 | + --signing-key*) |
| 21 | + GPG_SIGNING_KEY=${1#*=} |
| 22 | + ;; |
| 23 | + --signing-password*) |
| 24 | + GPG_SIGNING_PASSWORD=${1#*=} |
| 25 | + ;; |
| 26 | + *) |
| 27 | + echo "Unknown option '${1}'" |
| 28 | + exit 1 |
| 29 | + ;; |
| 30 | + esac |
| 31 | + shift |
| 32 | +done |
| 33 | + |
| 34 | +if [[ ! $OLD_VERSION =~ ^[0-9]*\.[0-9]*\.[0-9]*(-[A-Z0-9]*)?$ ]]; then |
| 35 | + echo "You have to provide the old version (without v-prefix, e.g. 0.14.0)" |
| 36 | + exit 1 |
| 37 | +fi |
| 38 | + |
| 39 | +if [[ ! $NEW_VERSION =~ ^[0-9]*\.[0-9]*\.[0-9]*(-[A-Z0-9]*)?$ ]]; then |
| 40 | + echo "You have to provide the new version (without v-prefix, e.g. 0.14.0)" |
| 41 | + exit 1 |
| 42 | +fi |
| 43 | + |
| 44 | +if [[ $(git rev-parse --abbrev-ref HEAD) != "release-$NEW_VERSION" ]]; then |
| 45 | + echo "You are not on the release branch \"release-$NEW_VERSION\", aborting..." |
| 46 | + exit 1 |
| 47 | +fi |
| 48 | + |
| 49 | +if [ -n "$(git status --porcelain)" ]; then |
| 50 | + echo "There are local, uncommitted changes, aborting..." |
| 51 | + exit 1 |
| 52 | +fi |
| 53 | + |
| 54 | +echo "Old version is $OLD_VERSION. Releasing version $NEW_VERSION..." |
| 55 | + |
| 56 | +echo Updating version in build.gradle, README.md and docs... |
| 57 | +sed -i -e s/version\ =.*/version\ =\ \'$NEW_VERSION\'/ build.gradle |
| 58 | +sed -i -e s/$OLD_VERSION/$NEW_VERSION/ README.md ./docs/_data/navigation.yml ./docs/_pages/getting-started.md |
| 59 | + |
| 60 | +echo Create release news... |
| 61 | +./gradlew createReleaseNews |
| 62 | + |
| 63 | +if [ -n "$(git status --porcelain)" ]; then |
| 64 | + echo Commiting version change |
| 65 | + git add build.gradle README.md ./docs -- ':!docs/**.png' |
| 66 | + git commit -m "Update version to $VERSION" |
| 67 | +fi |
| 68 | + |
| 69 | +echo Publishing ArchUnit... |
| 70 | +./gradlew clean publishArchUnit --no-parallel -PsonatypeUsername="$SONATYPE_USERNAME" -PsonatypePassword="$SONATYPE_PASSWORD" -PsigningKey="$GPG_SIGNING_KEY" -PsigningPassword="$GPG_SIGNING_PASSWORD" |
| 71 | + |
| 72 | +git checkout main |
| 73 | +git merge release-"$NEW_VERSION" |
| 74 | +git push |
0 commit comments