-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (57 loc) · 1.85 KB
/
Copy pathrelease.yml
File metadata and controls
69 lines (57 loc) · 1.85 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
name: Release
on:
workflow_dispatch:
push:
tags:
- "v*"
permissions:
contents: read
jobs:
publish:
name: Publish to Maven Central
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up JDK 11
uses: actions/setup-java@v5
with:
java-version: "11"
distribution: temurin
cache: maven
server-id: central
server-username: CENTRAL_TOKEN_USERNAME
server-password: CENTRAL_TOKEN_PASSWORD
- name: Import GPG private key
shell: bash
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
set -euo pipefail
if [[ -z "${GPG_PRIVATE_KEY}" ]]; then
echo "::error::GPG_PRIVATE_KEY secret is empty"
exit 1
fi
key_file="$(mktemp)"
trap 'rm -f "${key_file}"' EXIT
if [[ "${GPG_PRIVATE_KEY}" == *"-----BEGIN PGP PRIVATE KEY BLOCK-----"* ]]; then
printf '%s' "${GPG_PRIVATE_KEY}" | sed 's/\\n/\n/g' > "${key_file}"
else
printf '%s' "${GPG_PRIVATE_KEY}" | base64 --decode > "${key_file}"
fi
gpg --batch --import "${key_file}"
gpg --batch --list-secret-keys --keyid-format LONG
- name: Build release artifacts
run: mvn --batch-mode clean verify -Dgpg.skip=true
- name: Upload release artifacts
uses: actions/upload-artifact@v7
with:
name: maven-artifacts
path: |
target/*.jar
target/*.pom
- name: Publish to Maven Central
run: mvn --batch-mode deploy -DskipTests
env:
CENTRAL_TOKEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
CENTRAL_TOKEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}