forked from MathieuSoysal/Java-maven-library-publisher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
84 lines (75 loc) · 2.5 KB
/
action.yaml
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
name: Java maven library publisher
author: "Mathieu Soysal (@MathieuSoysal)"
description: "Build automatically Java Maven library and publish it to GitHub Packages and Maven Central."
branding:
icon: "package"
color: "gray-dark"
inputs:
nexus-username:
description: "Nexus username"
required: true
nexus-password:
description: "Nexus password"
required: true
gpg-private-key:
description: "GPG private key"
required: true
gpg-passphrase:
description: "GPG passphrase"
required: true
github-token:
description: "GitHub token"
required: true
# Java version to use
java-version:
description: "Java version to use"
required: true
default: "17"
# Library version
library-version:
description: "Library version"
required: false
default: ""
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17 for deploy to OSSRH
uses: actions/setup-java@v2
with:
distribution: "adopt"
java-version: ${{ inputs.java-version }}
server-id: ossrh
server-username: ${{ inputs.nexus-username }}
server-password: ${{ inputs.nexus-password }}
gpg-private-key: ${{ inputs.gpg-private-key }}
gpg-passphrase: ${{ inputs.gpg-passphrase }}
- name: Build with Maven
run: mvn -B package --file pom.xml
shell: bash
- name: Update package version
if: ${{ inputs.library-version != '' }}
run: mvn versions:set -DnewVersion=${{ inputs.library-version }}
shell: bash
- name: Prepare Maven environnement with Java 17 for deployment to OSSRH
run: export MAVEN_OPTS="--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED"
shell: bash
- name: Publish to Apache Maven Central
run: mvn deploy -PossrhDeploy
shell: bash
env:
MAVEN_USERNAME: ${{ inputs.nexus-username }}
MAVEN_CENTRAL_TOKEN: ${{ inputs.nexus-password }}
MAVEN_GPG_PASSPHRASE: ${{ inputs.gpg-passphrase }}
- name: Set up JDK 17 for deploy to github packages
uses: actions/setup-java@v2
with:
distribution: "adopt"
java-version: ${{ inputs.java-version }}
server-id: github
- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -PgithubDeploy
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github-token }}