-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathspring-artifactory-deploy-to-maven-central.yml
More file actions
108 lines (95 loc) · 3.44 KB
/
spring-artifactory-deploy-to-maven-central.yml
File metadata and controls
108 lines (95 loc) · 3.44 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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Deploy Release (Milestone or GA) to Maven Central from Artifactory Build
on:
workflow_call:
inputs:
buildName:
description: 'The Artifactory Build Name'
required: true
type: string
buildNumber:
description: 'The Artifactory Build Number'
required: true
type: string
runner:
description: 'The runner for job'
required: false
type: string
default: ubuntu-latest
secrets:
OSSRH_S01_TOKEN_USERNAME:
required: false
OSSRH_S01_TOKEN_PASSWORD:
required: false
OSSRH_STAGING_PROFILE_NAME:
required: false
CENTRAL_TOKEN_USERNAME:
required: false
CENTRAL_TOKEN_PASSWORD:
required: false
JF_ARTIFACTORY_SPRING:
required: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
OSSRH_S01_TOKEN_USERNAME: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }}
CENTRAL_TOKEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
WORKFLOWS_REF: main
jobs:
deploy-to-maven-central:
runs-on: ${{ inputs.runner }}
steps:
- uses: actions/checkout@v6
with:
show-progress: false
- name: Verify Maven Secrets
run: |
if [[ -z $OSSRH_S01_TOKEN_USERNAME && -z $CENTRAL_TOKEN_USERNAME ]]
then
gh run cancel ${{ github.run_id }}
echo "::error title=Cannot deploy to Maven Central:: The 'OSSRH_S01_TOKEN_USERNAME' & 'OSSRH_S01_TOKEN_PASSWORD' or 'CENTRAL_TOKEN_USERNAME' & 'CENTRAL_TOKEN_PASSWORD' pair of secrets must be provided"
exit 1
fi
- uses: actions/checkout@v6
with:
repository: spring-io/spring-github-workflows
show-progress: false
ref: ${{ env.WORKFLOWS_REF }}
- uses: jfrog/setup-jfrog-cli@v4
- name: Download Release Files
id: download-release-files
run: |
jfrog rt download \
--spec utils/release-files-spec.json \
--spec-vars "buildname=${{ inputs.buildName }};buildnumber=${{ inputs.buildNumber }}"
jarToCheck=$(find central_bundle -name "*.jar" -print -quit)
jarToCheck=${jarToCheck#central_bundle}
echo jarToCheck=$jarToCheck >> $GITHUB_OUTPUT
- uses: spring-io/nexus-sync-action@v0.0.1
id: nexus
if: env.OSSRH_S01_TOKEN_USERNAME
with:
username: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }}
password: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }}
staging-profile-name: ${{ secrets.OSSRH_STAGING_PROFILE_NAME }}
dir: central_bundle
create: true
upload: true
generate-checksums: true
upload-parallel: 10
close: true
release: true
close-timeout: 3600
release-timeout: 3600
- name: Await for Artifact in Maven Central Repository
if: env.OSSRH_S01_TOKEN_USERNAME
uses: ./.github/actions/await-http-resource
with:
url: https://repo.maven.apache.org/maven2${{ steps.download-release-files.outputs.jarToCheck }}
- name: Deploy Bundle to Maven Central Portal
if: env.CENTRAL_TOKEN_USERNAME
uses: spring-io/central-publish-action@v0.4.0
with:
token-name: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
token: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
dir: central_bundle
ignore-already-exists-error: true