Skip to content

quick fix, oops

quick fix, oops #7

Workflow file for this run

name: GitHub Release
on:
push:
branches:
- master
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Tag to release (example: v6.0.3)"
required: true
type: string
permissions:
contents: write
concurrency:
group: github-release
cancel-in-progress: false
jobs:
release:
name: Create release
runs-on: ubuntu-latest
env:
REQUESTED_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_type == 'tag' && github.ref_name || '' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ env.REQUESTED_TAG || github.sha }}
fetch-depth: 0
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "25"
cache: maven
- name: Resolve release metadata
id: metadata
shell: bash
run: |
VERSION="$(mvn -q help:evaluate -Dexpression=project.version -DforceStdout)"
VERSION="$(printf '%s' "${VERSION}" | tr -d '\r')"
if [[ -z "${VERSION}" || "${VERSION}" == *-SNAPSHOT ]]; then
echo "The Maven project version must be a non-SNAPSHOT release version." >&2
exit 1
fi
if [[ -n "${REQUESTED_TAG}" ]]; then
RELEASE_TAG="${REQUESTED_TAG}"
else
RELEASE_TAG="v${VERSION}"
fi
if [[ "${RELEASE_TAG}" != "v${VERSION}" ]]; then
echo "Tag ${RELEASE_TAG} does not match the Maven project version ${VERSION}." >&2
exit 1
fi
if [[ "${GITHUB_EVENT_NAME}" == "push" && "${GITHUB_REF_TYPE}" == "branch" ]] &&
git rev-parse --verify --quiet "refs/tags/${RELEASE_TAG}" >/dev/null; then
echo "Release tag ${RELEASE_TAG} already exists; nothing to publish." >> "${GITHUB_STEP_SUMMARY}"
echo "should_release=false" >> "${GITHUB_OUTPUT}"
exit 0
fi
CHANGELOG_FILE="changelog/${VERSION}.md"
echo "should_release=true" >> "${GITHUB_OUTPUT}"
echo "tag=${RELEASE_TAG}" >> "${GITHUB_OUTPUT}"
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
if [ -f "${CHANGELOG_FILE}" ]; then
echo "has_changelog=true" >> "${GITHUB_OUTPUT}"
echo "changelog_file=${CHANGELOG_FILE}" >> "${GITHUB_OUTPUT}"
else
echo "has_changelog=false" >> "${GITHUB_OUTPUT}"
fi
- name: Build release artifacts
if: steps.metadata.outputs.should_release == 'true'
run: mvn -B -ntp verify
- name: Create release tag
if: steps.metadata.outputs.should_release == 'true' && github.event_name == 'push' && github.ref_type == 'branch'
env:
RELEASE_TAG: ${{ steps.metadata.outputs.tag }}
RELEASE_VERSION: ${{ steps.metadata.outputs.version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag --annotate "${RELEASE_TAG}" --message "HeadDB ${RELEASE_VERSION}"
git push origin "${RELEASE_TAG}"
- name: Create release from changelog
if: steps.metadata.outputs.should_release == 'true' && steps.metadata.outputs.has_changelog == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.metadata.outputs.tag }}
name: HeadDB ${{ steps.metadata.outputs.version }}
body_path: ${{ steps.metadata.outputs.changelog_file }}
files: |
headdb-core/target/HeadDB-*.jar
headdb-legacy/target/HeadDB-*-legacy.jar
fail_on_unmatched_files: true
- name: Create release with generated notes
if: steps.metadata.outputs.should_release == 'true' && steps.metadata.outputs.has_changelog != 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.metadata.outputs.tag }}
name: HeadDB ${{ steps.metadata.outputs.version }}
generate_release_notes: true
files: |
headdb-core/target/HeadDB-*.jar
headdb-legacy/target/HeadDB-*-legacy.jar
fail_on_unmatched_files: true