Skip to content

Commit d5a8a84

Browse files
authored
Merge pull request #315 from FromDoppler/doi-2525-modify-maven-workflow
[DOI-2525] Modify workflow to store maven packages as release assets
2 parents 40936ce + 9c0a3d8 commit d5a8a84

1 file changed

Lines changed: 59 additions & 3 deletions

File tree

.github/workflows/continuous-delivery-maven-package.yml

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ name: Maven Build and Publish
66
on:
77
workflow_call:
88

9+
env:
10+
TZ: America/Argentina/Jujuy
11+
MAVEN_USER_HOME: ${{ github.workspace }}/.maven
12+
913
jobs:
1014
build:
1115
runs-on: ubuntu-latest
1216

1317
permissions:
1418
contents: read
1519
packages: write
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1622

1723
steps:
1824
- name: Checkout repository
@@ -32,10 +38,60 @@ jobs:
3238
run: |
3339
sudo timedatectl set-timezone America/Argentina/Jujuy
3440
35-
- name: Build and deploy
41+
- name: Ensure Maven repository folder exists
42+
run: mkdir -p "$MAVEN_USER_HOME"
43+
44+
- name: Build jar and populate local repo
3645
env:
37-
MAVEN_USER_HOME: ${{ github.workspace }}/.maven
3846
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3947
run: |
4048
chmod +x mvnw
41-
./mvnw -ntp clean deploy -Dmaven.repo.local="$MAVEN_USER_HOME"
49+
./mvnw -ntp clean install -Dmaven.repo.local=$MAVEN_USER_HOME --batch-mode
50+
51+
- name: Bundle offline Maven repo
52+
run: |
53+
mkdir -p dist
54+
zip -r dist/library-maven-repo.zip "$MAVEN_USER_HOME"
55+
56+
- name: Upload jar artifact
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: library-jar
60+
path: "**/target/*.jar"
61+
if-no-files-found: error
62+
63+
- name: Upload Maven repo bundle
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: library-maven-repo
67+
path: dist/library-maven-repo.zip
68+
if-no-files-found: error
69+
release:
70+
name: Publish release asset
71+
needs: build
72+
if: startsWith(github.ref, 'refs/tags/')
73+
runs-on: ubuntu-latest
74+
permissions:
75+
contents: write
76+
77+
steps:
78+
- name: Download jar artifact
79+
uses: actions/download-artifact@v4
80+
with:
81+
name: library-jar
82+
path: dist
83+
84+
- name: Download Maven repo bundle
85+
uses: actions/download-artifact@v4
86+
with:
87+
name: library-maven-repo
88+
path: dist
89+
90+
- name: Create GitHub Release and attach jar
91+
uses: softprops/action-gh-release@v1
92+
with:
93+
tag_name: ${{ github.ref_name }}
94+
name: ${{ github.ref_name }}
95+
files: |
96+
dist/**/*.jar
97+
dist/**/*.zip

0 commit comments

Comments
 (0)