-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (81 loc) · 3.38 KB
/
maven-publish-on-push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# 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#apache-maven-with-a-settings-path
name: Maven Publish Master On Push
on:
push:
branches:
- master
tags:
- "*"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17 for Github deployment
uses: actions/setup-java@v4
with:
java-version: 17
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: Read Maven project version
id: read_version
run: |
version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "version=${version}" >> $GITHUB_OUTPUT
- name: Check version properties
id: check_release
run: |
version="${{ steps.read_version.outputs.version }}"
if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT$ ]]; then
echo "is_snapshot=true" >> $GITHUB_OUTPUT
else
echo "is_snapshot=false" >> $GITHUB_OUTPUT
fi
if [[ ${{ github.ref }} == 'refs/tags/'* ]]; then
echo "has_tag=true" >> $GITHUB_OUTPUT
else
echo "has_tag=false" >> $GITHUB_OUTPUT
fi
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Publish to GitHub Packages Apache Maven
if: steps.check_release.outputs.is_snapshot == 'true' || steps.check_release.outputs.is_snapshot == 'false' && steps.check_release.outputs.has_tag == 'true'
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Set up JDK 17 for NERZ-Snapshot-Deployment
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
server-id: nerz-snapshots
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Publish Snapshots to NERZ Nexus
if: steps.check_release.outputs.is_snapshot == 'true'
run: |
echo "Ist ein Snapshot: ${{ steps.check_release.outputs.is_snapshot }} und hat einen Tag ${{ steps.check_release.outputs.has_tag }}"
mvn deploy -P nerz
env:
MAVEN_USERNAME: ${{ secrets.NERZ_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.NERZ_TOKEN }}
- name: Set up JDK 17 for NERZ-Release-Deployment
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
server-id: nerz-releases
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Publish Releases to NERZ Nexus
if: steps.check_release.outputs.is_snapshot == 'false' && steps.check_release.outputs.has_tag == 'true'
run: |
echo "Ist ein Snapshot: ${{ steps.check_release.outputs.is_snapshot }}"
mvn deploy -P nerz
env:
MAVEN_USERNAME: ${{ secrets.NERZ_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.NERZ_TOKEN }}