Skip to content

Commit d558695

Browse files
authored
Working on packaging (#2)
* Major work, most of the things for JSMH2 Deployment is working but untested * Added basic jsm example script * Added repo for JirInstanceManagerRest * Updated POM to generate sources * Updated action to build and publish package
1 parent fae85a8 commit d558695

1 file changed

Lines changed: 43 additions & 11 deletions

File tree

.github/publish-maven-package.yml

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
2-
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
3-
4-
name: Publish Maven Package
1+
name: Updated repository in packages branch
52

63
on:
74
workflow_dispatch:
@@ -14,7 +11,7 @@ jobs:
1411

1512
runs-on: ubuntu-latest
1613
permissions:
17-
contents: read
14+
contents: write
1815
packages: write
1916

2017
steps:
@@ -27,10 +24,45 @@ jobs:
2724
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
2825
settings-path: ${{ github.workspace }} # location for the settings.xml file
2926

30-
- name: Compile Groovy code
31-
run: mvn gplus:compile
27+
- name: Compile Groovy code and generate sources
28+
run: mvn gplus:compile generate-sources package
29+
30+
31+
#Manually first (once) set up an orphaned branch:
32+
# git switch --orphan packages
33+
# git commit --allow-empty -m "Initial commit on packages branch"
34+
# git push origin packages:packages
35+
36+
- name: Install Package to packages branch
37+
run: |
38+
MAINJAR=$(ls -1 target/*.jar | grep -v sources\.jar)
39+
SOURCEJAR=$(ls -1 target/*.jar | grep sources\.jar)
40+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
41+
echo Main JAR: $MAINJAR
42+
echo Source JAR: $SOURCEJAR
43+
echo Version: $VERSION
44+
mkdir -p repository
45+
echo Installing JAR in repository directory
46+
mvn install:install-file -DpomFile=pom.xml -DlocalRepositoryPath=repository/ -Dfile="$MAINJAR" -Dsources="$SOURCEJAR" -DgeneratePom=true -DcreateChecksum=true
47+
48+
git config user.name github-actions
49+
git config user.email github-actions@github.com
50+
echo Adding repository dir temporarily so stash picks it up
51+
git add repository
52+
echo Stashing current changes
53+
git stash
54+
echo Running git fetch
55+
git fetch
56+
echo Checking out Packages repo
57+
git checkout packages
58+
echo Applying stash, overwriting any checked out changes
59+
git checkout stash -- .
60+
echo Running git reset, to ignore any automatically added tracked changes
61+
git reset
62+
echo Adding repository files to git
63+
git add repository/*
64+
echo Committing changes
65+
git commit -m "Updated packages to $VERSION"
66+
echo Pushing changes
67+
git push
3268
33-
- name: Publish Package to Github Maven Repo
34-
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
35-
env:
36-
GITHUB_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)