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
54 changes: 43 additions & 11 deletions .github/publish-maven-package.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# 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: Publish Maven Package
name: Updated repository in packages branch

on:
workflow_dispatch:
Expand All @@ -14,7 +11,7 @@ jobs:

runs-on: ubuntu-latest
permissions:
contents: read
contents: write
packages: write

steps:
Expand All @@ -27,10 +24,45 @@ jobs:
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: Compile Groovy code
run: mvn gplus:compile
- name: Compile Groovy code and generate sources
run: mvn gplus:compile generate-sources package


#Manually first (once) set up an orphaned branch:
# git switch --orphan packages
# git commit --allow-empty -m "Initial commit on packages branch"
# git push origin packages:packages

- name: Install Package to packages branch
run: |
MAINJAR=$(ls -1 target/*.jar | grep -v sources\.jar)
SOURCEJAR=$(ls -1 target/*.jar | grep sources\.jar)
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo Main JAR: $MAINJAR
echo Source JAR: $SOURCEJAR
echo Version: $VERSION
mkdir -p repository
echo Installing JAR in repository directory
mvn install:install-file -DpomFile=pom.xml -DlocalRepositoryPath=repository/ -Dfile="$MAINJAR" -Dsources="$SOURCEJAR" -DgeneratePom=true -DcreateChecksum=true

git config user.name github-actions
git config user.email github-actions@github.com
echo Adding repository dir temporarily so stash picks it up
git add repository
echo Stashing current changes
git stash
echo Running git fetch
git fetch
echo Checking out Packages repo
git checkout packages
echo Applying stash, overwriting any checked out changes
git checkout stash -- .
echo Running git reset, to ignore any automatically added tracked changes
git reset
echo Adding repository files to git
git add repository/*
echo Committing changes
git commit -m "Updated packages to $VERSION"
echo Pushing changes
git push

- name: Publish Package to Github Maven Repo
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}