Skip to content

Commit fe474c2

Browse files
committed
Migrate using maven central (#926)
Motivation: OSSRH is deprecated and will be shut down soon. Let's switch to using maven central Modifications: - Replace old plugin with central-publishing-maven-plugin for release - Adjust workflow to setup the right token / password - Add scripts Result: Snapshot deployments and release works again
1 parent 81b55a8 commit fe474c2

14 files changed

+200
-53
lines changed

.github/scripts/bundle_create.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# ----------------------------------------------------------------------------
3+
# Copyright 2025 The Netty Project
4+
#
5+
# The Netty Project licenses this file to you under the Apache License,
6+
# version 2.0 (the "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at:
8+
#
9+
# https://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, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
# ----------------------------------------------------------------------------
17+
set -e
18+
19+
if [ "$#" -ne 2 ]; then
20+
echo "Expected bundle name and directory"
21+
exit 1
22+
fi
23+
24+
# Create a bundle zip that contains all jars.
25+
# See https://central.sonatype.org/publish/publish-portal-upload/
26+
pushd $2
27+
zip -r $1 * -x maven-metadata-central-staging.xml
28+
popd

.github/scripts/bundle_upload.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
# ----------------------------------------------------------------------------
3+
# Copyright 2025 The Netty Project
4+
#
5+
# The Netty Project licenses this file to you under the Apache License,
6+
# version 2.0 (the "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at:
8+
#
9+
# https://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, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
# ----------------------------------------------------------------------------
17+
set -e
18+
19+
if [ "$#" -ne 3 ]; then
20+
echo "Expected bundle-name, username, password"
21+
exit 1
22+
fi
23+
24+
# Generate the correct Bearer.
25+
# See https://central.sonatype.org/publish/publish-portal-api/
26+
BEARER=`printf "$2:$3" | base64`
27+
28+
# Upload a previous build bundle.
29+
# See https://central.sonatype.org/publish/publish-portal-api/
30+
curl --request POST \
31+
--header "Authorization: Bearer $BEARER" \
32+
--form bundle=@$1 \
33+
https://central.sonatype.com/api/v1/publisher/upload
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
# ----------------------------------------------------------------------------
3+
# Copyright 2021 The Netty Project
4+
#
5+
# The Netty Project licenses this file to you under the Apache License,
6+
# version 2.0 (the "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at:
8+
#
9+
# https://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, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
# ----------------------------------------------------------------------------
17+
set -e
18+
if [ "$#" -lt 2 ]; then
19+
echo "Expected target directory and at least one local staging directory"
20+
exit 1
21+
fi
22+
TARGET=$1
23+
24+
for ((i=2; i<=$#; i++))
25+
do
26+
DIR="${!i}"
27+
28+
if [ ! -d "${TARGET}" ]
29+
then
30+
mkdir -p "${TARGET}"
31+
fi
32+
cp -r "${DIR}"/* "${TARGET}"/
33+
done
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
# ----------------------------------------------------------------------------
3+
# Copyright 2025 The Netty Project
4+
#
5+
# The Netty Project licenses this file to you under the Apache License,
6+
# version 2.0 (the "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at:
8+
#
9+
# https://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, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
# ----------------------------------------------------------------------------
17+
18+
set -e
19+
if [ "$#" -lt 2 ]; then
20+
echo "Expected target directory and at least one local staging directory"
21+
exit 1
22+
fi
23+
TARGET=$1
24+
25+
for ((i=2; i<=$#; i++))
26+
do
27+
DIR="${!i}"
28+
29+
if [ ! -d "${TARGET}" ]
30+
then
31+
mkdir -p "${TARGET}"
32+
fi
33+
cp -r "${DIR}"/"${SUB_DIR}"/* "${TARGET}/${SUB_DIR}"/
34+
done

.github/scripts/merge_local_staging.sh renamed to .github/scripts/local_staging_merge_snapshot.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# License for the specific language governing permissions and limitations
1515
# under the License.
1616
# ----------------------------------------------------------------------------
17+
1718
set -e
1819
if [ "$#" -lt 2 ]; then
1920
echo "Expected target directory and at least one local staging directory"

.github/workflows/ci-deploy.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
run: mkdir -p ~/local-staging
103103

104104
- name: Stage snapshots to local staging directory
105-
run: ./mvnw -B -ntp -am -pl openssl-dynamic,boringssl-static clean package org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DaltStagingDirectory=$HOME/local-staging -DskipRemoteStaging=true -DskipTests=true
105+
run: ./mvnw -B -ntp -am -pl openssl-dynamic,boringssl-static clean package org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DaltStagingDirectory=$HOME/local-staging -DskipTests=true
106106

107107
- name: Upload local staging directory
108108
uses: actions/upload-artifact@v4
@@ -186,16 +186,11 @@ jobs:
186186
with:
187187
servers: |
188188
[{
189-
"id": "sonatype-nexus-snapshots",
190-
"username": "${{ secrets.SONATYPE_USERNAME }}",
191-
"password": "${{ secrets.SONATYPE_PASSWORD }}"
189+
"id": "central-portal-snapshots",
190+
"username": "${{ secrets.MAVEN_CENTRAL_USERNAME }}",
191+
"password": "${{ secrets.MAVEN_CENTRAL_PASSWORD }}"
192192
}]
193193
194-
# Setup some env to re-use later.
195-
- name: Prepare enviroment variables
196-
run: |
197-
echo "LOCAL_STAGING_DIR=$HOME/local-staging" >> $GITHUB_ENV
198-
199194
# Hardcode the staging artifacts that need to be downloaded.
200195
# These must match the matrix setups and windows build. There is currently no way to pull this out of the config.
201196
- name: Download windows_x86_64 staging directory
@@ -235,15 +230,15 @@ jobs:
235230
path: ~/centos6-x86_64-local-staging
236231

237232
- name: Copy previous build artifacts to local maven repository
238-
run: bash ./.github/scripts/install_local_staging.sh ~/.m2/repository ~/windows-x86_64-local-staging ~/macos-aarch64-local-staging ~/macos-x86_64-local-staging ~/centos7-aarch64-local-staging ~/debian7-x86_64-local-staging ~/centos6-x86_64-local-staging
233+
run: bash ./.github/scripts/local_staging_install_snapshot.sh ~/.m2/repository ~/windows-x86_64-local-staging ~/macos-aarch64-local-staging ~/macos-x86_64-local-staging ~/centos7-aarch64-local-staging ~/debian7-x86_64-local-staging ~/centos6-x86_64-local-staging
239234

240235
- name: Generate uber jar and deploy to local staging.
241236
run: |
242237
mkdir -p ~/uber-local-staging
243-
./mvnw -B --file pom.xml -Puber-snapshot -pl boringssl-static clean package org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DaltStagingDirectory=$HOME/uber-local-staging -DskipRemoteStaging=true -DskipTests=true
238+
./mvnw -B --file pom.xml -Puber-snapshot -pl boringssl-static clean package org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DaltStagingDirectory=$HOME/uber-local-staging -DskipTests=true
244239
245240
- name: Merge staging repositories
246-
run: bash ./.github/scripts/merge_local_staging.sh ~/local-staging ~/windows-x86_64-local-staging ~/macos-aarch64-local-staging ~/macos-x86_64-local-staging ~/centos7-aarch64-local-staging ~/debian7-x86_64-local-staging ~/centos6-x86_64-local-staging ~/uber-local-staging
241+
run: bash ./.github/scripts/local_staging_merge_snapshot.sh ~/local-staging ~/windows-x86_64-local-staging ~/macos-aarch64-local-staging ~/macos-x86_64-local-staging ~/centos7-aarch64-local-staging ~/debian7-x86_64-local-staging ~/centos6-x86_64-local-staging ~/uber-local-staging
247242

248243
- name: Deploy local staged artifacts
249-
run: ./mvnw -B --file pom.xml org.sonatype.plugins:nexus-staging-maven-plugin:deploy-staged -DaltStagingDirectory=$LOCAL_STAGING_DIR
244+
run: ./mvnw -B --file pom.xml org.sonatype.plugins:nexus-staging-maven-plugin:deploy-staged -DaltStagingDirectory=$HOME/local-staging

.github/workflows/ci-release.yml

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ jobs:
124124
with:
125125
servers: |
126126
[{
127-
"id": "sonatype-nexus-staging",
128-
"username": "${{ secrets.SONATYPE_USERNAME }}",
129-
"password": "${{ secrets.SONATYPE_PASSWORD }}"
127+
"id": "central",
128+
"username": "${{ secrets.MAVEN_CENTRAL_USERNAME }}",
129+
"password": "${{ secrets.MAVEN_CENTRAL_PASSWORD }}"
130130
}]
131131
132132
- name: Create local staging directory
@@ -148,7 +148,7 @@ jobs:
148148
uses: actions/upload-artifact@v4
149149
with:
150150
name: ${{ matrix.setup }}-local-staging
151-
path: ~/local-staging
151+
path: ./prepare-release-workspace/target/central-staging
152152
if-no-files-found: error
153153
include-hidden-files: true
154154

@@ -221,20 +221,20 @@ jobs:
221221
with:
222222
servers: |
223223
[{
224-
"id": "sonatype-nexus-staging",
225-
"username": "${{ secrets.SONATYPE_USERNAME }}",
226-
"password": "${{ secrets.SONATYPE_PASSWORD }}"
224+
"id": "central",
225+
"username": "${{ secrets.MAVEN_CENTRAL_USERNAME }}",
226+
"password": "${{ secrets.MAVEN_CENTRAL_PASSWORD }}"
227227
}]
228228
229229
- name: Stage release to local staging directory
230230
working-directory: prepare-release-workspace
231-
run: ./mvnw --file pom.xml -Pstage -am -pl boringssl-static clean javadoc:jar package gpg:sign org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DnexusUrl=https://oss.sonatype.org -DserverId=sonatype-nexus-staging -DaltStagingDirectory=local-staging -DskipRemoteStaging=true -DskipTests=true -D'checkstyle.skip=true'
231+
run: ./mvnw --file pom.xml -Pstage -am -pl boringssl-static clean javadoc:jar package gpg:sign org.sonatype.central:central-publishing-maven-plugin:publish -DskipTests=true -D'checkstyle.skip=true'
232232

233233
- name: Upload local staging directory
234234
uses: actions/upload-artifact@v4
235235
with:
236236
name: windows-x86_64-local-staging
237-
path: prepare-release-workspace/boringssl-static/local-staging
237+
path: ./prepare-release-workspace/target/central-staging
238238
if-no-files-found: error
239239
include-hidden-files: true
240240

@@ -298,9 +298,9 @@ jobs:
298298
with:
299299
servers: |
300300
[{
301-
"id": "sonatype-nexus-staging",
302-
"username": "${{ secrets.SONATYPE_USERNAME }}",
303-
"password": "${{ secrets.SONATYPE_PASSWORD }}"
301+
"id": "central",
302+
"username": "${{ secrets.MAVEN_CENTRAL_USERNAME }}",
303+
"password": "${{ secrets.MAVEN_CENTRAL_PASSWORD }}"
304304
}]
305305
306306
# Cache .m2/repository
@@ -322,21 +322,21 @@ jobs:
322322

323323
- name: Stage snapshots to local staging directory
324324
working-directory: ./prepare-release-workspace/
325-
run: ./mvnw -B -ntp -am -pl openssl-dynamic,boringssl-static clean javadoc:jar package gpg:sign org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DnexusUrl=https://oss.sonatype.org -DserverId=sonatype-nexus-staging -DaltStagingDirectory=$HOME/local-staging -DskipRemoteStaging=true -DskipTests=true -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Dgpg.keyname=${{ secrets.GPG_KEYNAME }}
325+
run: ./mvnw -B -ntp -am -pl openssl-dynamic,boringssl-static clean javadoc:jar package gpg:sign org.sonatype.central:central-publishing-maven-plugin:publish -DskipTests=true
326326

327327
- name: Upload local staging directory
328328
uses: actions/upload-artifact@v4
329329
with:
330330
name: ${{ matrix.setup }}-local-staging
331-
path: ~/local-staging
331+
path: ./prepare-release-workspace/target/central-staging
332332
if-no-files-found: error
333333
include-hidden-files: true
334334

335335
- name: Rollback release on failure
336336
working-directory: ./prepare-release-workspace/
337337
if: ${{ failure() }}
338338
# Rollback the release in case of an failure
339-
run: ./.github/scripts/release_rollback.ps1 release.properties netty/netty-tcnative main
339+
run: bash ./.github/scripts/release_rollback.sh release.properties netty/netty-tcnative main
340340

341341
deploy-staged-release:
342342
runs-on: ubuntu-latest
@@ -391,9 +391,9 @@ jobs:
391391
with:
392392
servers: |
393393
[{
394-
"id": "sonatype-nexus-staging",
395-
"username": "${{ secrets.SONATYPE_USERNAME }}",
396-
"password": "${{ secrets.SONATYPE_PASSWORD }}"
394+
"id": "central",
395+
"username": "${{ secrets.MAVEN_CENTRAL_USERNAME }}",
396+
"password": "${{ secrets.MAVEN_CENTRAL_PASSWORD }}"
397397
}]
398398
399399
# Hardcode the staging artifacts that need to be downloaded.
@@ -436,24 +436,27 @@ jobs:
436436

437437
- name: Copy previous build artifacts to local maven repository
438438
working-directory: ./prepare-release-workspace/
439-
run: bash ./.github/scripts/install_local_staging.sh ~/.m2/repository ~/windows-x86_64-local-staging/staging ~/macos-aarch64-local-staging/staging ~/macos-x86_64-local-staging/staging ~/centos7-aarch64-local-staging/staging ~/debian7-x86_64-local-staging/staging ~/centos6-x86_64-local-staging/staging
439+
run: bash ./.github/scripts/local_staging_install_release.sh ~/.m2/repository ~/windows-x86_64-local-staging ~/macos-aarch64-local-staging ~/macos-x86_64-local-staging ~/centos7-aarch64-local-staging ~/debian7-x86_64-local-staging ~/centos6-x86_64-local-staging
440440

441441
- name: Generate uber jar and deploy to local staging.
442442
working-directory: ./prepare-release-workspace/
443443
run: |
444444
mkdir -p ~/uber-local-staging
445-
./mvnw -B --file pom.xml -Puber-snapshot -pl boringssl-static clean package gpg:sign org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DnexusUrl=https://oss.sonatype.org -DserverId=sonatype-nexus-staging -DaltStagingDirectory=$HOME/uber-local-staging -DskipRemoteStaging=true -DskipTests=true
445+
./mvnw -B --file pom.xml -Puber-staging -pl boringssl-static clean package gpg:sign org.sonatype.central:central-publishing-maven-plugin:publish -DskipTests=true
446446
447447
# This step takes care of merging all the previous staged repositories in a way that will allow us to deploy
448448
# all together with one maven command.
449449
- name: Merge staging repositories
450450
working-directory: ./prepare-release-workspace/
451-
run: bash ./.github/scripts/merge_local_staging.sh /home/runner/local-staging/staging ~/windows-x86_64-local-staging/staging ~/macos-aarch64-local-staging/staging ~/macos-x86_64-local-staging/staging ~/centos7-aarch64-local-staging/staging ~/debian7-x86_64-local-staging/staging ~/centos6-x86_64-local-staging/staging ~/uber-local-staging/staging
451+
run: bash ./.github/scripts/local_staging_merge_release.sh ~/local-staging ~/windows-x86_64-local-staging ~/macos-aarch64-local-staging ~/macos-x86_64-local-staging ~/centos7-aarch64-local-staging ~/debian7-x86_64-local-staging ~/centos6-x86_64-local-staging ~/uber-local-staging
452+
453+
- name: Create bundle
454+
working-directory: ./prepare-release-workspace/
455+
run: bash ./.github/scripts/bundle_create.sh ~/central-bundle.zip ~/local-staging/
452456

453-
- name: Deploy local staged artifacts
457+
- name: Upload bundle to maven central
454458
working-directory: ./prepare-release-workspace/
455-
# If we don't want to close the repository we can add -DskipStagingRepositoryClose=true
456-
run: ./mvnw -B --file pom.xml org.sonatype.plugins:nexus-staging-maven-plugin:deploy-staged -DnexusUrl=https://oss.sonatype.org -DserverId=sonatype-nexus-staging -DaltStagingDirectory=$HOME/local-staging -DskipStagingRepositoryClose=true
459+
run: bash ./.github/scripts/bundle_upload.sh ~/central-bundle.zip ${{ secrets.MAVEN_CENTRAL_USERNAME }} ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
457460

458461
- name: Rollback release on failure
459462
working-directory: ./prepare-release-workspace/

boringssl-static/pom.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,14 +1051,6 @@
10511051
<compileLibrary>false</compileLibrary>
10521052
</properties>
10531053

1054-
<repositories>
1055-
<repository>
1056-
<id>staged-releases</id>
1057-
<name>Staged Releases</name>
1058-
<url>https://oss.sonatype.org/service/local/repositories/${stagingRepositoryId}/content/</url>
1059-
</repository>
1060-
</repositories>
1061-
10621054
<dependencies>
10631055
<dependency>
10641056
<groupId>io.netty</groupId>

docker/Dockerfile.cross_compile_aarch64

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM --platform=linux/amd64 centos:7.6.1810
22

33
ARG gcc_version=10.2-2020.11
44
ARG openssl_version=1_1_1d
5-
ARG apr_version=1.7.5
5+
ARG apr_version=1.7.6
66
ENV SOURCE_DIR /root/source
77
ENV GCC_VERSION $gcc_version
88
ENV OPENSSL_VERSION $openssl_version

docker/docker-compose.centos-6.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ services:
3939
- ~/.m2/repository:/root/.m2/repository
4040
- ~/local-staging:/root/local-staging
4141
- ..:/code
42-
command: /bin/bash -cl "./mvnw -Pstage -am -pl openssl-dynamic,boringssl-static clean package org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DaltStagingDirectory=/root/local-staging -DskipRemoteStaging=true -DskipTests=true"
42+
command: /bin/bash -cl "./mvnw -Pstage -am -pl openssl-dynamic,boringssl-static clean package org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DaltStagingDirectory=/root/local-staging -DskipTests=true"
4343

4444
stage-release:
4545
<<: *common
@@ -49,7 +49,7 @@ services:
4949
- ~/.m2/settings.xml:/root/.m2/settings.xml
5050
- ~/local-staging:/root/local-staging
5151
- ..:/code
52-
command: /bin/bash -cl "cat <(echo -e \"${GPG_PRIVATE_KEY}\") | gpg --batch --import && ./mvnw -B -Pstage -am -pl openssl-dynamic,boringssl-static clean javadoc:jar package gpg:sign org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DnexusUrl=https://oss.sonatype.org -DserverId=sonatype-nexus-staging -DaltStagingDirectory=/root/local-staging -DskipRemoteStaging=true -DskipTests=true -Dgpg.passphrase=${GPG_PASSPHRASE} -Dgpg.keyname=${GPG_KEYNAME}"
52+
command: /bin/bash -cl "cat <(echo -e \"${GPG_PRIVATE_KEY}\") | gpg --batch --import && ./mvnw -B -Pstage -am -pl openssl-dynamic,boringssl-static clean javadoc:jar package gpg:sign org.sonatype.central:central-publishing-maven-plugin:publish -DskipTests=true -Dgpg.passphrase=${GPG_PASSPHRASE} -Dgpg.keyname=${GPG_KEYNAME}"
5353

5454
deploy:
5555
<<: *common

0 commit comments

Comments
 (0)