Skip to content

Commit 825385e

Browse files
authored
4.x: migrate release workflow to use Central Publishing Portal (#10114)
Migrate release workflow from ossrh to central publishing portal
1 parent 5d4ebac commit 825385e

File tree

7 files changed

+485
-98
lines changed

7 files changed

+485
-98
lines changed

.github/actions/common/action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ runs:
9595
with:
9696
distribution: ${{ env.JAVA_DISTRO }}
9797
java-version: ${{ env.JAVA_VERSION }}
98+
overwrite-settings: false
9899
- name: Set up JDK ea-stable
99100
if: ${{ inputs.setup-latest-java == 'true' }}
100101
uses: oracle-actions/setup-java@v1
@@ -139,6 +140,15 @@ runs:
139140
restore-keys: |
140141
build-cache-${{ github.run_id }}-${{ github.run_attempt }}-
141142
build-cache-${{ github.run_id }}-
143+
- name: Build cache (write-only)
144+
if: ${{ inputs.build-cache == 'write-only' }}
145+
uses: actions/cache@v4.2.0
146+
with:
147+
path: |
148+
./**/target/**
149+
.m2/repository/io/helidon/**
150+
enableCrossOsArchive: true
151+
key: build-cache-${{ github.run_id }}-${{ github.run_attempt }}-${{ inputs.build-cache-id }}
142152
- name: Build cache (read-only)
143153
if: ${{ inputs.build-cache == 'read-only' }}
144154
uses: actions/cache/restore@v4.2.0

.github/workflows/release.yaml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ jobs:
105105
merge-multiple: true
106106
- shell: bash
107107
env:
108-
NEXUS_USER: ${{ secrets.NEXUS_USER }}
109-
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
108+
CENTRAL_USER: ${{ secrets.CENTRAL_USER }}
109+
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
110110
run: |
111-
etc/scripts/nexus.sh deploy_release \
111+
etc/scripts/upload.sh upload_release \
112112
--dir="staging" \
113113
--description="Helidon v%{version}"
114114
- uses: actions/upload-artifact@v4
@@ -119,22 +119,31 @@ jobs:
119119
needs: [ create-tag, deploy ]
120120
timeout-minutes: 30
121121
runs-on: ubuntu-22.04
122-
name: resolve-all
122+
environment: release
123123
steps:
124124
- uses: actions/checkout@v4
125125
with:
126126
fetch-depth: '0'
127127
ref: ${{ needs.create-tag.outputs.tag }}
128+
- shell: bash
129+
env:
130+
CENTRAL_USER: ${{ secrets.CENTRAL_USER }}
131+
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
132+
run: |
133+
./etc/scripts/setup-central-settings.sh
128134
- uses: ./.github/actions/common
129135
with:
136+
build-cache: write-only
137+
build-cache-id: resolve-all
130138
run: |
131139
mvn ${MVN_ARGS} -N \
132-
-Possrh-staging \
140+
-Pcentral.manual.testing \
133141
-Dartifact=io.helidon:helidon-all:${{ needs.create-tag.outputs.version }}:pom \
134142
dependency:get
135143
smoketest:
136-
needs: [ create-tag, deploy ]
144+
needs: [ resolve-all, create-tag, deploy ]
137145
timeout-minutes: 30
146+
environment: release
138147
strategy:
139148
matrix:
140149
archetype:
@@ -151,11 +160,19 @@ jobs:
151160
with:
152161
fetch-depth: '0'
153162
ref: ${{ needs.create-tag.outputs.tag }}
163+
- shell: bash
164+
env:
165+
CENTRAL_USER: ${{ secrets.CENTRAL_USER }}
166+
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
167+
run: |
168+
./etc/scripts/setup-central-settings.sh
154169
- uses: ./.github/actions/common
155170
with:
171+
build-cache: read-only
172+
build-cache-id: resolve-all
173+
maven-cache: read-only
156174
run: |
157175
./etc/scripts/smoketest.sh \
158-
--clean \
159176
--staged \
160177
--version=${{ needs.create-tag.outputs.version }} \
161178
--archetype=${{ matrix.archetype }}

.github/workflows/snapshot.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ jobs:
103103
merge-multiple: true
104104
- shell: bash
105105
env:
106-
NEXUS_USER: ${{ secrets.NEXUS_USER }}
107-
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
106+
CENTRAL_USER: ${{ secrets.CENTRAL_USER }}
107+
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
108108
run: |
109-
etc/scripts/nexus.sh deploy_snapshots \
109+
etc/scripts/upload.sh upload_snapshot \
110110
--dir="staging"
111111
- uses: actions/upload-artifact@v4
112112
with:
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2025 Oracle and/or its affiliates.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
set -o pipefail || true # trace ERR through pipes
19+
set -o errtrace || true # trace ERR through commands and functions
20+
set -o errexit || true # exit the script if any statement returns a non-true return value
21+
22+
on_error(){
23+
CODE="${?}" && \
24+
set +x && \
25+
printf "[ERROR] Error(code=%s) occurred at %s:%s command: %s\n" \
26+
"${CODE}" "${BASH_SOURCE[0]}" "${LINENO}" "${BASH_COMMAND}" >&2
27+
}
28+
trap on_error ERR
29+
30+
usage(){
31+
cat <<EOF
32+
33+
DESCRIPTION: Create a Maven settings.xml file that includes central staging repo so we can use it for testing.
34+
35+
USAGE:
36+
37+
$(basename "${0}") --dir=D
38+
39+
--dir=path
40+
Directory to place settings.xml file in. Defaults to ${HOME}/.m2
41+
EOF
42+
}
43+
44+
# parse command line args
45+
ARGS=( "${@}" )
46+
for ((i=0;i<${#ARGS[@]};i++))
47+
{
48+
ARG=${ARGS[${i}]}
49+
case ${ARG} in
50+
"--dir="*)
51+
DESTINATION_DIRECTORY=${ARG#*=}
52+
;;
53+
*)
54+
echo "ERROR: unknown argument: ${ARG}"
55+
exit 1
56+
;;
57+
esac
58+
}
59+
60+
if [ -z "${CENTRAL_USER}" ] ; then
61+
echo "ERROR: environment variable CENTRAL_USER is required." >&2
62+
usage
63+
exit 1
64+
fi
65+
66+
if [ -z "${CENTRAL_PASSWORD}" ] ; then
67+
echo "ERROR: environment variable CENTRAL_PASSWORD is required." >&2
68+
usage
69+
exit 1
70+
fi
71+
72+
if [ -z "${DESTINATION_DIRECTORY}" ] ; then
73+
DESTINATION_DIRECTORY="${HOME}/.m2"
74+
mkdir -p "${DESTINATION_DIRECTORY}"
75+
fi
76+
77+
if [ ! -d "${DESTINATION_DIRECTORY}" ] ; then
78+
echo "ERROR: destination directory ${DESTINATION_DIRECTORY} does not exist or is not a directory" >&2
79+
usage
80+
exit 1
81+
fi
82+
83+
readonly DESTINATION_DIRECTORY
84+
85+
if [ -e "${DESTINATION_DIRECTORY}/settings.xml" ]; then
86+
echo "WARNING: ${DESTINATION_DIRECTORY}/settings.xml already exists. Copying to ${DESTINATION_DIRECTORY}/settings.xml.bk" >&2
87+
cp "${DESTINATION_DIRECTORY}/settings.xml" "${DESTINATION_DIRECTORY}/settings.xml.bk"
88+
fi
89+
90+
# Create credential needed to access Maven Central Publishing portal
91+
BEARER=$(printf "%s:%s" "${CENTRAL_USER}" "${CENTRAL_PASSWORD}" | base64)
92+
readonly BEARER
93+
94+
maven_settings() {
95+
cat <<EOF
96+
<settings>
97+
<servers>
98+
<server>
99+
<id>central.manual.testing</id>
100+
<configuration>
101+
<httpHeaders>
102+
<property>
103+
<name>Authorization</name>
104+
<value>Bearer ${BEARER}</value>
105+
</property>
106+
</httpHeaders>
107+
</configuration>
108+
</server>
109+
</servers>
110+
<profiles>
111+
<profile>
112+
<id>central.manual.testing</id>
113+
<repositories>
114+
<repository>
115+
<id>central.manual.testing</id>
116+
<name>Central Testing repository</name>
117+
<url>https://central.sonatype.com/api/v1/publisher/deployments/download</url>
118+
</repository>
119+
</repositories>
120+
<pluginRepositories>
121+
<pluginRepository>
122+
<id>central.manual.testing</id>
123+
<name>Central Testing repository</name>
124+
<url>https://central.sonatype.com/api/v1/publisher/deployments/download</url>
125+
</pluginRepository>
126+
</pluginRepositories>
127+
</profile>
128+
</profiles>
129+
</settings>
130+
EOF
131+
}
132+
133+
setup_central_settings() {
134+
echo "INFO: creating settings.xml in ${DESTINATION_DIRECTORY}"
135+
maven_settings > "${DESTINATION_DIRECTORY}/settings.xml"
136+
}
137+
138+
setup_central_settings

etc/scripts/smoketest.sh

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ for ((i=0;i<${#ARGS[@]};i++))
6363
ARG=${ARGS[${i}]}
6464
case ${ARG} in
6565
"--staged")
66-
MVN_ARGS="${MVN_ARGS} -Possrh-staging"
66+
MVN_ARGS="${MVN_ARGS} -Pcentral.manual.testing"
6767
;;
6868
"--clean")
6969
MVN_ARGS="${MVN_ARGS} -Dmaven.repo.local=.m2/repository"
@@ -96,69 +96,6 @@ fi
9696
PID=""
9797
trap '[ -n "${PID}" ] && kill ${PID} 2> /dev/null || true' 0
9898

99-
maven_proxies() {
100-
[ -f "${HOME}/.m2/settings.xml" ] && \
101-
awk -f- "${HOME}/.m2/settings.xml" <<EOF
102-
BEGIN{
103-
IN_PROXIES="FALSE"
104-
FS="[<>]"
105-
}
106-
/<proxies>/{
107-
IN_PROXIES="true"
108-
next
109-
}
110-
/<\/proxies>/{
111-
IN_PROXIES="false"
112-
}
113-
{
114-
if (IN_PROXIES=="true") {
115-
print \$0
116-
}
117-
}
118-
EOF
119-
}
120-
121-
maven_settings() {
122-
cat <<EOF
123-
<settings>
124-
<proxies>
125-
$(maven_proxies)
126-
</proxies>
127-
<profiles>
128-
<profile>
129-
<id>ossrh-staging</id>
130-
<repositories>
131-
<repository>
132-
<id>ossrh-staging</id>
133-
<name>OSS Sonatype Staging</name>
134-
<url>https://oss.sonatype.org/content/groups/staging/</url>
135-
<snapshots>
136-
<enabled>false</enabled>
137-
</snapshots>
138-
<releases>
139-
<enabled>true</enabled>
140-
</releases>
141-
</repository>
142-
</repositories>
143-
<pluginRepositories>
144-
<pluginRepository>
145-
<id>ossrh-staging</id>
146-
<name>OSS Sonatype Staging</name>
147-
<url>https://oss.sonatype.org/content/groups/staging/</url>
148-
<snapshots>
149-
<enabled>false</enabled>
150-
</snapshots>
151-
<releases>
152-
<enabled>true</enabled>
153-
</releases>
154-
</pluginRepository>
155-
</pluginRepositories>
156-
</profile>
157-
</profiles>
158-
</settings>
159-
EOF
160-
}
161-
16299
# arg1: uri
163100
wait_ready() {
164101
sleep 6
@@ -293,9 +230,6 @@ readonly LOG_FILE
293230

294231
mkdir -p "${WORK_DIR}"
295232

296-
maven_settings > "${WORK_DIR}/settings.xml"
297-
MVN_ARGS="${MVN_ARGS} -s ${WORK_DIR}/settings.xml"
298-
299233
exec 1>> >(tee "${LOG_FILE}")
300234
exec 2>> >(tee "${LOG_FILE}")
301235

0 commit comments

Comments
 (0)