From c6f372a9af3df66c3b5c7b5f018ccc0df217324f Mon Sep 17 00:00:00 2001 From: Ricardo Costa Date: Sat, 9 May 2026 16:17:59 +0100 Subject: [PATCH 1/4] Add Publish Workflow --- .github/workflows/publish-api.yml | 45 +++++++++++++++++++ .github/workflows/publish-verifier.yml | 45 +++++++++++++++++++ liquidjava-api/pom.xml | 5 ++- liquidjava-verifier/pom.xml | 3 +- release.sh | 61 +++++++++++++++++++++++--- 5 files changed, 149 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/publish-api.yml create mode 100644 .github/workflows/publish-verifier.yml diff --git a/.github/workflows/publish-api.yml b/.github/workflows/publish-api.yml new file mode 100644 index 000000000..ec5beebcc --- /dev/null +++ b/.github/workflows/publish-api.yml @@ -0,0 +1,45 @@ +name: Publish API + +on: + push: + tags: + - "api-v*" + +permissions: + contents: read + +jobs: + publish: + name: Publish liquidjava-api to Maven Central + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Ensure tag is on main + run: | + git fetch origin main + TAG_COMMIT="$(git rev-list -n 1 "$GITHUB_REF_NAME")" + git merge-base --is-ancestor "$TAG_COMMIT" origin/main + + - name: Set up JDK 20 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: "20" + cache: maven + server-id: central + server-username: CENTRAL_USERNAME + server-password: CENTRAL_PASSWORD + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg-passphrase: GPG_PASSPHRASE + + - name: Publish API + run: ./mvnw -f liquidjava-api/pom.xml -B --fail-fast -Dgpg.skip=false -Dmaven.deploy.skip=false clean deploy + env: + CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} + CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} diff --git a/.github/workflows/publish-verifier.yml b/.github/workflows/publish-verifier.yml new file mode 100644 index 000000000..9a1ec390b --- /dev/null +++ b/.github/workflows/publish-verifier.yml @@ -0,0 +1,45 @@ +name: Publish verifier + +on: + push: + tags: + - "v*" + +permissions: + contents: read + +jobs: + publish: + name: Publish liquidjava-verifier to Maven Central + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Ensure tag is on main + run: | + git fetch origin main + TAG_COMMIT="$(git rev-list -n 1 "$GITHUB_REF_NAME")" + git merge-base --is-ancestor "$TAG_COMMIT" origin/main + + - name: Set up JDK 20 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: "20" + cache: maven + server-id: central + server-username: CENTRAL_USERNAME + server-password: CENTRAL_PASSWORD + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg-passphrase: GPG_PASSPHRASE + + - name: Publish verifier + run: ./mvnw -f liquidjava-verifier/pom.xml -B --fail-fast -Dgpg.skip=false -Dmaven.deploy.skip=false clean deploy + env: + CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} + CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} diff --git a/liquidjava-api/pom.xml b/liquidjava-api/pom.xml index 037ae5d1e..9e366b0ba 100644 --- a/liquidjava-api/pom.xml +++ b/liquidjava-api/pom.xml @@ -142,7 +142,8 @@ central ${maven.deploy.skip} - + true + published @@ -163,4 +164,4 @@ true true - \ No newline at end of file + diff --git a/liquidjava-verifier/pom.xml b/liquidjava-verifier/pom.xml index db87d2122..13efeb1a0 100644 --- a/liquidjava-verifier/pom.xml +++ b/liquidjava-verifier/pom.xml @@ -213,7 +213,8 @@ central ${maven.deploy.skip} - + true + published diff --git a/release.sh b/release.sh index bf6c3d857..3ac4ce2c3 100755 --- a/release.sh +++ b/release.sh @@ -1,20 +1,67 @@ -#!/bin/bash +#!/usr/bin/env bash -if [ -z "$1" ]; then - echo "Usage: $0 " +set -euo pipefail + +if [ $# -ne 2 ]; then + echo "Usage: $0 " exit 1 fi MODULE=$1 +VERSION=$2 if [ "$MODULE" != "api" ] && [ "$MODULE" != "verifier" ]; then echo "Invalid module: $MODULE" - echo "Usage: $0 " + echo "Usage: $0 " + exit 1 +fi + +if ! [[ "$VERSION" =~ ^[0-9]+(\.[0-9]+){1,2}(-[A-Za-z0-9.-]+)?$ ]]; then + echo "Invalid version: $VERSION" + echo "Expected format: 1.2.3" exit 1 fi MODULE_DIR="liquidjava-$MODULE" +POM="$MODULE_DIR/pom.xml" + +if [ "$MODULE" = "api" ]; then + TAG="api-v$VERSION" +else + TAG="v$VERSION" +fi + +CURRENT_BRANCH=$(git branch --show-current) +if [ "$CURRENT_BRANCH" != "main" ]; then + echo "Release must be run from main. Current branch: $CURRENT_BRANCH" + exit 1 +fi + +if [ -n "$(git status --porcelain)" ]; then + echo "Worktree must be clean before releasing." + git status --short + exit 1 +fi + +if git rev-parse "$TAG" >/dev/null 2>&1; then + echo "Tag already exists: $TAG" + exit 1 +fi + +perl -0pi -e "s#($MODULE_DIR\\s*)[^<]+()#\${1}$VERSION\${2}#" "$POM" + +if git diff --quiet -- "$POM"; then + echo "$POM is already at version $VERSION" + exit 1 +fi + +./mvnw -f "$POM" -B --fail-fast -Dgpg.skip=true -Dmaven.deploy.skip=true clean verify + +git add "$POM" +git commit -m "Release $MODULE_DIR $VERSION" +git tag "$TAG" + +git push origin main +git push origin "$TAG" -cd "$MODULE_DIR" -mvn -Dgpg.skip=false -Dmaven.deploy.skip=false clean deploy -cd .. +echo "Created and pushed $TAG. GitHub Actions will publish $MODULE_DIR to Maven Central." From b394d277afa77fc88fe52d511f099a61b82d7115 Mon Sep 17 00:00:00 2001 From: Ricardo Costa Date: Sat, 9 May 2026 16:25:16 +0100 Subject: [PATCH 2/4] Disable VS Code Java Auto-Build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent VS Code’s JDT background builder from writing partial or stale classes into Maven target directories. These classes can later cause Maven test runs to fail with unresolved compilation problem errors even when sources compile cleanly. --- .vscode/settings.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 04cd61886..0d379bc34 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "java.configuration.updateBuildConfiguration": "automatic" + "java.configuration.updateBuildConfiguration": "automatic", + "java.autobuild.enabled": false } From 959c2455e4d8ce6ca0a62cb066b76d3cf515007d Mon Sep 17 00:00:00 2001 From: Ricardo Costa Date: Sun, 10 May 2026 22:43:59 +0100 Subject: [PATCH 3/4] Automatically Bump Version --- release.sh | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/release.sh b/release.sh index 3ac4ce2c3..0a9536615 100755 --- a/release.sh +++ b/release.sh @@ -2,29 +2,51 @@ set -euo pipefail -if [ $# -ne 2 ]; then - echo "Usage: $0 " +if [ $# -lt 1 ] || [ $# -gt 2 ]; then + echo "Usage: $0 [version]" exit 1 fi MODULE=$1 -VERSION=$2 +VERSION=${2:-} if [ "$MODULE" != "api" ] && [ "$MODULE" != "verifier" ]; then echo "Invalid module: $MODULE" - echo "Usage: $0 " + echo "Usage: $0 [version]" exit 1 fi +MODULE_DIR="liquidjava-$MODULE" +POM="$MODULE_DIR/pom.xml" + +if [ -z "$VERSION" ]; then + CURRENT_VERSION=$(perl -0ne "print \$1 if m#\\Q$MODULE_DIR\\E\\s*([^<]+)#" "$POM") + + if [ -z "$CURRENT_VERSION" ]; then + echo "Could not read current version from $POM" + exit 1 + fi + + if ! [[ "$CURRENT_VERSION" =~ ^[0-9]+(\.[0-9]+){1,2}$ ]]; then + echo "Cannot automatically bump non-numeric version: $CURRENT_VERSION" + echo "Pass the release version explicitly." + exit 1 + fi + + IFS=. read -ra VERSION_PARTS <<<"$CURRENT_VERSION" + LAST_INDEX=$((${#VERSION_PARTS[@]} - 1)) + VERSION_PARTS[$LAST_INDEX]=$((${VERSION_PARTS[$LAST_INDEX]} + 1)) + VERSION=$(IFS=.; echo "${VERSION_PARTS[*]}") + + echo "Bumping $MODULE_DIR from $CURRENT_VERSION to $VERSION" +fi + if ! [[ "$VERSION" =~ ^[0-9]+(\.[0-9]+){1,2}(-[A-Za-z0-9.-]+)?$ ]]; then echo "Invalid version: $VERSION" echo "Expected format: 1.2.3" exit 1 fi -MODULE_DIR="liquidjava-$MODULE" -POM="$MODULE_DIR/pom.xml" - if [ "$MODULE" = "api" ]; then TAG="api-v$VERSION" else @@ -48,6 +70,8 @@ if git rev-parse "$TAG" >/dev/null 2>&1; then exit 1 fi +./mvnw -f "$POM" -B --fail-fast -Dgpg.skip=true -Dmaven.deploy.skip=true clean verify + perl -0pi -e "s#($MODULE_DIR\\s*)[^<]+()#\${1}$VERSION\${2}#" "$POM" if git diff --quiet -- "$POM"; then @@ -55,8 +79,6 @@ if git diff --quiet -- "$POM"; then exit 1 fi -./mvnw -f "$POM" -B --fail-fast -Dgpg.skip=true -Dmaven.deploy.skip=true clean verify - git add "$POM" git commit -m "Release $MODULE_DIR $VERSION" git tag "$TAG" From 4d023b410b5d6b81bd20ca06f368073c40fae4e9 Mon Sep 17 00:00:00 2001 From: Ricardo Costa Date: Mon, 11 May 2026 12:48:12 +0100 Subject: [PATCH 4/4] Update CONTRIBUTING --- CONTRIBUTING.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7d35dafdd..6fb8cb1ae 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,6 +28,33 @@ Verify a single file from the CLI: Code formatting runs automatically via `formatter-maven-plugin` during the `validate` phase. +## Release + +Releases are published through GitHub Actions when release tags are pushed to +`main`: + +- `v*` tags publish `liquidjava-verifier` through the `publish-verifier` + workflow. +- `api-v*` tags publish `liquidjava-api` through the `publish-api` workflow. + +Use `release.sh` from the repository root to publish a release. +The script automatically verifies the build and tests, bumps the module version, commits the version change, creates the matching tag, and pushes them to `main`. + +```bash +./release.sh verifier # publishes liquidjava-verifier +./release.sh api # publishes liquidjava-api +``` + +You can also pass the release version explicitly: + +```bash +./release.sh verifier 1.2.3 +./release.sh api 1.2.3 +``` + +Run releases from a clean `main` branch. Once the tag is pushed, the matching +GitHub Actions workflow publishes the module to Maven Central. + ## Adding test cases Tests live under `liquidjava-example/src/main/java/testSuite/` and are auto-discovered: