Skip to content

Added GitHub workflow #2

Added GitHub workflow

Added GitHub workflow #2

Workflow file for this run

# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
name: Maven Package Publish
on:
workflow_dispatch:
push:
tags:
- 'v[0-9]+\.[0-9]+\.[0-9]+' # Match major version tags
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Extract Maven project version
run: echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT
id: maven_version
- name: Extract Maven project JDK version
run: echo "jdk=$(mvn -q -Dexec.executable=echo -Dexec.args='${maven.compiler.release}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT
id: maven_jdk
- name: Get current date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
id: date
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ steps.maven_jdk.outputs.jdk }}
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
makeLatest: true
tag: v${{ steps.maven_version.outputs.version }}
name: v${{ steps.maven_version.outputs.version }}
body: |
## [v${{ steps.maven_version.outputs.version }}] - ${{ steps.date.outputs.date }}
---
Automated release for version ${{ steps.maven_version.outputs.version }}.