Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GHA to build and publish snapshots to maven & add mvn process on package_proto_jar.sh #11

Merged
merged 1 commit into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build and Publish Snapshots to Maven

on:
workflow_dispatch:
push:
branches:
- 'main'
jobs:
build-and-publish-snapshots:
runs-on: ubuntu-latest

permissions:
id-token: write
contents: write

steps:
- uses: actions/setup-java@v3
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: 21
- uses: actions/checkout@v3
- uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.PUBLISH_SNAPSHOTS_ROLE }}
aws-region: us-east-1
- name: publish snapshots to maven
run: |
export SONATYPE_USERNAME=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-username --query SecretString --output text)
export SONATYPE_PASSWORD=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-password --query SecretString --output text)
echo "::add-mask::$SONATYPE_USERNAME"
echo "::add-mask::$SONATYPE_PASSWORD"
./tools/java/package_proto_jar.sh
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Added
- Add bulk + search protos and bazel to compile ([#5](https://github.com/opensearch-project/opensearch-protobufs/pull/5))
- Add scripts to create java opensearch-protobuf-1.0.0.jar ([#6](https://github.com/opensearch-project/opensearch-protobufs/pull/6))
- Add GHA to build and publish snapshots to maven & add mvn process ([#11](https://github.com/opensearch-project/opensearch-protobufs/pull/11))

### Removed

Expand Down
14 changes: 13 additions & 1 deletion tools/java/package_proto_jar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Configuration
GROUP_ID="org.opensearch.protobuf"
ARTIFACT_ID="opensearch-protobuf"
VERSION="1.0.0"
VERSION="1.0.0-SNAPSHOT"
JAR_NAME="${ARTIFACT_ID}-${VERSION}.jar"
POM_NAME="${ARTIFACT_ID}-${VERSION}.pom"
OUTPUT_DIR="generated/maven"
Expand Down Expand Up @@ -216,3 +216,15 @@ echo ""
echo "dependencies {"
echo " implementation '${GROUP_ID}:${ARTIFACT_ID}:${VERSION}'"
echo "}"

mvn deploy:deploy-file \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the mvn deploy command should be added to the GHA file maven-publish.yml instead of package_proto_jar.sh, so we can use the latter script for creating local jars for testing, without accidentally publishing to maven central

-Dfile=${OUTPUT_DIR}/${JAR_NAME} \
-DpomFile="${OUTPUT_DIR}/META-INF/maven/${GROUP_ID}/${ARTIFACT_ID}/pom.xml" \
-DgroupId=${GROUP_ID} \
-DartifactId=${ARTIFACT_ID} \
-Dversion=${VERSION} \
-Dpackaging=jar \
-DrepositoryId=Snapshots \
-Durl=https://aws.oss.sonatype.org/content/repositories/snapshots/ \
-Dusername=$SONATYPE_USERNAME \
-Dpassword=$SONATYPE_PASSWORD