Skip to content

Commit faeab99

Browse files
Nils-Oliver Lindencodecholeric
authored andcommitted
add script to execute all necessary commands for releasing ArchUnit
This script can be executed by a GitHub action to release ArchUnit. This will fully automate the release process, removing the last possibly error-prone manual steps we had documented so far. Signed-off-by: Nils-Oliver Linden <nils-oliver.linden@tngtech.com>
1 parent ed88c55 commit faeab99

2 files changed

Lines changed: 77 additions & 0 deletions

File tree

build-steps/release/publish.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,6 @@ releaseProjects*.with {
9292
sign publishing.publications.mavenJava
9393
}
9494
}
95+
96+
task publishArchUnit(dependsOn: [closeSonatypeStagingRepository, releaseSonatypeStagingRepository])
97+
releaseProjects.each { publishArchUnit.dependsOn("${it.name}:publishToSonatype") }

release/release.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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

Comments
 (0)