Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Release
on: [ workflow_dispatch ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -17,6 +19,9 @@ jobs:
publish:
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v7
Expand Down
20 changes: 20 additions & 0 deletions github-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ getVersion() {
grep -m1 -o "<version>.*</version>$" pom.xml | awk -F'[><]' '{print $3}'
}

requireSnapshot() {
local APP_VERSION=$(getVersion)
if [[ ${APP_VERSION} != *-SNAPSHOT ]]; then
echo "Version in pom.xml must end with -SNAPSHOT to be released: '${APP_VERSION}'"
exit 1
fi
}

removeSnapshots() {
sed -i 's/-SNAPSHOT//' pom.xml
}
Expand All @@ -15,6 +23,15 @@ commitRelease() {
git tag -a "v${APP_VERSION}" -m "Tag release version"
}

publishTag() {
local APP_VERSION=$(getVersion)
git push origin "v${APP_VERSION}"
# Release tags aren't on master's first-parent history, so GitHub can't find the previous one on its own
local PREVIOUS_TAG=$(gh release view --json tagName --jq .tagName)
gh release create "v${APP_VERSION}" --verify-tag --draft --generate-notes --notes-start-tag "${PREVIOUS_TAG}" --title "v${APP_VERSION}" \
|| echo "::warning::Draft release for v${APP_VERSION} was not created, create it manually"
}

bumpVersion() {
echo "Bump version number"
local APP_VERSION=$(getVersion | xargs)
Expand Down Expand Up @@ -43,11 +60,14 @@ commitNextVersion() {
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"

requireSnapshot

echo "Deploying release to Maven Central"
removeSnapshots

mvn --batch-mode -Prelease deploy

commitRelease
publishTag
bumpVersion
commitNextVersion
Loading