From 779ad57e77f7cc89f03b9cb14f0b17be51776eb2 Mon Sep 17 00:00:00 2001 From: Yesudeep Mangalapilly Date: Wed, 24 Dec 2025 16:20:08 -0800 Subject: [PATCH] docs(java): Update readme with badge, add Java readme, and add a publish script for later --- .release-please-config.json | 8 ++- .release-please-manifest.json | 3 +- README.md | 1 + docs/contributing/releases.md | 2 + java/README.md | 111 ++++++++++++++++++++++++++++++++++ scripts/publish-java.sh | 47 ++++++++++++++ 6 files changed, 170 insertions(+), 2 deletions(-) create mode 100644 java/README.md create mode 100755 scripts/publish-java.sh diff --git a/.release-please-config.json b/.release-please-config.json index a97234de2..4c1ccb6eb 100644 --- a/.release-please-config.json +++ b/.release-please-config.json @@ -84,7 +84,13 @@ "bump-patch-for-minor-pre-major": true, "draft": false, "prerelease": false, - "path": "java/**" + "path": "java/**", + "extra-files": [ + { + "type": "generic", + "path": "java/com/google/dotprompt/BUILD.bazel" + } + ] } }, "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json" diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 76f427ea8..950991bd9 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -2,5 +2,6 @@ "js": "1.1.1", "python/dotpromptz": "0.1.4", "python/handlebarrz": "0.1.3", - "go": "0.1.0" + "go": "0.1.0", + "java": "0.1.0" } diff --git a/README.md b/README.md index 60f33f36a..242761788 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ [![Go checks](https://github.com/google/dotprompt/actions/workflows/go.yml/badge.svg)](https://github.com/google/dotprompt/actions/workflows/go.yml) [![Python checks](https://github.com/google/dotprompt/actions/workflows/python.yml/badge.svg)](https://github.com/google/dotprompt/actions/workflows/python.yml) [![JS checks](https://github.com/google/dotprompt/actions/workflows/test.yml/badge.svg)](https://github.com/google/dotprompt/actions/workflows/test.yml) +[![Java checks](https://github.com/google/dotprompt/actions/workflows/java.yml/badge.svg)](https://github.com/google/dotprompt/actions/workflows/java.yml) [![Ask Codewiki](https://codewiki.google/github.com/google/dotprompt)](https://codewiki.google/github.com/google/dotprompt) [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/google/dotprompt) diff --git a/docs/contributing/releases.md b/docs/contributing/releases.md index 9a2a54a75..a126ea1d4 100644 --- a/docs/contributing/releases.md +++ b/docs/contributing/releases.md @@ -15,6 +15,7 @@ packages: * `python/dotpromptz/` - Python implementation of dotprompt * `python/handlebarrz/` - Python implementation of handlebarrz * `go/` - Go implementation of dotprompt +* `java/` - Java implementation of dotprompt ## How It Works @@ -62,6 +63,7 @@ To target specific packages, use these scopes: * `py/dotpromptz`: For changes to the Python dotpromptz package * `py/handlebarrz`: For changes to the Python handlebarrz package * `go`: For changes to the Go implementation +* `java`: For changes to the Java implementation * `deps`: For dependency updates ### Examples diff --git a/java/README.md b/java/README.md new file mode 100644 index 000000000..ec7a33caa --- /dev/null +++ b/java/README.md @@ -0,0 +1,111 @@ +# Java Dotprompt + +This directory contains the Java implementation of the Dotprompt library. + +## Usage + +Add the following dependency to your project: + +**Maven:** +```xml + + com.google.dotprompt + dotprompt + 0.1.0 + +``` + +**Gradle:** +```groovy +implementation 'com.google.dotprompt:dotprompt:0.1.0' +``` + +**Bazel:** +```starlark +maven_install( + artifacts = [ + "com.google.dotprompt:dotprompt:0.1.0", + ], + # ... +) +``` + +## Building + +```bash +bazel build //java/com/google/dotprompt:dotprompt +``` + +## Testing + +```bash +bazel test //java/com/google/dotprompt/... +``` + +--- + +# Deploying to Maven Central + +This section describes the process for releasing the `dotprompt` Java library to Maven Central. + +## Prerequisites + +1. **GPG Keys**: You need a GPG key pair to sign artifacts. + * Export the private key: `gpg --armor --export-secret-keys ` + * Note the passphrase. + +2. **Sonatype OSSRH Account**: You need an account on [s01.oss.sonatype.org](https://s01.oss.sonatype.org/) with access to the `com.google.dotprompt` group ID. + +## GitHub Secrets Configuration + +Configure these secrets in the repository settings (Settings → Secrets and variables → Actions): + +| Secret Name | Description | +|-------------------------|---------------------------------------| +| `OSSRH_USERNAME` | Your Sonatype username | +| `OSSRH_TOKEN` | Your Sonatype password or user token | +| `MAVEN_GPG_PRIVATE_KEY` | ASCII-armored GPG private key | +| `MAVEN_GPG_PASSPHRASE` | Passphrase for your GPG key | + +## Release Process + +Releases are managed by [release-please](https://github.com/googleapis/release-please). + +### Automated Flow + +1. **Commit changes** to `main` using conventional commit messages with the `java` scope: + ``` + feat(java): add new template helper + fix(java): resolve parsing issue + ``` + +2. **Release-please creates a PR** automatically with: + * Updated version in `BUILD.bazel` + * Generated `CHANGELOG.md` + +3. **Merge the release PR** when ready. + +4. **Publishing is automated** via `.github/workflows/publish_java.yml`: + * Triggers on release creation + * Signs and uploads to Maven Central + +### Verification + +* Check the GitHub Actions workflow logs for success. +* Log in to [Sonatype OSSRH](https://s01.oss.sonatype.org/) to verify the staging repository. +* After sync (typically 10-30 minutes), verify on [Maven Central](https://search.maven.org/search?q=g:com.google.dotprompt). + +## Local Testing (Dry Run) + +To verify artifacts build correctly without publishing: + +```bash +bazel build //java/com/google/dotprompt:dotprompt_pkg +``` + +To inspect the generated POM: + +```bash +bazel build //java/com/google/dotprompt:dotprompt_pkg-pom +cat bazel-bin/java/com/google/dotprompt/dotprompt_pkg-pom.xml +``` diff --git a/scripts/publish-java.sh b/scripts/publish-java.sh new file mode 100755 index 000000000..47f9a6b3a --- /dev/null +++ b/scripts/publish-java.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +set -euo pipefail + +# Usage: ./scripts/publish-java.sh + +if [ "$#" -ne 4 ]; then + echo "Usage: $0 " + exit 1 +fi + +GPG_KEY_PATH=$1 +GPG_PASSPHRASE=$2 +MAVEN_USER=$3 +MAVEN_PASSWORD=$4 + +# Define the deployment repository URL (Sonatype OSSRH) +DEPLOY_ENV="release" # or "snapshot" if desired, but typically we want release for tags. +# Bazel java_export allows specifying deployment via flags or properties. +# We will use the standard command structure generated by java_export. + +echo "Publishing Java artifacts..." + +bazel run //java/com/google/dotprompt:dotprompt_pkg.publish -- \ + --define "maven_repo=https://oss.sonatype.org/service/local/staging/deploy/maven2/" \ + --define "maven_user=$MAVEN_USER" \ + --define "maven_password=$MAVEN_PASSWORD" \ + --define "gpg_sign=true" \ + --define "gpg_key=$GPG_KEY_PATH" \ + --define "gpg_passphrase=$GPG_PASSPHRASE" + +echo "Publishing complete."