Skip to content

Commit 0c62405

Browse files
committed
Migrate to using maven central for release (#102)
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 - Adjust workflow to setup the right token / password Result: Release works again
1 parent 38865e8 commit 0c62405

9 files changed

Lines changed: 124 additions & 37 deletions

.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: 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
File renamed without changes.

.github/workflows/ci-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ jobs:
189189
path: ~/linux-x86_64-local-staging
190190

191191
- name: Merge staging repositories
192-
run: bash ./.github/scripts/merge_local_staging.sh ~/local-staging ~/macos-x86_64-local-staging ~/macos-aarch64-local-staging ~/linux-aarch64-local-staging ~/linux-x86_64-local-staging
192+
run: bash ./.github/scripts/local_staging_merge_snapshot.sh ~/local-staging ~/macos-x86_64-local-staging ~/macos-aarch64-local-staging ~/linux-aarch64-local-staging ~/linux-x86_64-local-staging
193193

194194
- name: Deploy local staged artifacts
195195
run: ./mvnw -B -ntp --file pom.xml -Pstage-snapshot org.sonatype.plugins:nexus-staging-maven-plugin:deploy-staged -DaltStagingDirectory=$HOME/local-staging

.github/workflows/ci-release.yml

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ jobs:
128128
with:
129129
servers: |
130130
[{
131-
"id": "sonatype-nexus-staging",
132-
"username": "${{ secrets.SONATYPE_USERNAME }}",
133-
"password": "${{ secrets.SONATYPE_PASSWORD }}"
131+
"id": "central",
132+
"username": "${{ secrets.MAVEN_CENTRAL_USERNAME }}",
133+
"password": "${{ secrets.MAVEN_CENTRAL_PASSWORD }}"
134134
}]
135135
136136
- name: Create local staging directory
@@ -152,7 +152,7 @@ jobs:
152152
uses: actions/upload-artifact@v4
153153
with:
154154
name: ${{ matrix.setup }}-local-staging
155-
path: ~/local-staging
155+
path: ./prepare-release-workspace/target/central-staging
156156
if-no-files-found: error
157157
include-hidden-files: true
158158

@@ -213,11 +213,12 @@ jobs:
213213
with:
214214
servers: |
215215
[{
216-
"id": "sonatype-nexus-staging",
217-
"username": "${{ secrets.SONATYPE_USERNAME }}",
218-
"password": "${{ secrets.SONATYPE_PASSWORD }}"
216+
"id": "central",
217+
"username": "${{ secrets.MAVEN_CENTRAL_USERNAME }}",
218+
"password": "${{ secrets.MAVEN_CENTRAL_PASSWORD }}"
219219
}]
220220
221+
221222
# Cache .m2/repository
222223
# Caching of maven dependencies
223224
- uses: actions/cache@v4
@@ -232,18 +233,15 @@ jobs:
232233
working-directory: ./prepare-release-workspace/
233234
run: brew bundle
234235

235-
- name: Create local staging directory
236-
run: mkdir -p ~/local-staging
237-
238236
- name: Stage snapshots to local staging directory
239237
working-directory: ./prepare-release-workspace/
240-
run: ./mvnw -B -ntp 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 }}
238+
run: ./mvnw -B -ntp clean package javadoc:jar gpg:sign org.sonatype.central:central-publishing-maven-plugin:publish -DskipTests=true
241239

242240
- name: Upload local staging directory
243241
uses: actions/upload-artifact@v4
244242
with:
245243
name: ${{ matrix.setup }}-local-staging
246-
path: ~/local-staging
244+
path: ./prepare-release-workspace/target/central-staging
247245
if-no-files-found: error
248246
include-hidden-files: true
249247

