-
Notifications
You must be signed in to change notification settings - Fork 1
73 lines (70 loc) · 2.66 KB
/
Copy pathpublish-maven-central.yml
File metadata and controls
73 lines (70 loc) · 2.66 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
name: Publish Maven Central
on:
workflow_dispatch:
inputs:
auto_publish:
description: "Automatically publish after validation (true/false)"
required: true
default: "false"
wait_until:
description: "Central wait mode (uploaded/validated/published)"
required: true
default: "validated"
push:
tags:
- "v*"
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
env:
CENTRAL_PORTAL_USERNAME: ${{ secrets.CENTRAL_PORTAL_USERNAME }}
CENTRAL_PORTAL_PASSWORD: ${{ secrets.CENTRAL_PORTAL_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21 + Maven server credentials + GPG key
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "temurin"
cache: maven
server-id: central
server-username: CENTRAL_PORTAL_USERNAME
server-password: CENTRAL_PORTAL_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Validate required secrets
run: |
test -n "$CENTRAL_PORTAL_USERNAME" || (echo "Missing CENTRAL_PORTAL_USERNAME" && exit 1)
test -n "$CENTRAL_PORTAL_PASSWORD" || (echo "Missing CENTRAL_PORTAL_PASSWORD" && exit 1)
test -n "$GPG_PASSPHRASE" || (echo "Missing GPG_PASSPHRASE" && exit 1)
test -n "$MAVEN_GPG_PASSPHRASE" || (echo "Missing MAVEN_GPG_PASSPHRASE" && exit 1)
- name: Publish to Maven Central
run: |
EVENT_NAME="${{ github.event_name }}"
if [ "$EVENT_NAME" = "push" ]; then
AUTO_PUBLISH="true"
# Central queues can exceed 30m on busy windows; wait only for validation in CI
# and let Central complete publish asynchronously.
WAIT_UNTIL="validated"
else
AUTO_PUBLISH="${{ github.event.inputs.auto_publish }}"
WAIT_UNTIL="${{ github.event.inputs.wait_until }}"
if [ -z "$AUTO_PUBLISH" ]; then
AUTO_PUBLISH="false"
fi
if [ -z "$WAIT_UNTIL" ]; then
WAIT_UNTIL="validated"
fi
fi
echo "central.auto.publish=$AUTO_PUBLISH"
echo "central.wait.until=$WAIT_UNTIL"
mvn -B -Pcentral-release -DskipTests \
-Dcentral.auto.publish="$AUTO_PUBLISH" \
-Dcentral.wait.until="$WAIT_UNTIL" \
-Dcentral.wait.max.time="PT120M" \
-Dcentral.wait.poll.interval="PT15S" \
deploy --file pom.xml