Skip to content

Commit 2615c63

Browse files
Onboarding new maven snapshots publishing to s3 (opensearch-sdk-java)
Signed-off-by: Peter Zhu <[email protected]>
1 parent 654a735 commit 2615c63

File tree

5 files changed

+41
-21
lines changed

5 files changed

+41
-21
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,22 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v4
15+
- name: Set up JDK 21
16+
uses: actions/setup-java@v4
17+
with:
18+
java-version: 21
19+
distribution: temurin
1520
- name: Spotless Check
1621
run: ./gradlew spotlessCheck
1722
javadoc:
1823
runs-on: ubuntu-latest
1924
steps:
2025
- uses: actions/checkout@v4
26+
- name: Set up JDK 21
27+
uses: actions/setup-java@v4
28+
with:
29+
java-version: 21
30+
distribution: temurin
2131
- name: Javadoc CheckStyle
2232
run: ./gradlew checkstyleMain
2333
- name: Javadoc Check
@@ -43,6 +53,11 @@ jobs:
4353
needs: [check]
4454
runs-on: ubuntu-latest
4555
steps:
46-
- uses: actions/checkout@v4
47-
- name: Publish to Maven Local
48-
run: ./gradlew publishToMavenLocal
56+
- uses: actions/checkout@v4
57+
- name: Set up JDK 21
58+
uses: actions/setup-java@v4
59+
with:
60+
java-version: 21
61+
distribution: temurin
62+
- name: Publish to Maven Local
63+
run: ./gradlew publishToMavenLocal

.github/workflows/publish-snapshots.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@ jobs:
2121
with:
2222
java-version: 21
2323
distribution: temurin
24+
- name: Load secret
25+
uses: 1password/load-secrets-action@v3
26+
with:
27+
# Export loaded secrets as environment variables
28+
export-env: true
29+
env:
30+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
31+
MAVEN_SNAPSHOTS_S3_REPO: op://opensearch-infra-secrets/maven-snapshots-s3/repo
32+
MAVEN_SNAPSHOTS_S3_ROLE: op://opensearch-infra-secrets/maven-snapshots-s3/role
2433
- name: Configure AWS credentials
25-
uses: aws-actions/configure-aws-credentials@v4
34+
uses: aws-actions/configure-aws-credentials@v5
2635
with:
27-
role-to-assume: ${{ secrets.PUBLISH_SNAPSHOTS_ROLE }}
36+
role-to-assume: ${{ env.MAVEN_SNAPSHOTS_S3_ROLE }}
2837
aws-region: us-east-1
2938
- name: publish snapshots to maven
30-
run: |
31-
export SONATYPE_USERNAME=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-username --query SecretString --output text)
32-
export SONATYPE_PASSWORD=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-password --query SecretString --output text)
33-
echo "::add-mask::$SONATYPE_USERNAME"
34-
echo "::add-mask::$SONATYPE_PASSWORD"
35-
./gradlew publishMavenJavaPublicationToSnapshotsRepository
39+
run: ./gradlew publishMavenJavaPublicationToSnapshotsRepository

CREATE_YOUR_FIRST_EXTENSION.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ In your dependency management, set up a dependency on the OpenSearch SDK for Jav
2727
- Version: `1.0.0-SNAPSHOT` (compatible with OpenSearch 2.x) or `2.0.0-SNAPSHOT` (compatible with OpenSearch 3.x)
2828

2929
At general availability, dependencies will be released to the Central Repository. To use SNAPSHOT versions, add these repositories:
30-
- OpenSearch SNAPSHOT repository: https://aws.oss.sonatype.org/content/repositories/snapshots/
30+
- OpenSearch SNAPSHOT repository: https://ci.opensearch.org/ci/dbc/snapshots/maven/
3131
- Lucene snapshot repository: https://ci.opensearch.org/ci/dbc/snapshots/lucene/
3232

3333
If you use Maven, the following POM entries will work:
@@ -37,7 +37,7 @@ If you use Maven, the following POM entries will work:
3737
<repository>
3838
<id>opensearch.snapshots</id>
3939
<name>OpenSearch Snapshot Repository</name>
40-
<url>https://aws.oss.sonatype.org/content/repositories/snapshots/</url>
40+
<url>https://ci.opensearch.org/ci/dbc/snapshots/maven/</url>
4141
</repository>
4242
<repository>
4343
<id>lucene.snapshots</id>
@@ -60,7 +60,7 @@ For Gradle, specify dependencies as follows:
6060
```groovy
6161
repositories {
6262
mavenCentral()
63-
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots/" }
63+
maven { url "https://ci.opensearch.org/ci/dbc/snapshots/maven/" }
6464
maven { url "https://ci.opensearch.org/ci/dbc/snapshots/lucene/"}
6565
}
6666

RELEASING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ The release process is standard across repositories in this org and is run by a
3535
5. Increment "version" in [build.gradle](https://github.com/opensearch-project/opensearch-sdk-java/blob/main/build.gradle#L79) to the next iteration, e.g. v1.0.1.
3636

3737
## Snapshot Builds
38-
The [snapshots builds](https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/sdk/opensearch-sdk-java/) are published to sonatype using [publish-snapshots.yml](./.github/workflows/publish-snapshots.yml) workflow. Each `push` event to the main branch triggers this workflow.
38+
The [snapshots builds](https://ci.opensearch.org/ci/dbc/snapshots/maven/org/opensearch/sdk/opensearch-sdk-java/) are published to sonatype using [publish-snapshots.yml](./.github/workflows/publish-snapshots.yml) workflow. Each `push` event to the main branch triggers this workflow.

build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ buildscript {
2727
repositories {
2828
mavenLocal()
2929
mavenCentral()
30-
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
30+
maven { url "https://ci.opensearch.org/ci/dbc/snapshots/maven/" }
3131
}
3232

3333
dependencies {
@@ -130,10 +130,11 @@ publishing {
130130
if (version.toString().endsWith("SNAPSHOT")) {
131131
maven {
132132
name = "Snapshots" // optional target repository name
133-
url = "https://aws.oss.sonatype.org/content/repositories/snapshots"
134-
credentials {
135-
username "$System.env.SONATYPE_USERNAME"
136-
password "$System.env.SONATYPE_PASSWORD"
133+
url = System.getenv("MAVEN_SNAPSHOTS_S3_REPO")
134+
credentials(AwsCredentials) {
135+
accessKey = System.getenv("AWS_ACCESS_KEY_ID")
136+
secretKey = System.getenv("AWS_SECRET_ACCESS_KEY")
137+
sessionToken = System.getenv("AWS_SESSION_TOKEN")
137138
}
138139
}
139140
}
@@ -156,7 +157,7 @@ javadoc {
156157
repositories {
157158
mavenLocal()
158159
mavenCentral()
159-
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
160+
maven { url "https://ci.opensearch.org/ci/dbc/snapshots/maven/" }
160161
maven { url "https://ci.opensearch.org/ci/dbc/snapshots/lucene/"}
161162
}
162163

0 commit comments

Comments
 (0)