Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Package to GitHub Packages | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: # Allows manual triggering from the Actions tab | |
jobs: | |
publish: | |
name: Publish to GitHub Packages | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write # Needed to publish packages | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true # Ensure submodules are checked out if needed | |
- name: Set up JDK 8 and Configure Maven Settings | |
uses: actions/setup-java@v4 | |
with: | |
java-version: "8" | |
distribution: "zulu" | |
cache: maven | |
server-id: github # Id of the publication repository field in the pom.xml | |
settings-path: ${{ github.workspace }} # path for settings.xml with generated authentication info | |
- name: Display generated Maven settings.xml for debugging | |
run: | | |
echo "Maven settings.xml:" | |
cat ${{ github.workspace }}/settings.xml || echo "settings.xml not found or empty." | |
echo "env:" | |
env | |
- name: Verify Project Version is not a SNAPSHOT (on release event only) | |
if: github.event_name == 'release' # Only run this check for actual releases | |
run: | | |
PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
echo "Checking project version: $PROJECT_VERSION for release trigger." | |
if [[ "$PROJECT_VERSION" == *"-SNAPSHOT"* ]]; then | |
echo "Error: Attempting to deploy a SNAPSHOT version ($PROJECT_VERSION) on a release event. Aborting." | |
exit 1 | |
fi | |
echo "Project version $PROJECT_VERSION is a valid release version. Proceeding..." | |
- name: Publish package | |
run: mvn --batch-mode deploy -DskipTests=true -s ${{ github.workspace }}/settings.xml | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Provided by Actions, used for authentication |