-
Notifications
You must be signed in to change notification settings - Fork 76
71 lines (67 loc) · 2.25 KB
/
Copy pathrelease.yml
File metadata and controls
71 lines (67 loc) · 2.25 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
name: Release to Maven Central
on:
workflow_dispatch:
inputs:
mode:
description: Verify the release build or upload a signed bundle for manual publishing
required: true
default: verify
type: choice
options:
- verify
- upload
permissions:
contents: read
jobs:
verify:
if: inputs.mode == 'verify'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '8'
cache: maven
- run: mvn --batch-mode --no-transfer-progress clean verify
upload:
if: inputs.mode == 'upload'
runs-on: ubuntu-latest
environment: maven-central
steps:
- name: Require a release tag
shell: bash
run: |
if [[ "${GITHUB_REF_TYPE}" != "tag" || "${GITHUB_REF_NAME}" != v* ]]; then
echo "Upload mode must be dispatched from a v* release tag." >&2
exit 1
fi
- uses: actions/checkout@v7
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '8'
cache: maven
server-id: central
server-username: CENTRAL_USERNAME
server-password: CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Confirm a non-SNAPSHOT project version
shell: bash
run: |
project_version="$(mvn --quiet help:evaluate -Dexpression=project.version -DforceStdout)"
if [[ "${project_version}" == *-SNAPSHOT ]]; then
echo "Refusing to upload SNAPSHOT version ${project_version}." >&2
exit 1
fi
if [[ "${GITHUB_REF_NAME}" != "v${project_version}" ]]; then
echo "Tag ${GITHUB_REF_NAME} does not match project version ${project_version}." >&2
exit 1
fi
- name: Upload signed bundle for Central validation
run: mvn --batch-mode --no-transfer-progress clean deploy -Prelease
env:
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}