-
Notifications
You must be signed in to change notification settings - Fork 52
69 lines (69 loc) · 2.69 KB
/
publish-to-maven-central.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
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: Publish to Maven Central
on:
workflow_dispatch:
pull_request:
types: [opened]
paths:
- 'version.txt'
branches:
- release
jobs:
create-staging-repository:
name: Create staging repository
runs-on: ubuntu-latest
outputs:
repository_id: ${{ steps.create.outputs.repository_id }}
steps:
- id: create
uses: nexus-actions/[email protected]
with:
base_url: "https://s01.oss.sonatype.org/service/local/"
username: ${{ secrets.SONATYPE_USERNAME }}
password: ${{ secrets.SONATYPE_PASSWORD }}
staging_profile_id: ${{ secrets.SONATYPE_PROFILE_ID }}
description: ${{ github.repository }}/${{ github.workflow }}#${{ github.run_number }}
linux-upload:
runs-on: ubuntu-latest
needs: [create-staging-repository]
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Configure JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
- name: Upload all artifacts Linux can build
run: >-
./gradlew --scan --console=plain --no-configuration-cache
publishAllPublicationsToMavenCentralStagingRepository
env:
sonatype_staging_repo_id: ${{ needs.create-staging-repository.outputs.repository_id }}
finalize:
runs-on: ubuntu-latest
needs: [create-staging-repository, linux-upload]
if: ${{ always() && needs.create-staging-repository.result == 'success' }}
steps:
- name: Discard staging repository
if: ${{ needs.linux-upload.result != 'success' }}
uses: nexus-actions/drop-nexus-staging-repo@v1
with:
base_url: "https://s01.oss.sonatype.org/service/local/"
username: ${{ secrets.SONATYPE_USERNAME }}
password: ${{ secrets.SONATYPE_PASSWORD }}
staging_repository_id: ${{ needs.create-staging-repository.outputs.repository_id }}
- name: Release
if: ${{ needs.linux-upload.result == 'success' }}
uses: nexus-actions/[email protected]
with:
base_url: "https://s01.oss.sonatype.org/service/local/"
username: ${{ secrets.SONATYPE_USERNAME }}
password: ${{ secrets.SONATYPE_PASSWORD }}
staging_repository_id: ${{ needs.create-staging-repository.outputs.repository_id }}
env:
sonatype_username: ${{ secrets.SONATYPE_USERNAME }}
sonatype_password: ${{ secrets.SONATYPE_PASSWORD }}
GPG_key_id: ${{ secrets.GPG_KEY_ID }}
GPG_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_private_password: ${{ secrets.GPG_PRIVATE_PASSWORD }}