Skip to content

Commit b7dec97

Browse files
authored
Migrate CD to maven central (#891)
1 parent 479239d commit b7dec97

16 files changed

+341
-212
lines changed

android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ if (project.hasProperty("sonatypeUsername") && project.hasProperty("sonatypePass
2020
apply plugin: 'io.github.gradle-nexus.publish-plugin'
2121
nexusPublishing {
2222
repositories {
23-
create("awsNexus") {
24-
nexusUrl.set(uri("https://aws.oss.sonatype.org/service/local/"))
25-
snapshotRepositoryUrl.set(uri("https://aws.oss.sonatype.org/content/repositories/snapshots/"))
23+
sonatype {
24+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
25+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
2626
username.set(project.property("sonatypeUsername") as String)
2727
password.set(project.property("sonatypePassword") as String)
2828
}

android/crt/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ afterEvaluate {
199199

200200
repositories {
201201
maven {
202-
def snapshotRepo = "https://aws.oss.sonatype.org/content/repositories/snapshots"
203-
def releaseRepo = "https://aws.oss.sonatype.org/"
202+
def snapshotRepo = "https://central.sonatype.com/repository/maven-snapshots/"
203+
def releaseRepo = "https://ossrh-staging-api.central.sonatype.com/"
204204
url = version.endsWith('SNAPSHOT') ? snapshotRepo : releaseRepo
205205
}
206206
}

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ publishing {
124124
}
125125
repositories {
126126
maven {
127-
val releasesRepo = uri("https://aws.oss.sonatype.org/")
128-
val snapshotRepo = uri("https://aws.oss.sonatype.org/content/repositories/snapshots")
127+
val releasesRepo = uri("https://ossrh-staging-api.central.sonatype.com/")
128+
val snapshotRepo = uri("https://central.sonatype.com/repository/maven-snapshots/")
129129
url = if (version.toString().endsWith("SNAPSHOT")) snapshotRepo else releasesRepo
130130
}
131131
}

codebuild/cd/deploy-platform-specific-jars.sh renamed to codebuild/cd/bundle-platform-specific-jars.sh

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@
22

33
set -ex
44

5-
if [[ $DEPLOY_VERSION = *-SNAPSHOT ]]; then
6-
# snapshot doesn't need to gpg sign the file to deploy
7-
DEPLOY_FILE_GOAL=deploy:deploy-file
8-
DEPLOY_REPOSITORY_URL=https://aws.oss.sonatype.org/content/repositories/snapshots
9-
else
10-
# Need to sign the file to deploy to staging repo
11-
# pin to 3.1.0, somehow the latest 3.2.0 breaks the file deploy with 401.
12-
DEPLOY_FILE_GOAL=org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign-and-deploy-file
13-
DEPLOY_REPOSITORY_URL=https://aws.oss.sonatype.org:443/service/local/staging/deployByRepositoryId/${STAGING_REPO_ID}
14-
fi
5+
DEPLOY_FILE_GOAL=org.apache.maven.plugins:maven-gpg-plugin:sign-and-deploy-file
6+
DEPLOY_DIR_URL=file://${BUNDLE_DIR}
7+
158

169
CLASSIFIERS_ARRAY=("linux-armv6" "linux-armv7" "linux-aarch_64" "linux-x86_32" "linux-x86_64" "osx-aarch_64" "osx-x86_64" "windows-x86_32" "windows-x86_64" "linux-x86_64-musl" "linux-armv7-musl" "linux-aarch_64-musl" "fips-where-available")
1710

@@ -28,12 +21,11 @@ TYPES=${TYPES::-1}
2821

2922

3023
mvn -B -X $DEPLOY_FILE_GOAL \
31-
-Dgpg.passphrase=$GPG_PASSPHRASE \
3224
-DgroupId=software.amazon.awssdk.crt -DartifactId=aws-crt -Dpackaging=jar \
3325
-Dversion=$DEPLOY_VERSION \
3426
-Dfile=./target/aws-crt-$DEPLOY_VERSION.jar \
3527
-Dfiles=$FILES \
3628
-Dclassifiers=$CLASSIFIERS \
3729
-Dtypes=$TYPES \
3830
-DpomFile=pom.xml \
39-
-DrepositoryId=ossrh -Durl=$DEPLOY_REPOSITORY_URL
31+
-Durl=$DEPLOY_DIR_URL
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
version: 0.2
2+
# this buildspec assumes the ubuntu image
3+
# This job is responsible for deploying and test a snapshot version of the aws-crt-java library
4+
phases:
5+
install:
6+
commands:
7+
- sudo add-apt-repository ppa:openjdk-r/ppa
8+
- sudo apt-get update -y
9+
- sudo apt-get install openjdk-11-jdk-headless maven wget unzip -y -f
10+
pre_build:
11+
commands:
12+
- cd $CODEBUILD_SRC_DIR/aws-crt-java
13+
- export PKG_VERSION=$(git describe --tags | cut -f2 -dv)
14+
- echo $PKG_VERSION
15+
- mkdir -p target/cmake-build/lib
16+
# mv all the platform-specific jars to target/
17+
- aws s3 cp --recursive s3://aws-crt-java-pipeline/v${PKG_VERSION}/jar $CODEBUILD_SRC_DIR/aws-crt-java/target/
18+
# cp all the shared libs to cmake-build/lib/
19+
- aws s3 cp --recursive s3://aws-crt-java-pipeline/v${PKG_VERSION}/lib $CODEBUILD_SRC_DIR/aws-crt-java/target/cmake-build/lib
20+
# log the downloaded files
21+
- ls -alR $CODEBUILD_SRC_DIR/aws-crt-java/target
22+
# install settings.xml to ~/.m2/settings.xml
23+
- mkdir -p $HOME/.m2
24+
- aws s3 cp s3://code-sharing-aws-crt/aws-crt-java.settings.token.xml $HOME/.m2/settings.xml
25+
# import gpg key
26+
- aws s3 cp s3://code-sharing-aws-crt/aws-sdk-common-runtime.key.asc /tmp/aws-sdk-common-runtime.key.asc
27+
# for https://github.com/keybase/keybase-issues/issues/2798
28+
- export GPG_TTY=$(tty)
29+
- gpg --batch --import /tmp/aws-sdk-common-runtime.key.asc
30+
# refer to https://maven.apache.org/plugins/maven-gpg-plugin/usage.html
31+
- export MAVEN_GPG_PASSPHRASE=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id aws-sdk-common-runtime.key.asc/password --region us-east-1 | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
32+
- export ST_USERNAME=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token --region us-east-1 | cut -f2 -d":" | cut -f1 -d"," | sed -e 's/[\\\"\}]//g')
33+
- export ST_PASSWORD=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token --region us-east-1 | cut -f3 -d":" | sed -e 's/[\\\"\}]//g')
34+
# Use the username and password from secret manager to update the settings
35+
- sed -i 's|token-username|'"$ST_USERNAME"'|g' $HOME/.m2/settings.xml
36+
- sed -i 's|token-password|'"$ST_PASSWORD"'|g' $HOME/.m2/settings.xml
37+
38+
build:
39+
commands:
40+
# --- DEPLOY SNAPSHOT ---
41+
- cd $CODEBUILD_SRC_DIR/aws-crt-java
42+
# update the version to match the git tag, make a snapshot version we can test
43+
- export DEPLOY_VERSION=${PKG_VERSION}-SNAPSHOT
44+
- mvn -B versions:set -DnewVersion=${DEPLOY_VERSION}
45+
# do a full build/deploy, but skip shared libs and tests, since the shared libs were artifacts above
46+
- mvn -B deploy -Prelease -Dshared-lib.skip=true -Dmaven.test.skip=true
47+
48+
post_build:
49+
commands:
50+
# --- TEST SNAPSHOT ---
51+
- mvn -B dependency:get -DrepoUrl=https://central.sonatype.com/repository/maven-snapshots/ -Dartifact=software.amazon.awssdk.crt:aws-crt:${DEPLOY_VERSION} -Dtransitive=false
52+
53+
cache:
54+
paths:
55+
- "/root/.m2/**/*"

codebuild/cd/deploy-snapshot-android.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

codebuild/cd/deploy-snapshot.yml

Lines changed: 0 additions & 77 deletions
This file was deleted.

codebuild/cd/fips-where-available-jar-build.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
version: 0.2
2-
#this buildspec assumes the aws-common-runtime/ubuntu-16.04 image
3-
# This job is responsible for artifacting the JAR which will have all of the other shared libs stuffed
4-
# into it once all platforms are built and artifacted
52
phases:
63
install:
74
commands:

codebuild/cd/promote-release.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

codebuild/cd/publish-android.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
set -o pipefail # Make sure one process in pipe fail gets bubble up
5+
6+
git submodule update --init
7+
cd ./android
8+
9+
# Check if promote release mode is enabled
10+
PROMOTE_RELEASE="${PROMOTE_RELEASE:-false}"
11+
12+
GPG_KEY=$(cat /tmp/aws-sdk-common-runtime.key.asc)
13+
# Publish and release
14+
# As May30th, 2025, the Sonatype OSSRH has been deprecated and replaced with Central Publisher and the new API does't support `findSonatypeStagingRepository`.
15+
# the release will need to be invoked within the same call.
16+
# https://github.com/gradle-nexus/publish-plugin/issues/379
17+
18+
if [ "$PROMOTE_RELEASE" = "true" ]; then
19+
# close and release the staging repository to promote release
20+
../gradlew -PsigningKey=$"$GPG_KEY" -PsigningPassword=$MAVEN_GPG_PASSPHRASE -PsonatypeUsername=$ST_USERNAME -PsonatypePassword=$ST_PASSWORD publishToSonatype closeAndReleaseSonatypeStagingRepository
21+
else
22+
# close the staging repository without promoting release. NOTES: you need to manually clean up the staging repository in Maven Central.
23+
../gradlew -PsigningKey=$"$GPG_KEY" -PsigningPassword=$MAVEN_GPG_PASSPHRASE -PsonatypeUsername=$ST_USERNAME -PsonatypePassword=$ST_PASSWORD publishToSonatype closeSonatypeStagingRepository
24+
fi

0 commit comments

Comments
 (0)