Skip to content
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
8 changes: 7 additions & 1 deletion .release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 2 additions & 0 deletions docs/contributing/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
111 changes: 111 additions & 0 deletions java/README.md
Original file line number Diff line number Diff line change
@@ -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
<dependency>
<groupId>com.google.dotprompt</groupId>
<artifactId>dotprompt</artifactId>
<version>0.1.0</version>
</dependency>
```

**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 <KEY_ID>`
* 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
```
47 changes: 47 additions & 0 deletions scripts/publish-java.sh
Original file line number Diff line number Diff line change
@@ -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 <gpg_sign_key_path> <gpg_passphrase> <maven_user> <maven_password>

if [ "$#" -ne 4 ]; then
echo "Usage: $0 <gpg_sign_key_path> <gpg_passphrase> <maven_user> <maven_password>"
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."
Loading