-
Notifications
You must be signed in to change notification settings - Fork 5
42 lines (37 loc) · 1.52 KB
/
publish-snapshot.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
name: Publish SNAPSHOT to Sonatype
on:
push:
branches:
- 'main'
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Java & Maven
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
server-id: ossrh
# User/pass refer to ENV VARs set below
server-username: MAVEN_USERNAME # Sonatype user
server-password: MAVEN_PASSWORD # Sonatype password # env variable for GPG private key passphrase
gpg-private-key: ${{ secrets.MAVEN_GPG_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Get project version
id: project_version
# run: echo ::set-output name=version::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
run: echo "VERSION=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`" >> $GITHUB_OUTPUT
- name: Publish SNAPSHOT
# Only execute for -SNAPSHOT versions
if: ${{ endsWith(steps.project_version.outputs.version, '-SNAPSHOT') }}
run: mvn -B --no-transfer-progress clean deploy
env:
# Add OSSRH_USERNAME and OSSRH_PASSWORD as GH secrets
# https://docs.github.com/en/actions/security-guides/encrypted-secrets
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}