Skip to content

Releases are published to Maven Central through the Central Portal from a GitHub release #50

Releases are published to Maven Central through the Central Portal from a GitHub release

Releases are published to Maven Central through the Central Portal from a GitHub release #50

Workflow file for this run

name: Check that version is updated
on:
pull_request:
branches: [ master ]
jobs:
CheckVersionAndReleaseNote:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
# The pull request's merge commit, with the base branch as its first parent
- uses: actions/checkout@v4
with:
fetch-depth: 2
# A released version can't change, so changes to the published library need a version that isn't released
# yet. Other changes, such as to docs, tests and CI, need no new version.
- name: Version check
run: |
changed=$(git diff --name-only HEAD^1 HEAD -- src/main build.gradle)
if [ -z "$changed" ]; then
echo "The published library is unchanged, so no new version is needed"
exit 0
fi
# A released version is known by its release tag, v<version>. Maven Central can't be asked reliably, as it
# rate limits the IP addresses that GitHub's runners share
version=$(sed -n 's/^version=//p' gradle.properties)
if git ls-remote --exit-code --tags origin "refs/tags/v$version" > /dev/null; then
echo "::error file=gradle.properties::Version $version is already released, update the version in gradle.properties"
echo "The published library changes in:"
echo "$changed"
exit 1
elif [ $? -ne 2 ]; then
echo "::error::Could not list the release tags to check whether version $version is released"
exit 1
fi
echo "Version $version is not released yet, so it can include the changes to:"
echo "$changed"