-
Notifications
You must be signed in to change notification settings - Fork 52
146 lines (141 loc) · 5.02 KB
/
maven-publish.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Maven Package
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
release_version:
description: 'Release Version to publish'
required: true
type: string
publish_repo:
description: 'Repository to publish artifacts'
required: true
type: choice
default: 'GitHub'
options:
- 'GitHub'
- 'CloudsmithIO'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'zulu'
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Setup Github Package Registry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p ~/.m2
cat <<EOF > ~/.m2/settings.xml
<settings>
<servers>
<server>
<id>gh</id>
<username>$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $1}')</username>
<password>${GITHUB_TOKEN}</password>
</server>
<server>
<id>artifactory-snapshots</id>
<username>${{ secrets.ARTIFACTORY_USERNAME }}</username>
<password>${{ secrets.ARTIFACTORY_PASSWORD }}</password>
</server>
<server>
<id>artifactory-releases</id>
<username>${{ secrets.ARTIFACTORY_USERNAME }}</username>
<password>${{ secrets.ARTIFACTORY_PASSWORD }}</password>
</server>
<server>
<id>artifactory</id>
<username>${{ secrets.ARTIFACTORY_USERNAME }}</username>
<password>${{ secrets.ARTIFACTORY_PASSWORD }}</password>
</server>
<server>
<id>cloudsmith</id>
<username>${{ secrets.CLOUDSMITH_USERNAME }}</username>
<password>${{ secrets.CLOUDSMITH_PASSWORD }}</password>
</server>
</servers>
</settings>
EOF
- name: Setup release version
if: ${{ github.event_name != 'workflow_dispatch' }}
run: |
RELEASE_VERSION="${GITHUB_REF##*/}"
RELEASE_VERSION="${RELEASE_VERSION:1}"
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
- name: Setup release version
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "RELEASE_VERSION=${{ inputs.release_version }}" >> $GITHUB_ENV
- name: Update pom with release version
run: |
mvn versions:set -DnewVersion=${{ env.RELEASE_VERSION }}
mvn versions:update-child-modules -Pdse,hcd
- name: Deploy Artifacts to GitHub Packages
if: |-
${{
github.event_name != 'workflow_dispatch' ||
inputs.publish_repo == 'GitHub'
}}
run: |
REPO="gh::default::https://maven.pkg.github.com/${GITHUB_REPOSITORY}"
mvn -B clean deploy \
-P dse,hcd \
-Dskip.surefire.tests \
-DskipTests \
-DaltDeploymentRepository="${REPO}" \
-DaltSnapshotDeploymentRepository="${REPO}"
- name: Deploy Artifacts to Cloudsmith.io Artifactory
if: |-
${{
github.event_name != 'workflow_dispatch' ||
inputs.publish_repo == 'CloudsmithIO'
}}
run: |
REPO="cloudsmith::default::https://maven.cloudsmith.io/thelastpickle/reaper-mvn/"
mvn -B deploy \
-P dse,hcd \
-Dskip.surefire.tests \
-DskipTests \
-DaltDeploymentRepository="${REPO}" \
-DaltSnapshotDeploymentRepository="${REPO}"
- name: Deploy OpenAPI client to GitHub Packages
if: |-
${{
github.event_name != 'workflow_dispatch' ||
inputs.publish_repo == 'GitHub'
}}
run: |
REPO="gh::default::https://maven.pkg.github.com/${GITHUB_REPOSITORY}"
mvn -B deploy \
-f management-api-server/target/generated-sources/openapi/java-client/pom.xml \
-Dskip.surefire.tests \
-DskipTests \
-DaltDeploymentRepository="${REPO}" \
-DaltSnapshotDeploymentRepository="${REPO}"
- name: Deploy OpenAPI client to Cloudsmith.io Artifactory
if: |-
${{
github.event_name != 'workflow_dispatch' ||
inputs.publish_repo == 'CloudsmithIO'
}}
run: |
REPO="cloudsmith::default::https://maven.cloudsmith.io/thelastpickle/reaper-mvn/"
mvn -B deploy \
-f management-api-server/target/generated-sources/openapi/java-client/pom.xml \
-Dskip.surefire.tests \
-DskipTests \
-DaltDeploymentRepository="${REPO}" \
-DaltSnapshotDeploymentRepository="${REPO}"