Repository navigation
61 lines (54 loc) · 1.64 KB
/
Copy pathrelease.yml
File metadata and controls
61 lines (54 loc) · 1.64 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
name: Publish to Maven Central
on:
push:
tags:
- "*"
permissions:
contents: read
concurrency:
group: maven-central-publish
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Require tag to match pom version
run: |
version=$(python3 - <<'PY'
import xml.etree.ElementTree as ET
root = ET.parse("pom.xml").getroot()
print(root.findtext("{http://maven.apache.org/POM/4.0.0}version") or "")
PY
)
if [ -z "$version" ]; then
echo "::error::Could not read project version from pom.xml"
exit 1
fi
if [ "$version" != "$GITHUB_REF_NAME" ]; then
echo "::error::Tag '$GITHUB_REF_NAME' does not match pom version '$version'."
exit 1
fi
case "$version" in
*-SNAPSHOT)
echo "::error::Refusing to publish SNAPSHOT version '$version'."
exit 1
;;
esac
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
cache: maven
server-id: central
server-username: CENTRAL_USERNAME
server-password: CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Publish
run: ./mvnw -B deploy
env:
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}