Skip to content
Merged
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
26 changes: 17 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Release

# Pushing a v* tag releases: the tag must match the project version and
# point at a commit on main.
on:
release:
types: [published]
push:
tags: ['v*']
workflow_dispatch:
inputs:
version:
Expand All @@ -16,27 +18,28 @@ permissions:
# Manual dry runs get their own group, so they can never displace a pending
# release (GitHub keeps only one pending run per group).
concurrency:
group: maven-central-${{ github.event_name == 'release' && 'release' || 'dry-run' }}
group: maven-central-${{ github.event_name == 'push' && 'release' || 'dry-run' }}
cancel-in-progress: false

jobs:
validate:
if: github.event_name == 'release' && github.event.release.prerelease == false
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
# github.sha is the tag's commit when the release was published, so a
# tag moved while this workflow runs cannot swap in untested code.
# github.sha is the tag's commit when it was pushed, so a tag moved
# while this workflow runs cannot swap in untested code.
- uses: actions/checkout@v6
with:
ref: ${{ github.sha }}
fetch-depth: 0
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
cache: maven
- name: Validate release tag
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
RELEASE_TAG: ${{ github.ref_name }}
run: |
VERSION="$(./mvnw -q -N org.apache.maven.plugins:maven-help-plugin:3.5.2:evaluate -Dexpression=project.version -DforceStdout)"
if [[ "$VERSION" == *-SNAPSHOT ]]; then
Expand All @@ -54,6 +57,11 @@ jobs:
echo "::error::Tag $RELEASE_TAG now points at ${TAGGED:-nothing}, not the released commit $GITHUB_SHA"
exit 1
fi
git fetch --no-tags origin +refs/heads/main:refs/remotes/origin/main
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
echo "::error::Tag $RELEASE_TAG points at $GITHUB_SHA, which is not on main"
exit 1
fi

build:
needs: validate
Expand All @@ -65,8 +73,8 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
# github.sha is the tag's commit when the release was published, so a
# tag moved while this workflow runs cannot swap in untested code.
# github.sha is the tag's commit when it was pushed, so a tag moved
# while this workflow runs cannot swap in untested code.
- uses: actions/checkout@v6
with:
ref: ${{ github.sha }}
Expand Down
Loading