Skip to content

Commit a204fa4

Browse files
authored
Publish snapshots to maven via GHA (#362)
Signed-off-by: Ashish Agrawal <ashisagr@amazon.com>
1 parent af292c3 commit a204fa4

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Publish snapshots to maven
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [
7+
main
8+
1.*
9+
2.*
10+
]
11+
12+
jobs:
13+
build-and-publish-snapshots:
14+
strategy:
15+
fail-fast: false
16+
if: github.repository == 'opensearch-project/common-utils'
17+
runs-on: ubuntu-latest
18+
19+
permissions:
20+
id-token: write
21+
contents: write
22+
23+
steps:
24+
- uses: actions/setup-java@v3
25+
with:
26+
distribution: temurin # Temurin is a distribution of adoptium
27+
java-version: 17
28+
- uses: actions/checkout@v3
29+
- uses: aws-actions/configure-aws-credentials@v1
30+
with:
31+
role-to-assume: ${{ secrets.PUBLISH_SNAPSHOTS_ROLE }}
32+
aws-region: us-east-1
33+
- name: publish snapshots to maven
34+
run: |
35+
export SONATYPE_USERNAME=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-username --query SecretString --output text)
36+
export SONATYPE_PASSWORD=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-password --query SecretString --output text)
37+
echo "::add-mask::$SONATYPE_USERNAME"
38+
echo "::add-mask::$SONATYPE_PASSWORD"
39+
./gradlew publishShadowPublicationToSnapshotsRepository

build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ publishing {
165165
name = 'staging'
166166
url = "${rootProject.buildDir}/local-staging-repo"
167167
}
168+
maven {
169+
name = "Snapshots"
170+
url = "https://aws.oss.sonatype.org/content/repositories/snapshots"
171+
credentials {
172+
username "$System.env.SONATYPE_USERNAME"
173+
password "$System.env.SONATYPE_PASSWORD"
174+
}
175+
}
168176
}
169177
publications {
170178
shadow(MavenPublication) {

0 commit comments

Comments
 (0)