-
Notifications
You must be signed in to change notification settings - Fork 25
56 lines (50 loc) · 1.87 KB
/
Copy pathversion-and-release.yml
File metadata and controls
56 lines (50 loc) · 1.87 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
name: Release
# Needs CENTRAL_USERNAME / CENTRAL_PASSWORD (Sonatype Central Portal user token) plus GPG_SECRET / GPG_PASSWORD.
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: Version to publish (e.g. 3.0.0); the poms are set to it before deploying
required: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up Java with Maven cache
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
cache: 'maven'
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Update version in Maven configuration
run: |
mvn --no-transfer-progress \
--batch-mode \
versions:set -DnewVersion=${{ github.event.inputs.version || github.event.release.tag_name }} -DprocessAllModules
- name: Install GPG key
# accepts the armored key with real newlines, with escaped "\n", or base64 encoded
run: |
printf '%s' "$GPG_SECRET" > "$RUNNER_TEMP/gpg.key"
gpg --batch --import "$RUNNER_TEMP/gpg.key" 2>/dev/null \
|| printf '%b' "$GPG_SECRET" | gpg --batch --import 2>/dev/null \
|| base64 -d "$RUNNER_TEMP/gpg.key" | gpg --batch --import
rm -f "$RUNNER_TEMP/gpg.key"
gpg --list-secret-keys --keyid-format LONG
env:
GPG_SECRET: ${{ secrets.GPG_SECRET }}
- name: Publish to Maven
run: |
mvn --no-transfer-progress \
--batch-mode \
-Dgpg.passphrase='${{ secrets.GPG_PASSWORD }}' \
-DskipTests deploy -P release
env:
MAVEN_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}