-
Notifications
You must be signed in to change notification settings - Fork 5
70 lines (62 loc) · 2.49 KB
/
publish.yml
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
name: Publish
on:
release:
types: [ published ]
workflow_dispatch:
inputs:
versionTag:
type: string
description: Version tag to use for the Maven JAR, e.g. "v1.0.12", "1.1.0-rc1" (no quotes)
required: true
releaseType:
description: 'Release type'
required: true
default: 'prerelease'
type: choice
options:
- prerelease
- release
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_and_publish:
name: Build and Publish Jar
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get version tag
run: |
# Default to using the tag from the release event for the version string, stripping the prefix
VERSION=$( echo ${{ github.event.release.tag_name }} | sed -e 's/^v//' )
# If there is no associated release event, use the input version string, still stripping the prefix
if [ "$VERSION" == "" ] ; then
VERSION=$( echo ${{ github.event.inputs.versionTag }} | sed -e 's/^v//' )
fi
# Store version for later use.
echo "VERSION=$VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
- name: Build with Gradle
run: ./gradlew clean build --refresh-dependencies -Pversion=$VERSION
- name: Install gpg secret key
run: |
export GPG_TTY=$(tty)
echo -n "${{ secrets.OSSRH_GPG_SECRET_KEY }}" | base64 --decode | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
echo -n "${{ secrets.OSSRH_GPG_SECRET_KEY }}" | base64 --decode > $GITHUB_WORKSPACE/release.gpg
- name: Publish to Maven Central
run: |
./gradlew publishToSonatype $(if [ "${{github.event.release.prerelease}}" = "true" || "${{github.event.inputs.releaseType}}" = "prerelease" ]; then echo 'closeSonatypeStagingRepository'; else echo 'closeAndReleaseSonatypeStagingRepository'; fi) \
-Pversion=$VERSION \
-Psigning.keyId=B7D30ABE -Psigning.password="${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}" \
-Psigning.secretKeyRingFile=$GITHUB_WORKSPACE/release.gpg \
--info
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}