Skip to content

Commit 0e12507

Browse files
committed
Add GHA to build and publish snapshots to maven & mvn process
Signed-off-by: xil <[email protected]>
1 parent 10b5c83 commit 0e12507

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

.github/workflows/maven-publish.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build and Publish Snapshots to Maven
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- 'main'
8+
jobs:
9+
build-and-publish-snapshots:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
id-token: write
14+
contents: write
15+
16+
steps:
17+
- uses: actions/setup-java@v3
18+
with:
19+
distribution: temurin # Temurin is a distribution of adoptium
20+
java-version: 21
21+
- uses: actions/checkout@v3
22+
- uses: aws-actions/configure-aws-credentials@v1
23+
with:
24+
role-to-assume: ${{ secrets.PUBLISH_SNAPSHOTS_ROLE }}
25+
aws-region: us-east-1
26+
- name: publish snapshots to maven
27+
run: |
28+
export SONATYPE_USERNAME=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-username --query SecretString --output text)
29+
export SONATYPE_PASSWORD=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-password --query SecretString --output text)
30+
echo "::add-mask::$SONATYPE_USERNAME"
31+
echo "::add-mask::$SONATYPE_PASSWORD"
32+
./tools/java/package_proto_jar.sh

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
77
### Added
88
- Add bulk + search protos and bazel to compile ([#5](https://github.com/opensearch-project/opensearch-protobufs/pull/5))
99
- Add scripts to create java opensearch-protobuf-1.0.0.jar ([#6](https://github.com/opensearch-project/opensearch-protobufs/pull/6))
10+
- Add GHA to build and publish snapshots to maven & add mvn process ([#11](https://github.com/opensearch-project/opensearch-protobufs/pull/11))
1011

1112
### Removed
1213

tools/java/package_proto_jar.sh

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Configuration
55
GROUP_ID="org.opensearch.protobuf"
66
ARTIFACT_ID="opensearch-protobuf"
7-
VERSION="1.0.0"
7+
VERSION="1.0.0-SNAPSHOT"
88
JAR_NAME="${ARTIFACT_ID}-${VERSION}.jar"
99
POM_NAME="${ARTIFACT_ID}-${VERSION}.pom"
1010
OUTPUT_DIR="generated/maven"
@@ -216,3 +216,15 @@ echo ""
216216
echo "dependencies {"
217217
echo " implementation '${GROUP_ID}:${ARTIFACT_ID}:${VERSION}'"
218218
echo "}"
219+
220+
mvn deploy:deploy-file \
221+
-Dfile=${OUTPUT_DIR}/${JAR_NAME} \
222+
-DpomFile="${OUTPUT_DIR}/META-INF/maven/${GROUP_ID}/${ARTIFACT_ID}/pom.xml" \
223+
-DgroupId=${GROUP_ID} \
224+
-DartifactId=${ARTIFACT_ID} \
225+
-Dversion=${VERSION} \
226+
-Dpackaging=jar \
227+
-DrepositoryId=Snapshots \
228+
-Durl=https://aws.oss.sonatype.org/content/repositories/snapshots/ \
229+
-Dusername=$SONATYPE_USERNAME \
230+
-Dpassword=$SONATYPE_PASSWORD

0 commit comments

Comments
 (0)