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
17 changes: 10 additions & 7 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Maven Publish
on:
# Run by hand on a tag to retry a failed publish.
workflow_dispatch:
release:
types: [published]
push:
tags:
- "v*"
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -20,14 +22,15 @@ jobs:
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Check release tag matches pom version
if: github.event_name == 'release'
# The tag is the only source of the version; pom.xml holds a placeholder.
- name: Set the version from the tag
run: |
VERSION=$(mvn -q help:evaluate -Dexpression=project.version -DforceStdout)
if [ "${GITHUB_REF_NAME#v}" != "$VERSION" ]; then
echo "::error::Release tag $GITHUB_REF_NAME does not match pom version $VERSION"
if ! [[ "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]]; then
echo "::error::$GITHUB_REF_NAME is not a version tag such as v1.2.3"
exit 1
fi
mvn -q org.codehaus.mojo:versions-maven-plugin:2.18.0:set \
-DnewVersion="${GITHUB_REF_NAME#v}" -DgenerateBackupPoms=false

- name: Publish to Apache Maven Central
run: mvn clean deploy
Expand Down
36 changes: 36 additions & 0 deletions .vesnik.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# vesnik tags releases and writes the GitHub Release notes for `just release` and
# `just hotfix-release`: https://github.com/nklmilojevic/vesnik
#
# The tag is the only source of the version. vesnik never commits: the publish
# workflow writes the version from the tag into pom.xml before it deploys to Maven Central.

provider: claude
model: claude-haiku-5-5

# The SDK is public. GitHub's generated notes copy PR titles, which carry internal
# ticket keys, so a release without the model stops instead of using them.
ai:
on_error: fail

style:
preset: ste100
product: "MailerSend Java SDK for the MailerSend API; release notes are read by developers who use the SDK."
rules:
- "Never write ticket keys such as MSD-15283 or SRE-76231, branch names, or names of internal tools and processes."
- "Describe each change by what it adds, changes or fixes for developers who use the SDK, such as the endpoint, method or option."
- "Leave out merge commits, Renovate dependency updates (\"chore(deps): ...\"), and version bump commits unless they change behavior."
- "Leave out reverted changes, and \"Fix\", \"Nits\" or \"update docs\" commits unless they change behavior."

github:
append_generated_notes: false

changelog:
enabled: false

branch: main

breaking_bumps_minor: true

packages:
- path: .
ecosystem: none
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

MailerSend Java SDK

[![Maven Central](https://img.shields.io/maven-central/v/com.mailersend/java-sdk)](https://central.sonatype.com/artifact/com.mailersend/java-sdk)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)

# Table of Contents
Expand Down Expand Up @@ -192,17 +193,19 @@ MailerSend Java SDK

# Installation

Replace `x.y.z` with the latest version on [Maven Central](https://central.sonatype.com/artifact/com.mailersend/java-sdk).

Using Maven:

<dependency>
<groupId>com.mailersend</groupId>
<artifactId>java-sdk</artifactId>
<version>2.6.0</version>
<version>x.y.z</version>
</dependency>

Using Gradle:

implementation 'com.mailersend:java-sdk:2.6.0'
implementation 'com.mailersend:java-sdk:x.y.z'

# Usage

Expand Down
24 changes: 23 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# Release notes and versions for `just release`.
vesnik = {
url = "github:nklmilojevic/vesnik/v0.2.0";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs }:
outputs = { self, nixpkgs, vesnik }:
let
systems = [ "aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux" ];
forEachSystem = f:
Expand All @@ -18,7 +23,8 @@
lefthook
gitleaks
git-secrets
];
just
] ++ [ vesnik.packages.${system}.default ];
};
});
};
Expand Down
56 changes: 56 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
set shell := ["bash", "-uc"]

[private]
default:
@just --list

# Release main: vesnik picks the version (minor if the model gives none) and writes the notes
release:
@git checkout main
@git pull --tags -f
@just _publish-release --default-bump minor
@just _open "https://github.com/mailersend/mailersend-java/releases"

# Release main as a patch version
hotfix-release:
@git checkout main
@git pull --tags -f
@just _publish-release --bump patch
@just _open "https://github.com/mailersend/mailersend-java/releases"

# --- Internal helpers ----------------------------------------------------------------

# Tag main and publish the GitHub Release with vesnik from PATH or the Nix dev
# shell; the tag push starts the Maven Central publish workflow. Without vesnik, the
# version is typed by hand. VESNIK_YES=1 skips vesnik's review.
[private]
_publish-release +flags:
#!/usr/bin/env bash
set -uo pipefail
vesnik=""
if command -v vesnik >/dev/null 2>&1; then
vesnik="vesnik"
elif command -v nix >/dev/null 2>&1; then
vesnik="nix develop --command vesnik"
fi
if [ -n "$vesnik" ]; then
review=""
if [ "${VESNIK_YES:-}" = 1 ]; then review="--yes"; fi
$vesnik release {{flags}} $review
case $? in
0) exit 0 ;;
3) echo "Release aborted; nothing was tagged." >&2; exit 1 ;;
4) echo "The tag is pushed but the GitHub Release failed; run: vesnik renote <tag>" >&2; exit 1 ;;
*) echo "vesnik failed before tagging; falling back to the manual release." >&2 ;;
esac
fi
echo "> Latest version:"
git tag -l --sort=-creatordate | head -n 1
read -r VERSION || exit 1
# No --generate-notes: it copies PR titles, which carry internal ticket keys.
gh release create "$VERSION" --target main --notes "" || exit 1
echo "Add the release notes: vesnik renote $VERSION"

[private]
_open url:
@if [ "$(uname -s)" = "Darwin" ]; then open "{{url}}"; elif command -v xdg-open >/dev/null 2>&1; then xdg-open "{{url}}"; else echo "{{url}}"; fi
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.mailersend</groupId>
<artifactId>java-sdk</artifactId>
<version>2.6.0</version>
<version>0.0.0-SNAPSHOT</version>
<name>MailerSend Java SDK</name>
<description>An SDK for MailerSend API</description>
<url>https://github.com/mailersend/mailersend-java</url>
Expand Down