-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (117 loc) · 4.33 KB
/
Copy pathrelease.yml
File metadata and controls
124 lines (117 loc) · 4.33 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Release
on:
push:
tags:
- 'v[0-9]*'
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
validate:
name: Validate release tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6
with:
distribution: temurin
java-version: '17'
cache: maven
- name: Require a main-branch SemVer tag matching the POM
shell: bash
run: |
if [[ ! "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Release tags must use vMAJOR.MINOR.PATCH" >&2
exit 1
fi
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
echo "Release tag must point to a commit on main" >&2
exit 1
fi
pom_version="$(mvn --batch-mode --no-transfer-progress -q \
help:evaluate -Dexpression=project.version -DforceStdout)"
if [[ "$pom_version" != "${GITHUB_REF_NAME#v}" ]]; then
echo "POM version $pom_version does not match tag $GITHUB_REF_NAME" >&2
exit 1
fi
verify:
name: Verify Java ${{ matrix.java-version }}
needs: validate
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java-version: ['17', '21', '25', '26']
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6
with:
distribution: temurin
java-version: ${{ matrix.java-version }}
cache: maven
- name: Verify SDK, examples, documentation, and package artifacts
run: mvn --batch-mode --no-transfer-progress verify
publish-central:
name: Publish to Maven Central
needs: verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Check Maven Central release credentials
env:
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
MAVEN_GPG_PRIVATE_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
run: |
if [[ -z "$CENTRAL_USERNAME" || -z "$CENTRAL_PASSWORD" || \
-z "$MAVEN_GPG_PRIVATE_KEY" || -z "$MAVEN_GPG_PASSPHRASE" ]]; then
echo "Configure the Central token and GPG signing secrets before tagging a release." >&2
exit 1
fi
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6
with:
distribution: temurin
java-version: '17'
cache: maven
server-id: central
server-username-env-var: CENTRAL_USERNAME
server-password-env-var: CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase-env-var: MAVEN_GPG_PASSPHRASE
- name: Publish signed SDK, sources, and Javadocs to Maven Central
run: mvn --batch-mode --no-transfer-progress -Pcentral-release deploy
env:
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: release-jars
path: target/*.jar
if-no-files-found: error
publish:
name: Create GitHub Release
needs: publish-central
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: release-jars
path: target
- name: Create GitHub Release with built artifacts
run: gh release create "$GITHUB_REF_NAME" target/*.jar --verify-tag --generate-notes --title "$GITHUB_REF_NAME"
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}