-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (86 loc) · 3.61 KB
/
ci-java.yml
File metadata and controls
97 lines (86 loc) · 3.61 KB
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
name: Build, Publish, & Deploy Java Package
on:
push:
branches:
- main
paths:
- "java/**"
workflow_dispatch:
jobs:
build-java:
name: Build and Publish Java Package
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_TOKEN }}
defaults:
run:
working-directory: java
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 21
cache: "maven"
- name: Generate dynamic Maven settings.xml
run: |
cat > "$RUNNER_TEMP/settings.xml" <<'EOF'
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
<servers>
<server>
<id>wyrmlings-repository-releases</id>
<username>${env.NEXUS_USERNAME}</username>
<password>${env.NEXUS_PASSWORD}</password>
</server>
<server>
<id>wyrmlings-repository-snapshots</id>
<username>${env.NEXUS_USERNAME}</username>
<password>${env.NEXUS_PASSWORD}</password>
</server>
</servers>
</settings>
EOF
- name: Read Version
id: version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "value=$VERSION" >> $GITHUB_OUTPUT
- name: Generate Changelog
id: changelog
run: |
TAG="java-v${{ steps.version.outputs.value }}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
LOG=$(git log "$TAG"..HEAD --oneline -- ../java)
else
LOG=$(git log --oneline -20 -- ../java)
fi
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "body<<$EOF" >> $GITHUB_OUTPUT
echo "$LOG" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: java-v${{ steps.version.outputs.value }}
name: Java v${{ steps.version.outputs.value }}
body: |
## Java Package v${{ steps.version.outputs.value }}
${{ steps.changelog.outputs.body }}
files: |
java/target/pacts-${{ steps.version.outputs.value }}.jar
java/target/pacts-${{ steps.version.outputs.value }}-sources.jar
java/target/pacts-${{ steps.version.outputs.value }}-javadoc.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Sonatype Nexus
run: mvn -B deploy --file pom.xml -s "$RUNNER_TEMP/settings.xml"