Skip to content

Commit f88fc6b

Browse files
authored
Migrate to maven central (#201)
* update to use maven central * use ubuntu-latest for ci * use [email protected] * use role to assume instead * add id-token permission * use crt resource for testing * hardcode endpoint value to test CI * test with aws credentials set in env * revert endpoint path and secrets * test with CRT CI role * use CRT credential, hardcoded * hard coded to not use websocket * revert test properties * DEBUG: print system property * DEBUG: more logs * update websocket test properties * setup environment variable for websocket test * use default thing name * revert to use SDK CI role * clean up comments * cleanup test changes * clean up * cleanup
1 parent 8dbe18e commit f88fc6b

File tree

6 files changed

+40
-32
lines changed

6 files changed

+40
-32
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ env:
1212
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
1313
PACKAGE_NAME: aws-iot-device-sdk-java
1414
RUN: ${{ github.run_id }}-${{ github.run_number }}
15-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
16-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
1715
AWS_DEFAULT_REGION: us-east-1
16+
SDK_V1_CI_ROLE: ${{ secrets.CI_SDK_V1_ROLE_ARN }}
17+
18+
permissions:
19+
id-token: write # This is required for requesting the JWT
1820

1921
jobs:
2022
java-compat:
21-
runs-on: ubuntu-20.04
23+
runs-on: ubuntu-latest
2224
strategy:
2325
fail-fast: false
2426
matrix:
@@ -30,12 +32,23 @@ jobs:
3032
- name: Checkout Sources
3133
uses: actions/checkout@v2
3234
- name: Setup Java
33-
uses: actions/setup-java@v2
35+
uses: actions/setup-java@v3.14.1
3436
with:
3537
distribution: temurin
3638
java-version: ${{ matrix.version }}
3739
cache: maven
40+
- name: Configure AWS Credentials
41+
id: creds
42+
uses: aws-actions/configure-aws-credentials@v4
43+
with:
44+
role-to-assume: ${{ env.SDK_V1_CI_ROLE }}
45+
aws-region: ${{ env.AWS_DEFAULT_REGION }}
46+
output-credentials: true
3847
- name: Build ${{ env.PACKAGE_NAME }} + consumers
3948
run: |
4049
java -version
4150
mvn -B test
51+
env:
52+
AWS_ACCESS_KEY_ID: ${{ steps.creds.outputs.aws-access-key-id }}
53+
AWS_SECRET_ACCESS_KEY: ${{ steps.creds.outputs.aws-secret-access-key }}
54+
AWS_SESSION_TOKEN: ${{ steps.creds.outputs.aws-session-token }}

aws-iot-device-sdk-java/src/test/java/com/amazonaws/services/iot/client/CredentialUtil.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,14 @@ public static AWSIotMqttClient newClient(String clientEndpoint, String clientId,
7373
String privateMaterial = CredentialUtil.getSecret(privateMateiralARN);
7474

7575
if (isWebSocket == false) {
76-
return newMqttTlsClient(clientEndpoint, clientId+TEST_UID, publicMaterial,
77-
privateMaterial);
76+
return newMqttTlsClient(clientEndpoint, clientId+TEST_UID, publicMaterial, privateMaterial);
7877
} else {
79-
return new AWSIotMqttClient(clientEndpoint, clientId+TEST_UID, publicMaterial, privateMaterial);
78+
// For WebSocket, the public material is the AWS access key id and the private material is the AWS secret access key.
79+
// Grab the credential info from environment variables.
80+
String accessKeyId = System.getenv("AWS_ACCESS_KEY_ID");
81+
String privateKey = System.getenv("AWS_SECRET_ACCESS_KEY");
82+
String sessionToken = System.getenv("AWS_SESSION_TOKEN");
83+
return new AWSIotMqttClient(clientEndpoint, clientId+TEST_UID, accessKeyId, privateKey, sessionToken);
8084
}
8185
}
8286

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
clientEndpoint=ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com
1+
clientEndpoint=a16523t7iy5uyg-ats.iot.us-east-1.amazonaws.com
22
clientId=DefaultClientId
33
thingName=DefaultThingName
4-
privateMaterial=arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestPrivateKey-vNUQU8
5-
publicMaterial=arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestCertificate-vTRwjE
4+
privateMaterial=arn:aws:secretsmanager:us-east-1:123124136734:secret:unit-test/privatekey-p8-d3pMKx
5+
publicMaterial=arn:aws:secretsmanager:us-east-1:123124136734:secret:unit-test/certificate-iZBV7L
66
isWebSocket=false
77
authMode=CertificateMutualAuthentication
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
clientEndpoint=ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com
1+
clientEndpoint=a16523t7iy5uyg-ats.iot.us-east-1.amazonaws.com
22
clientId=DefaultClientId
33
thingName=DefaultThingName
4-
privateMaterial=arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestWebsocketSecretAccessKey-MKTSaV
5-
publicMaterial=arn:aws:secretsmanager:us-east-1:123124136734:secret:V1IotSdkIntegrationTestWebsocketAccessKeyId-1YdB9z
4+
privateMaterial=arn:aws:secretsmanager:us-east-1:123124136734:secret:unit-test/privatekey-p8-d3pMKx
5+
publicMaterial=arn:aws:secretsmanager:us-east-1:123124136734:secret:unit-test/certificate-iZBV7L
66
isWebSocket=true
77
authMode=MqttOverWebSocketSigV4Signing

codebuild/cd/promote-release.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ phases:
2929
- cp -r maven-gpg aws-iot-device-sdk-java-samples/maven-gpg
3030
# install settings.xml to ~/.m2/settings.xml
3131
- mkdir -p $HOME/.m2
32-
- aws s3 cp s3://code-sharing-aws-crt/iot-sdk-java-v1.settings.xml $HOME/.m2/settings.xml
32+
- aws s3 cp s3://code-sharing-aws-crt/iot-sdk-java-v1.settings.central.xml $HOME/.m2/settings.xml
3333
- aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token/V1 > sonatype_secret
3434
- jq fromjson sonatype_secret > sonatype_json
3535
- export ST_PASSWORD=$(jq -r '.password' sonatype_json)
@@ -49,10 +49,8 @@ phases:
4949
build:
5050
commands:
5151
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java
52-
# Trigger the release of the last staged package in the staging repository
53-
- mvn -s $HOME/.m2/settings.xml clean package -Dmaven.test.skip=true
54-
- mvn -s $HOME/.m2/settings.xml clean deploy -P publishing -e -X
55-
- mvn -s $HOME/.m2/settings.xml nexus-staging:release -e -X
52+
- mvn -B versions:set -DnewVersion=${PKG_VERSION}
53+
- mvn clean deploy -P publishing -Dmaven.test.skip=true
5654

5755
cache:
5856
paths:

pom.xml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<version>0.0.1-dev</version>
66
<packaging>pom</packaging>
77
<name>AWS IoT Device SDK for Java</name>
8-
<description>The AWS IoT Device SDK for Java provides Java APIs for devices to connect to AWS IoT service using the MQTT protocol. The SDK also provides support for AWS IoT specific features, such as Thing Shadow and Thing Shadow abstraction.</description>
8+
<description>The SDK is in maintenance mode, and no longer receive feature updates. Checkout aws-iot-device-sdk for new features. The AWS IoT Device SDK for Java provides Java APIs for devices to connect to AWS IoT service using the MQTT protocol. The SDK also provides support for AWS IoT specific features, such as Thing Shadow and Thing Shadow abstraction.</description>
99
<url>https://aws.amazon.com/iot/sdk</url>
1010
<licenses>
1111
<license>
@@ -34,23 +34,16 @@
3434
<properties>
3535
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3636
</properties>
37-
<distributionManagement>
38-
<snapshotRepository>
39-
<id>ossrh</id>
40-
<url>https://aws.oss.sonatype.org/content/repositories/snapshots</url>
41-
</snapshotRepository>
42-
</distributionManagement>
4337
<build>
4438
<plugins>
4539
<plugin>
46-
<groupId>org.sonatype.plugins</groupId>
47-
<artifactId>nexus-staging-maven-plugin</artifactId>
48-
<version>1.6.8</version>
40+
<groupId>org.sonatype.central</groupId>
41+
<artifactId>central-publishing-maven-plugin</artifactId>
42+
<version>0.7.0</version>
4943
<extensions>true</extensions>
5044
<configuration>
51-
<serverId>ossrh</serverId>
52-
<nexusUrl>https://aws.oss.sonatype.org/</nexusUrl>
53-
<autoReleaseAfterClose>false</autoReleaseAfterClose>
45+
<publishingServerId>central</publishingServerId>
46+
<autoPublish>true</autoPublish>
5447
</configuration>
5548
</plugin>
5649
<plugin>
@@ -66,7 +59,7 @@
6659
<plugin>
6760
<groupId>org.apache.maven.plugins</groupId>
6861
<artifactId>maven-gpg-plugin</artifactId>
69-
<version>1.6</version>
62+
<version>3.2.7</version>
7063
<executions>
7164
<execution>
7265
<id>sign-artifacts</id>

0 commit comments

Comments
 (0)