-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (44 loc) · 1.54 KB
/
deploy.yml
File metadata and controls
47 lines (44 loc) · 1.54 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
name: Deploy Snapshots and Publish Releases to the Maven Central Repository
on:
# Snapshots
push:
branches: [main]
# Releases
release:
types: [created]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
- name: Cache Local Maven Repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Verify and Update Version in pom.xml
run: |
VERSION=$(mvn -B -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec -q)
echo "Found version: ${VERSION}"
if [[ "${{ github.event_name }}" == "release" ]]; then
VERSION=$(echo "${{ github.event.release.tag_name }}" | sed -e 's/^v//gi')
echo "Release: updating version to ${VERSION}"
mvn -B versions:set -DnewVersion=${VERSION} -DgenerateBackupPoms=false
elif [[ ! "${VERSION}" =~ -SNAPSHOT$ ]]; then
echo "Missing SNAPSHOT in version: ${VERSION}"
exit 1
fi
- name: Release Maven Package
uses: samuelmeuli/action-maven-publish@v1
with:
maven_args: -Ddeploy
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
nexus_username: ${{ secrets.OSSRH_USERNAME }}
nexus_password: ${{ secrets.OSSRH_TOKEN }}