feat: Update release workflow for Maven Central deployment and enhance POM metadata

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
extio-de
2026-05-06 21:45:10 +02:00
parent cc19bcc87b
commit ec30026e02
3 changed files with 102 additions and 26 deletions

View File

@@ -1,22 +1,25 @@
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created # This workflow derives the next release version from the repository, tags it,
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path # updates the published release, and deploys the artifact to Maven Central.
name: Maven Package name: Release To Maven Central
on: on:
release: release:
types: [created] types: [published]
jobs: jobs:
build: publish:
if: ${{ !github.event.release.prerelease }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: write
packages: write
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.repository.default_branch }}
- name: Set up JDK 25 - name: Set up JDK 25
uses: actions/setup-java@v4 uses: actions/setup-java@v4
with: with:
@@ -27,12 +30,71 @@ jobs:
server-password: MAVEN_PASSWORD server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }} gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Set version - name: Configure Git
run: mvn versions:set -DnewVersion=${{ github.event.release.tag_name }} run: |
- name: Build with Maven git config user.name "github-actions[bot]"
run: mvn -B package --file pom.xml git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Calculate release version
id: version
shell: bash
run: |
set -euo pipefail
current_version="$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version | tail -n 1 | tr -d '\r')"
base_version="${current_version%-SNAPSHOT}"
if [[ ! "$base_version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
echo "Unsupported project version format: $current_version" >&2
exit 1
fi
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
release_version="${major}.$((minor + 1)).0"
echo "current_version=$current_version" >> "$GITHUB_OUTPUT"
echo "release_version=$release_version" >> "$GITHUB_OUTPUT"
echo "release_tag=$release_version" >> "$GITHUB_OUTPUT"
- name: Update release files
env:
RELEASE_VERSION: ${{ steps.version.outputs.release_version }}
run: |
set -euo pipefail
mvn -B versions:set -DnewVersion="$RELEASE_VERSION" -DgenerateBackupPoms=false
perl -0pi -e 's{<version>\d+\.\d+\.\d+</version>}{<version>'"$RELEASE_VERSION"'</version>}g' README.md
- name: Commit release version
env:
RELEASE_VERSION: ${{ steps.version.outputs.release_version }}
run: |
set -euo pipefail
git add pom.xml README.md
git commit -m "chore: release $RELEASE_VERSION"
git push origin HEAD:${{ github.event.repository.default_branch }}
- name: Create release tag
env:
RELEASE_TAG: ${{ steps.version.outputs.release_tag }}
run: |
set -euo pipefail
git tag "$RELEASE_TAG"
git push origin "$RELEASE_TAG"
- name: Retarget GitHub release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_ID: ${{ github.event.release.id }}
RELEASE_TAG: ${{ steps.version.outputs.release_tag }}
run: |
set -euo pipefail
gh api "repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}" \
--method PATCH \
-f tag_name="$RELEASE_TAG" \
-f target_commitish="${{ github.event.repository.default_branch }}" \
-f name="$RELEASE_TAG"
- name: Publish package - name: Publish package
run: mvn -P release --batch-mode deploy -DskipTests run: mvn -B -P release deploy -DskipTests
env: env:
MAVEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }} MAVEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }} MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}

View File

@@ -41,25 +41,13 @@ The current built-in client set supports both chat completions and legacy text c
## Setup ## Setup
The published artifacts are hosted in the external Maven repository, so consuming applications must add that repository in addition to Maven Central: The published artifacts are hosted on Maven Central, so no additional repository configuration is required:
```xml ```xml
<repositories>
<repository>
<id>spacecraft-tactics-releases</id>
<name>Spacecraft Tactics Repository</name>
<url>https://spacecraft-tactics.com/repository/releases</url>
</repository>
<repository>
<id>Central</id>
<url>https://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<dependency> <dependency>
<groupId>de.extio</groupId> <groupId>de.extio</groupId>
<artifactId>lm-lib</artifactId> <artifactId>lm-lib</artifactId>
<version>${lmlib.version}</version> <version>2.5.13</version>
</dependency> </dependency>
``` ```

26
pom.xml
View File

@@ -4,8 +4,34 @@
<artifactId>lm-lib</artifactId> <artifactId>lm-lib</artifactId>
<groupId>de.extio</groupId> <groupId>de.extio</groupId>
<name>lm-lib</name> <name>lm-lib</name>
<description>Modular Java library for LLM-powered applications, model clients, and agentic orchestration.</description>
<url>https://github.com/extio-de/lm-lib</url>
<version>2.5.13</version> <version>2.5.13</version>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>extio</id>
<name>extio</name>
<organization>extio</organization>
<organizationUrl>https://github.com/extio-de</organizationUrl>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/extio-de/lm-lib.git</connection>
<developerConnection>scm:git:ssh://git@github.com/extio-de/lm-lib.git</developerConnection>
<url>https://github.com/extio-de/lm-lib</url>
<tag>HEAD</tag>
</scm>
<properties> <properties>
<java.version>25</java.version> <java.version>25</java.version>
<maven.compiler.source>25</maven.compiler.source> <maven.compiler.source>25</maven.compiler.source>