@@ -314,34 +312,18 @@ jobs:
314312
# all together with one maven command.
315313
- name: Merge staging repositories
316314
working-directory: ./prepare-release-workspace/
317-
run: bash ./.github/scripts/merge_local_staging.sh ~/local-staging/staging ~/macos-x86_64-local-staging/staging ~/macos-aarch64-local-staging/staging ~/linux-aarch64-local-staging/staging ~/linux-x86_64-local-staging/staging
318-
319-
# Caching of maven dependencies
320-
- uses: actions/cache@v4
321-
continue-on-error: true
322-
with:
323-
path: ~/.m2/repository
324-
key: deploy-staged-release-maven-cache-${{ hashFiles('**/pom.xml') }}
325-
restore-keys: |
326-
deploy-staged-release-maven-cache-
315+
run: bash ./.github/scripts/local_staging_merge_release.sh ~/local-staging ~/macos-x86_64-local-staging ~/macos-aarch64-local-staging ~/linux-aarch64-local-staging ~/linux-x86_64-local-staging
327316

328-
- uses: s4u/maven-settings-action@v3.0.0
329-
with:
330-
servers: |
331-
[{
332-
"id": "sonatype-nexus-staging",
333-
"username": "${{ secrets.SONATYPE_USERNAME }}",
334-
"password": "${{ secrets.SONATYPE_PASSWORD }}"
335-
}]
317+
- name: Create bundle
318+
working-directory: ./prepare-release-workspace/
319+
run: bash ./.github/scripts/bundle_create.sh ~/central-bundle.zip ~/local-staging/
336320

337-
- name: Deploy local staged artifacts
321+
- name: Upload bundle to maven central
338322
working-directory: ./prepare-release-workspace/
339-
# If we don't want to close the repository we can add -DskipStagingRepositoryClose=true
340-
run: ./mvnw -B -ntp --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
323+
run: bash ./.github/scripts/bundle_upload.sh ~/central-bundle.zip ${{ secrets.MAVEN_CENTRAL_USERNAME }} ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
341324

342325
- name: Rollback release on failure
343326
working-directory: ./prepare-release-workspace/
344327
if: ${{ failure() }}
345328
# Rollback the release in case of an failure
346329
run: bash ./.github/scripts/release_rollback.sh release.properties netty/netty-incubator-codec-ohttp main
347-

docker/docker-compose.centos-7-cross.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ services:
6868
- ~/.m2/repository:/root/.m2/repository
6969
- ~/local-staging:/root/local-staging
7070
- ..:/code
71-
command: /bin/bash -cl "cat <(echo -e \"${GPG_PRIVATE_KEY}\") | gpg --batch --import && ./mvnw -B -ntp -Plinux-aarch64 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}"
71+
command: /bin/bash -cl "cat <(echo -e \"${GPG_PRIVATE_KEY}\") | gpg --batch --import && ./mvnw -B -ntp -Plinux-aarch64 clean package javadoc:jar gpg:sign org.sonatype.central:central-publishing-maven-plugin:publish -DskipTests=true -Dgpg.passphrase=${GPG_PASSPHRASE} -Dgpg.keyname=${GPG_KEYNAME}"
7272

7373
cross-compile-aarch64-install:
7474
<<: *cross-compile-aarch64-common

docker/docker-compose.centos-7.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ services:
7878
- ~/.m2/repository:/root/.m2/repository
7979
- ~/local-staging:/root/local-staging
8080
- ..:/code
81-
command: /bin/bash -cl "cat <(echo -e \"${GPG_PRIVATE_KEY}\") | gpg --batch --import && ./mvnw -B -ntp 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}"
81+
command: /bin/bash -cl "cat <(echo -e \"${GPG_PRIVATE_KEY}\") | gpg --batch --import && ./mvnw -B -ntp clean package javadoc:jar gpg:sign org.sonatype.central:central-publishing-maven-plugin:publish -DskipTests=true -Dgpg.passphrase=${GPG_PASSPHRASE} -Dgpg.keyname=${GPG_KEYNAME}"
8282

8383
shell:
8484
<<: *common

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,16 @@
373373
</dependency>
374374
</dependencies>
375375
</plugin>
376+
<plugin>
377+
<groupId>org.sonatype.central</groupId>
378+
<artifactId>central-publishing-maven-plugin</artifactId>
379+
<version>0.7.0</version>
380+
<configuration>
381+
<publishingServerId>central</publishingServerId>
382+
<skipPublishing>true</skipPublishing>
383+
<autoPublish>false</autoPublish>
384+
</configuration>
385+
</plugin>
376386
</plugins>
377387
</build>
378388

0 commit comments

Comments
 (0)