From 12e61c9770f31decb6e47d18d0f91a9159d4e540 Mon Sep 17 00:00:00 2001 From: Frooodle <77850077+Frooodle@users.noreply.github.com> Date: Wed, 21 Oct 2026 09:31:33 +0100 Subject: [PATCH 01/10] Publish to the Stirling Maven repo on R2 --- .github/scripts/maven_metadata.py | 59 ++++++++++++++ .github/scripts/upload-to-r2.sh | 59 ++++++++++++++ .github/scripts/verify-central.sh | 26 +++++-- .github/workflows/mirror-central-to-r2.yml | 91 ++++++++++++++++++++++ build.gradle.kts | 21 +++++ 5 files changed, 249 insertions(+), 7 deletions(-) create mode 100644 .github/scripts/maven_metadata.py create mode 100755 .github/scripts/upload-to-r2.sh create mode 100644 .github/workflows/mirror-central-to-r2.yml diff --git a/.github/scripts/maven_metadata.py b/.github/scripts/maven_metadata.py new file mode 100644 index 000000000..7f87d54ac --- /dev/null +++ b/.github/scripts/maven_metadata.py @@ -0,0 +1,59 @@ +"""Writes /maven-metadata.xml plus checksums. + +usage: maven_metadata.py ... +Keeps every version the live file lists and adds the new ones; and + become the highest version by Maven-style numeric ordering. +""" + +import hashlib +import re +import sys +import time +import xml.etree.ElementTree as ET +from pathlib import Path + + +def version_key(version: str) -> tuple: + parts = re.split(r"[.\-]", version) + return tuple((0, int(p), "") if p.isdigit() else (-1, 0, p) for p in parts) + + +def main() -> None: + artifact_dir = Path(sys.argv[1]) + live = Path(sys.argv[2]) + new_versions = sys.argv[3:] + group_id, artifact_id = artifact_dir.parent.as_posix().replace("/", "."), artifact_dir.name + + versions = set(new_versions) + if live.is_file(): + root = ET.parse(live).getroot() + if root.findtext("groupId") != group_id or root.findtext("artifactId") != artifact_id: + sys.exit(f"live metadata for {artifact_dir} names a different artifact") + versions.update(v.text for v in root.findall("./versioning/versions/version") if v.text) + + ordered = sorted(versions, key=version_key) + releases = [v for v in ordered if not v.endswith("-SNAPSHOT")] + + metadata = ET.Element("metadata") + ET.SubElement(metadata, "groupId").text = group_id + ET.SubElement(metadata, "artifactId").text = artifact_id + versioning = ET.SubElement(metadata, "versioning") + ET.SubElement(versioning, "latest").text = ordered[-1] + if releases: + ET.SubElement(versioning, "release").text = releases[-1] + versions_el = ET.SubElement(versioning, "versions") + for v in ordered: + ET.SubElement(versions_el, "version").text = v + ET.SubElement(versioning, "lastUpdated").text = time.strftime("%Y%m%d%H%M%S", time.gmtime()) + ET.indent(metadata) + + out = artifact_dir / "maven-metadata.xml" + data = b'\n' + ET.tostring(metadata) + b"\n" + out.write_bytes(data) + for algo in ("md5", "sha1", "sha256", "sha512"): + Path(f"{out}.{algo}").write_text(hashlib.new(algo, data).hexdigest()) + print(f"{artifact_dir}: {', '.join(ordered)}") + + +if __name__ == "__main__": + main() diff --git a/.github/scripts/upload-to-r2.sh b/.github/scripts/upload-to-r2.sh new file mode 100755 index 000000000..f3f6a5816 --- /dev/null +++ b/.github/scripts/upload-to-r2.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# upload-to-r2.sh [] +# Uploads a Maven repo dir to the bucket behind https://maven.stirlingpdf.com. +# Fails if any version is already released at the root. Without a prefix it also +# rewrites each maven-metadata.xml from the live copy, last; callers must hold the +# stirling-maven concurrency group or two releases drop each other's version. +set -euo pipefail + +REPO_DIR="${1:?usage: upload-to-r2.sh []}" +PREFIX="${2:-}" +BUCKET="${R2_BUCKET:-s3://stirling-maven}" +: "${R2_ENDPOINT:?R2_ENDPOINT is required}" +export AWS_DEFAULT_REGION=auto +# Not every S3-compatible store accepts the CRC checksums newer AWS CLIs send. +export AWS_REQUEST_CHECKSUM_CALCULATION=when_required +export AWS_RESPONSE_CHECKSUM_VALIDATION=when_required +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +s3() { aws s3 "$@" --endpoint-url "$R2_ENDPOINT" --no-progress; } +key_count() { + aws s3api list-objects-v2 --endpoint-url "$R2_ENDPOINT" --bucket "${BUCKET#s3://}" \ + --prefix "$1" --max-items 1 --query 'KeyCount' --output text +} + +cd "$REPO_DIR" +mapfile -t VERSION_DIRS < <(find . -name '*.pom' -printf '%h\n' | sed 's#^\./##' | sort -u) +if [ "${#VERSION_DIRS[@]}" -eq 0 ]; then + echo "ERROR: no publications under $REPO_DIR" >&2 + exit 1 +fi + +for dir in "${VERSION_DIRS[@]}"; do + count=$(key_count "$dir/") + if [ "$count" != "0" ] && [ "$count" != "None" ]; then + echo "ERROR: $dir is already released; published versions are immutable." >&2 + exit 1 + fi +done + +find . -name 'maven-metadata.xml*' -delete +s3 sync . "$BUCKET/$PREFIX" +echo "Uploaded ${#VERSION_DIRS[@]} publications to $BUCKET/$PREFIX" + +if [ -n "$PREFIX" ]; then + exit 0 +fi + +mapfile -t ARTIFACT_DIRS < <(printf '%s\n' "${VERSION_DIRS[@]}" | xargs -n1 dirname | sort -u) +for artifact in "${ARTIFACT_DIRS[@]}"; do + live="$artifact/maven-metadata.live.xml" + s3 cp "$BUCKET/$artifact/maven-metadata.xml" "$live" >/dev/null 2>&1 || rm -f "$live" + mapfile -t new_versions < <(printf '%s\n' "${VERSION_DIRS[@]}" | grep "^$artifact/[^/]*$" | xargs -n1 basename) + python3 -I "$SCRIPT_DIR/maven_metadata.py" "$artifact" "$live" "${new_versions[@]}" + rm -f "$live" + for f in "$artifact"/maven-metadata.xml*; do + s3 cp "$f" "$BUCKET/$f" + done +done +echo "Updated maven-metadata.xml for ${#ARTIFACT_DIRS[@]} artifacts" diff --git a/.github/scripts/verify-central.sh b/.github/scripts/verify-central.sh index 98c15bbf2..90180c446 100755 --- a/.github/scripts/verify-central.sh +++ b/.github/scripts/verify-central.sh @@ -2,10 +2,11 @@ # Verifies the JPDFium artifact set, then runs a smoke against it. # MODE=staging Central Portal validated-deployment downloads (before release) # MODE=released repo1.maven.org (after the deployment is released) +# MODE=r2 the Stirling Maven repo at R2_REPO_URL (staging prefix or root) # Called by release.yml with VERSION and PLATFORM in the environment. set -euo pipefail -MODE="${MODE:?MODE must be staging or released}" +MODE="${MODE:?MODE must be staging, released or r2}" VERSION="${VERSION:?VERSION is required}" PLATFORM="${PLATFORM:?PLATFORM is required}" GROUP_PATH="com/stirling" @@ -21,6 +22,11 @@ case "$MODE" in REPO_URL="https://repo1.maven.org/maven2" PORTAL_TOKEN="" ;; + r2) + REPO_URL="${R2_REPO_URL:-https://maven.stirlingpdf.com}" + REPO_URL="${REPO_URL%/}" + PORTAL_TOKEN="" + ;; *) echo "ERROR: unknown MODE '$MODE'" >&2 exit 2 @@ -160,14 +166,20 @@ repositories { if (System.getenv("VERIFY_STAGING") == "true") { maven { url = uri(System.getenv("VERIFY_REPO_URL") + "/") - credentials(HttpHeaderCredentials::class) { - name = "Authorization" - value = System.getenv("VERIFY_TOKEN") + if (!System.getenv("VERIFY_TOKEN").isNullOrEmpty()) { + credentials(HttpHeaderCredentials::class) { + name = "Authorization" + value = System.getenv("VERIFY_TOKEN") + } + authentication { create("header") } } - authentication { create("header") } } } - mavenCentral() + mavenCentral { + if (System.getenv("VERIFY_STAGING") == "true") { + content { excludeGroup("com.stirling") } + } + } } dependencies { @@ -249,7 +261,7 @@ if [ "$VIPS_SUPPORTED" != "1" ]; then export VERIFY_VIPS=false fi -if [ "$MODE" = "staging" ]; then +if [ "$MODE" = "staging" ] || [ "$MODE" = "r2" ]; then export VERIFY_STAGING=true export VERIFY_REPO_URL="$REPO_URL" export VERIFY_TOKEN="$PORTAL_TOKEN" diff --git a/.github/workflows/mirror-central-to-r2.yml b/.github/workflows/mirror-central-to-r2.yml new file mode 100644 index 000000000..1f8796948 --- /dev/null +++ b/.github/workflows/mirror-central-to-r2.yml @@ -0,0 +1,91 @@ +name: Copy a Central release to maven.stirlingpdf.com + +on: + workflow_dispatch: + inputs: + version: + description: 'Version already on Maven Central to copy (e.g. 1.1.6)' + required: true + push: + branches: [publish-to-r2] + +permissions: + contents: read + +jobs: + copy: + name: Copy ${{ inputs.version || '1.1.6' }} from Central + runs-on: ubuntu-latest + environment: maven + concurrency: + group: stirling-maven + cancel-in-progress: false + env: + VERSION: ${{ inputs.version || '1.1.6' }} + steps: + - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 + + - name: Download every JPDFium module at this version from Central + shell: bash + run: | + CENTRAL=https://repo1.maven.org/maven2/com/stirling + get() { curl -fsSL --retry 5 --retry-all-errors --retry-delay 5 --max-time 300 "$@"; } + modules=$(get "$CENTRAL/" | grep -o 'href="jpdfium[^"/]*/' | cut -d'"' -f2 | tr -d /) + for m in $modules; do + listing=$(curl -fsSL --retry 5 --retry-delay 5 "$CENTRAL/$m/$VERSION/" 2>/dev/null) || continue + for f in $(echo "$listing" | grep -o 'href="[^"]*"' | cut -d'"' -f2 | grep -v '^\.\./'); do + get --create-dirs -o "central-repo/com/stirling/$m/$VERSION/$f" "$CENTRAL/$m/$VERSION/$f" + done + echo "$m: $(ls "central-repo/com/stirling/$m/$VERSION" | wc -l) files" + done + [ -d central-repo ] || { echo "ERROR: $VERSION is not on Central"; exit 1; } + + - name: Check every file against Central's sha1 + shell: bash + run: | + bad=0 + while IFS= read -r sum; do + file="${sum%.sha1}" + [ -f "$file" ] || continue + [ "$(sha1sum "$file" | cut -d' ' -f1)" = "$(tr -d ' \n' < "$sum")" ] || { echo "MISMATCH $file"; bad=1; } + done < <(find central-repo -name '*.sha1') + exit "$bad" + + - name: Upload to the Stirling Maven repo + shell: bash + env: + AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} + R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} + R2_BUCKET: s3://${{ vars.R2_BUCKET || 'stirling-maven' }} + run: bash .github/scripts/upload-to-r2.sh central-repo + + verify: + name: Verify maven.stirlingpdf.com (${{ matrix.platform }}) + needs: copy + strategy: + fail-fast: false + matrix: + include: + - { platform: linux-x64, runner: ubuntu-latest } + - { platform: linux-arm64, runner: ubuntu-24.04-arm } + - { platform: darwin-x64, runner: macos-15-intel } + - { platform: darwin-arm64, runner: macos-14 } + - { platform: windows-x64, runner: windows-latest } + - { platform: windows-arm64, runner: windows-11-arm } + runs-on: ${{ matrix.runner }} + steps: + - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 + + - uses: actions/setup-java@2a69be27b0baa8a7ec1c0ba665dc022b180664c5 # v5.7.0 + with: + distribution: ${{ matrix.platform == 'windows-arm64' && 'microsoft' || 'temurin' }} + java-version: '25' + + - name: Verify every artifact and run the smoke + shell: bash + env: + MODE: r2 + VERSION: ${{ inputs.version || '1.1.6' }} + PLATFORM: ${{ matrix.platform }} + run: bash .github/scripts/verify-central.sh diff --git a/build.gradle.kts b/build.gradle.kts index 1238c1fad..9b5660ed4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -327,3 +327,24 @@ tasks.register("publishAllToCentralPortal") { dependsOn(subprojects.filter { it.plugins.hasPlugin("maven-publish") }.map { "${it.path}:publishAllPublicationsToCentralPortalRepository" }) finalizedBy("finalizePortalDeployment") } + +// Release layout for https://maven.stirlingpdf.com; release.yml uploads it with +// .github/scripts/upload-to-r2.sh. +val r2StagingDir = layout.buildDirectory.dir("r2-repo") + +subprojects { + plugins.withId("maven-publish") { + extensions.configure { + repositories.maven { + name = "r2Staging" + url = uri(r2StagingDir) + } + } + } +} + +tasks.register("publishAllToR2Staging") { + group = "publishing" + description = "Publish all modules into build/r2-repo for upload to the Stirling Maven repo" + dependsOn(subprojects.map { sub -> sub.tasks.matching { it.name == "publishAllPublicationsToR2StagingRepository" } }) +} From ddd0b36fe816640ee63b5be4fce0e925ddd32dc7 Mon Sep 17 00:00:00 2001 From: Frooodle <77850077+Frooodle@users.noreply.github.com> Date: Wed, 21 Oct 2026 09:40:32 +0100 Subject: [PATCH 02/10] Release through staging on maven.stirlingpdf.com and point docs and runtime downloads at it --- .github/workflows/mirror-central-to-r2.yml | 8 +- .github/workflows/release.yml | 123 +++++++++--------- README.md | 3 + docs/configuration.md | 2 +- docs/installation.md | 16 ++- docs/native-loading.md | 4 +- examples/render-first-page/README.md | 2 +- examples/render-first-page/build.gradle.kts | 3 + .../jpdfium/panama/NativeDownloader.java | 8 +- 9 files changed, 91 insertions(+), 78 deletions(-) diff --git a/.github/workflows/mirror-central-to-r2.yml b/.github/workflows/mirror-central-to-r2.yml index 1f8796948..c6977aa1b 100644 --- a/.github/workflows/mirror-central-to-r2.yml +++ b/.github/workflows/mirror-central-to-r2.yml @@ -6,22 +6,20 @@ on: version: description: 'Version already on Maven Central to copy (e.g. 1.1.6)' required: true - push: - branches: [publish-to-r2] permissions: contents: read jobs: copy: - name: Copy ${{ inputs.version || '1.1.6' }} from Central + name: Copy ${{ inputs.version }} from Central runs-on: ubuntu-latest environment: maven concurrency: group: stirling-maven cancel-in-progress: false env: - VERSION: ${{ inputs.version || '1.1.6' }} + VERSION: ${{ inputs.version }} steps: - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 @@ -86,6 +84,6 @@ jobs: shell: bash env: MODE: r2 - VERSION: ${{ inputs.version || '1.1.6' }} + VERSION: ${{ inputs.version }} PLATFORM: ${{ matrix.platform }} run: bash .github/scripts/verify-central.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4b1e786b7..20247e17a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Release to Central Portal +name: Release to maven.stirlingpdf.com on: push: @@ -8,15 +8,10 @@ on: version: description: 'Version to publish (e.g. 1.0.0). If omitted on tag push, derived from the tag.' required: false - autoRelease: - description: 'Auto-release to Maven Central without manual Publish click' + dryRun: + description: 'Build, stage and verify, then delete the staging copy without releasing' required: false - default: 'false' - type: boolean - verifyReleased: - description: 'Run the Maven Central probe after a manual release' - required: false - default: 'false' + default: false type: boolean permissions: @@ -886,6 +881,7 @@ jobs: publish: needs: [build-natives, build-vips-natives, cli-binaries] runs-on: ubuntu-latest + environment: maven steps: - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 @@ -951,21 +947,20 @@ jobs: echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "Publishing version: $VERSION" - - name: Publish to Central Portal + - name: Stage on the Stirling Maven repo env: - CENTRAL_PORTAL_USERNAME: ${{ secrets.CENTRAL_PORTAL_USERNAME }} - CENTRAL_PORTAL_PASSWORD: ${{ secrets.CENTRAL_PORTAL_PASSWORD }} GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} GPG_SIGNING_PASSWORD: ${{ secrets.GPG_SIGNING_PASSWORD }} + AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} + R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} + R2_BUCKET: s3://${{ vars.R2_BUCKET || 'stirling-maven' }} run: | - ARGS=(publishAllToCentralPortal -Pjpdfium.version=${{ steps.v.outputs.version }}) - if [ "${{ inputs.autoRelease }}" = "true" ]; then - ARGS+=(-PautoRelease=true) - fi - ./gradlew "${ARGS[@]}" --no-daemon --stacktrace + ./gradlew publishAllToR2Staging -Pjpdfium.version=${{ steps.v.outputs.version }} --no-daemon --stacktrace + bash .github/scripts/upload-to-r2.sh build/r2-repo "staging/${{ github.run_id }}/" - name: Attach CLI binaries to GitHub Release - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/') && !inputs.dryRun env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -988,13 +983,9 @@ jobs: - name: Summary run: | - echo "### Published com.stirling:*:${{ steps.v.outputs.version }}" >> $GITHUB_STEP_SUMMARY + echo "### Staged com.stirling:*:${{ steps.v.outputs.version }}" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - if [ "${{ inputs.autoRelease }}" = "true" ]; then - echo "Auto-release enabled - artifacts will land on Maven Central in 10–30 min." >> $GITHUB_STEP_SUMMARY - else - echo "Review and click **Publish** at https://central.sonatype.com/publishing/deployments" >> $GITHUB_STEP_SUMMARY - fi + echo "https://maven.stirlingpdf.com/staging/${{ github.run_id }}/ - released to the root once every platform verifies." >> $GITHUB_STEP_SUMMARY # ── Pre-release verification: every artifact in the staged deployment ── @@ -1036,53 +1027,57 @@ jobs: - name: Verify every staged artifact and run the smoke shell: bash env: - MODE: staging + MODE: r2 + R2_REPO_URL: https://maven.stirlingpdf.com/staging/${{ github.run_id }} VERSION: ${{ steps.v.outputs.version }} PLATFORM: ${{ matrix.platform }} - CENTRAL_PORTAL_USERNAME: ${{ secrets.CENTRAL_PORTAL_USERNAME }} - CENTRAL_PORTAL_PASSWORD: ${{ secrets.CENTRAL_PORTAL_PASSWORD }} run: bash .github/scripts/verify-central.sh - # ── Post-release verification: probe Maven Central once it is released ── - verify-released: - name: Verify Maven Central (${{ matrix.platform }}) - needs: publish - if: inputs.autoRelease == true || inputs.verifyReleased == true - strategy: - fail-fast: false - matrix: - include: - - { platform: linux-x64, runner: ubuntu-latest } - - { platform: linux-arm64, runner: ubuntu-24.04-arm } - - { platform: darwin-x64, runner: macos-15-intel } - - { platform: darwin-arm64, runner: macos-14 } - - { platform: windows-x64, runner: windows-latest } - - { platform: windows-arm64, runner: windows-11-arm } - runs-on: ${{ matrix.runner }} + # ── Release: copy the verified staging set to the root, then drop staging ── + promote: + name: Release to maven.stirlingpdf.com + needs: [publish, verify-staging] + if: ${{ !inputs.dryRun }} + runs-on: ubuntu-latest + environment: maven + concurrency: + group: stirling-maven + cancel-in-progress: false + env: + AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: auto + AWS_REQUEST_CHECKSUM_CALCULATION: when_required + AWS_RESPONSE_CHECKSUM_VALIDATION: when_required + R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} + R2_BUCKET: s3://${{ vars.R2_BUCKET || 'stirling-maven' }} steps: - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 - - uses: actions/setup-java@2a69be27b0baa8a7ec1c0ba665dc022b180664c5 # v5.7.0 - with: - distribution: ${{ matrix.platform == 'windows-arm64' && 'microsoft' || 'temurin' }} - java-version: '25' + - name: Fetch the verified staging set + run: aws s3 sync "$R2_BUCKET/staging/${{ github.run_id }}/" staged/ --endpoint-url "$R2_ENDPOINT" --no-progress - - name: Resolve version - id: v - shell: bash - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.version }}" ]; then - VERSION="${{ inputs.version }}" - else - REF="${GITHUB_REF_NAME}" - VERSION="${REF#v}" - fi - echo "version=$VERSION" >> "$GITHUB_OUTPUT" + - name: Release + run: bash .github/scripts/upload-to-r2.sh staged - - name: Probe Maven Central and run the smoke - shell: bash + - name: Summary + run: | + VERSION=$(ls staged/com/stirling/jpdfium) + curl -fsSI "https://maven.stirlingpdf.com/com/stirling/jpdfium/$VERSION/jpdfium-$VERSION.pom" >/dev/null + echo "### Released com.stirling:*:$VERSION to https://maven.stirlingpdf.com" >> $GITHUB_STEP_SUMMARY + + cleanup-staging: + name: Delete the staging copy + needs: [publish, verify-staging, promote] + if: ${{ always() && needs.publish.result == 'success' }} + runs-on: ubuntu-latest + environment: maven + steps: + - name: Delete staging/${{ github.run_id }} env: - MODE: released - VERSION: ${{ steps.v.outputs.version }} - PLATFORM: ${{ matrix.platform }} - run: bash .github/scripts/verify-central.sh + AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: auto + AWS_REQUEST_CHECKSUM_CALCULATION: when_required + AWS_RESPONSE_CHECKSUM_VALIDATION: when_required + run: aws s3 rm "s3://${{ vars.R2_BUCKET || 'stirling-maven' }}/staging/${{ github.run_id }}/" --recursive --endpoint-url "${{ secrets.R2_ENDPOINT }}" --only-show-errors diff --git a/README.md b/README.md index 7cc0d7051..139b77a50 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,9 @@ plugins { } repositories { + maven("https://maven.stirlingpdf.com") { + content { includeGroup("com.stirling") } + } mavenCentral() } diff --git a/docs/configuration.md b/docs/configuration.md index ff42e0132..59558b54e 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -53,7 +53,7 @@ These bound concurrent admission, not memory. Two operations admitted together m | `jpdfium.native.sweep` | `true` | Set to `false` to disable cleanup of stale cache entries. | | `jpdfium.native.download` | `false` | Set to `true` to download a missing native module at runtime. | | `jpdfium.native.version` | Version stamped in the JAR | Version to download at runtime. | -| `jpdfium.native.repo` | Maven Central | Repository URL for runtime downloads. | +| `jpdfium.native.repo` | `https://maven.stirlingpdf.com` | Repository URL for runtime downloads. | `jpdfium.native.verify=marker` weakens cache-integrity verification. See [native-loading.md](native-loading.md) for the trust model before using it. diff --git a/docs/installation.md b/docs/installation.md index c8127e7d9..62e44d2d1 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -1,6 +1,6 @@ # Installation -JPDFium publishes to Maven Central under the `com.stirling` group. The current release is **1.2.0**. +JPDFium publishes to https://maven.stirlingpdf.com under the `com.stirling` group. Releases up to 1.2.0 are also on Maven Central. The current release is **1.2.0**. ## Requirements @@ -26,6 +26,13 @@ Java 25 is the version JPDFium is built and tested against. Earlier releases are Windows x64. Substitute the native module for your platform from the table below. ```kotlin +repositories { + maven("https://maven.stirlingpdf.com") { + content { includeGroup("com.stirling") } + } + mavenCentral() +} + dependencies { implementation(platform("com.stirling:jpdfium-bom:1.2.0")) implementation("com.stirling:jpdfium") @@ -38,6 +45,13 @@ dependencies { Windows x64. ```xml + + + stirling + https://maven.stirlingpdf.com + + + diff --git a/docs/native-loading.md b/docs/native-loading.md index 262598123..b8d57f97e 100644 --- a/docs/native-loading.md +++ b/docs/native-loading.md @@ -8,9 +8,9 @@ Packaging depends on your deployment model; see [deployment.md](deployment.md). ## Downloading at runtime -As an alternative to bundling, JPDFium can download the matching native artifact from Maven Central the first time it runs and reuse the cached copy afterwards. +As an alternative to bundling, JPDFium can download the matching native artifact from https://maven.stirlingpdf.com the first time it runs and reuse the cached copy afterwards. -This is disabled by default. Enable it only when network access to Maven Central is acceptable at runtime: +This is disabled by default. Enable it only when network access to maven.stirlingpdf.com is acceptable at runtime: ```bash java -Djpdfium.native.download=true --enable-native-access=ALL-UNNAMED -jar app.jar diff --git a/examples/render-first-page/README.md b/examples/render-first-page/README.md index 49152a391..883cc7f22 100644 --- a/examples/render-first-page/README.md +++ b/examples/render-first-page/README.md @@ -1,6 +1,6 @@ # Render the first page -A minimal JPDFium consumer project. It resolves `com.stirling:jpdfium` from Maven Central and renders `sample.pdf` (the JPDFium logo) to a PNG at 150 DPI. +A minimal JPDFium consumer project. It resolves `com.stirling:jpdfium` from https://maven.stirlingpdf.com and renders `sample.pdf` (the JPDFium logo) to a PNG at 150 DPI. From the repository root: diff --git a/examples/render-first-page/build.gradle.kts b/examples/render-first-page/build.gradle.kts index 80a18d11d..256b316d1 100644 --- a/examples/render-first-page/build.gradle.kts +++ b/examples/render-first-page/build.gradle.kts @@ -6,6 +6,9 @@ plugins { } repositories { + maven("https://maven.stirlingpdf.com") { + content { includeGroup("com.stirling") } + } mavenCentral() } diff --git a/jpdfium/src/main/java/stirling/software/jpdfium/panama/NativeDownloader.java b/jpdfium/src/main/java/stirling/software/jpdfium/panama/NativeDownloader.java index 314d3daa6..de2774252 100644 --- a/jpdfium/src/main/java/stirling/software/jpdfium/panama/NativeDownloader.java +++ b/jpdfium/src/main/java/stirling/software/jpdfium/panama/NativeDownloader.java @@ -29,9 +29,9 @@ *

Off by default. When {@code -Djpdfium.native.download=true} is set and * the classpath has no natives jar for the current platform, the matching * {@code com.stirling:jpdfium-natives-:} jar is fetched - * from Maven Central (or {@code -Djpdfium.native.repo=...}), cached under the - * native cache root for offline reuse, and loaded through the same - * checksum-verified extraction path as a bundled jar. + * from https://maven.stirlingpdf.com (or {@code -Djpdfium.native.repo=...}), + * cached under the native cache root for offline reuse, and loaded through + * the same checksum-verified extraction path as a bundled jar. * *

Trust model: TLS authenticates the repository (plain http is refused * except for loopback test servers), and every extracted file is still @@ -48,7 +48,7 @@ final class NativeDownloader { static final String ENABLE_PROPERTY = "jpdfium.native.download"; static final String VERSION_PROPERTY = "jpdfium.native.version"; static final String REPO_PROPERTY = "jpdfium.native.repo"; - static final String DEFAULT_REPO = "https://repo1.maven.org/maven2"; + static final String DEFAULT_REPO = "https://maven.stirlingpdf.com"; static final String GROUP_PATH = "com/stirling"; static final String VERSION_RESOURCE = "jpdfium-version.properties"; From f28e5443a872dc093a5447c8c6b4b273079e7976 Mon Sep 17 00:00:00 2001 From: Frooodle <77850077+Frooodle@users.noreply.github.com> Date: Wed, 21 Oct 2026 10:49:29 +0100 Subject: [PATCH 03/10] Take the released version from the publish job --- .github/workflows/release.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 20247e17a..853537eb0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -882,6 +882,8 @@ jobs: needs: [build-natives, build-vips-natives, cli-binaries] runs-on: ubuntu-latest environment: maven + outputs: + version: ${{ steps.v.outputs.version }} steps: - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 @@ -1061,8 +1063,9 @@ jobs: run: bash .github/scripts/upload-to-r2.sh staged - name: Summary + env: + VERSION: ${{ needs.publish.outputs.version }} run: | - VERSION=$(ls staged/com/stirling/jpdfium) curl -fsSI "https://maven.stirlingpdf.com/com/stirling/jpdfium/$VERSION/jpdfium-$VERSION.pom" >/dev/null echo "### Released com.stirling:*:$VERSION to https://maven.stirlingpdf.com" >> $GITHUB_STEP_SUMMARY From 1f133528ab51b32929c9e29dd1c3a87634264535 Mon Sep 17 00:00:00 2001 From: Frooodle <77850077+Frooodle@users.noreply.github.com> Date: Wed, 21 Oct 2026 10:53:18 +0100 Subject: [PATCH 04/10] Record the move to maven.stirlingpdf.com in the changelog --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a80f95a5..37799b1c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ below ships in 1.3.0. Every incompatible change is listed here under "Removed" or "Changed", and [compatibility.md](docs/compatibility.md) states the policy in full. -This file covers library releases on Maven Central (the `v*.*.*` tags). +This file covers library releases (the `v*.*.*` tags), published to +https://maven.stirlingpdf.com; releases up to 1.2.0 are also on Maven Central. Infrastructure tags such as `pdfium-*` and `vips-*` are prebuild inputs for the publishing workflows, not library releases, so they are not listed here. @@ -34,6 +35,11 @@ publishing workflows, not library releases, so they are not listed here. ### Changed +- Releases publish to https://maven.stirlingpdf.com instead of Maven Central. + Add `maven("https://maven.stirlingpdf.com")` to your repositories; 1.1.6 and + 1.2.0 are there too. Runtime native downloads (`jpdfium.native.download`) now + default to this repository. + - The published `jpdfium` jar no longer carries the GraalVM smoke-test PDFs. Those fixtures stay on the native-image build classpath, so the smoke test still reads them. From 7639e8fd37e92657133adec79454e34c48597614 Mon Sep 17 00:00:00 2001 From: Frooodle <77850077+Frooodle@users.noreply.github.com> Date: Fri, 6 Nov 2026 22:16:32 +0000 Subject: [PATCH 05/10] Mirror each release to Maven Central without blocking the R2 release --- .github/workflows/release.yml | 92 +++++++++++++++++++++++++++++++++++ CHANGELOG.md | 11 +++-- docs/installation.md | 2 +- 3 files changed, 99 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 82d1f4c78..52a7b12ee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1159,6 +1159,98 @@ jobs: curl -fsSI "https://maven.stirlingpdf.com/com/stirling/jpdfium/$VERSION/jpdfium-$VERSION.pom" >/dev/null echo "### Released com.stirling:*:$VERSION to https://maven.stirlingpdf.com" >> $GITHUB_STEP_SUMMARY + publish-central: + name: Publish to Maven Central + needs: [publish, promote] + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 + + - uses: actions/setup-java@816722acf8fd27c9d1e9ae6ee6085da07e0d44c1 # v5.7.0 + with: + distribution: 'temurin' + java-version: '25' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@c8a326d85724fce2ae59a38810306f4a058f26a4 # v6.3.0 + + - name: Install jextract + # jpdfium/build.gradle.kts uses jextract to generate JpdfiumH.java + # FFM bindings from native/bridge/include/jpdfium.h. Without it the + # publish job fails on compileJava with `cannot find symbol JpdfiumH` + # - the natives jars (built earlier in this run) ship fine but the + # main jpdfium.jar can't be built without bindings. Mirrors the + # snapshot.yml + publish-github-packages.yml jextract install step. + run: | + JEXTRACT_URL="https://download.java.net/java/early_access/jextract/25/2/openjdk-25-jextract+2-4_linux-x64_bin.tar.gz" + mkdir -p "$HOME/jextract-install" + curl -fsSL --retry 5 --retry-all-errors --retry-delay 3 --max-time 120 "$JEXTRACT_URL" -o /tmp/jextract.tar.gz + tar -xzf /tmp/jextract.tar.gz -C "$HOME/jextract-install" --strip-components=1 + echo "JEXTRACT_HOME=$HOME/jextract-install" >> "$GITHUB_ENV" + + - name: Download all native artifacts + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.1 + with: + path: .artifacts + pattern: natives-* + + - name: Flatten into native/dist// + run: | + mkdir -p native/dist + for d in .artifacts/natives-*; do + plat="${d##*natives-}" + mkdir -p "native/dist/$plat" + cp -v "$d"/* "native/dist/$plat/" + done + echo "--- final layout ---" + find native/dist -type f | sort + + - name: Publish to Central Portal + env: + CENTRAL_PORTAL_USERNAME: ${{ secrets.CENTRAL_PORTAL_USERNAME }} + CENTRAL_PORTAL_PASSWORD: ${{ secrets.CENTRAL_PORTAL_PASSWORD }} + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + GPG_SIGNING_PASSWORD: ${{ secrets.GPG_SIGNING_PASSWORD }} + VERSION: ${{ needs.publish.outputs.version }} + run: ./gradlew publishAllToCentralPortal "-Pjpdfium.version=$VERSION" -PautoRelease=true --no-daemon --stacktrace + + - name: Summary + env: + VERSION: ${{ needs.publish.outputs.version }} + run: echo "### Sent com.stirling:*:$VERSION to Maven Central; it appears there in 10-30 min" >> "$GITHUB_STEP_SUMMARY" + + verify-central: + name: Verify Maven Central (${{ matrix.platform }}) + needs: [publish, publish-central] + continue-on-error: true + strategy: + fail-fast: false + matrix: + include: + - { platform: linux-x64, runner: ubuntu-24.04 } + - { platform: linux-arm64, runner: ubuntu-24.04-arm } + - { platform: darwin-x64, runner: macos-15-intel } + - { platform: darwin-arm64, runner: macos-15 } + - { platform: windows-x64, runner: windows-latest } + - { platform: windows-arm64, runner: windows-11-arm } + runs-on: ${{ matrix.runner }} + steps: + - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 + + - uses: actions/setup-java@816722acf8fd27c9d1e9ae6ee6085da07e0d44c1 # v5.7.0 + with: + distribution: ${{ matrix.platform == 'windows-arm64' && 'microsoft' || 'temurin' }} + java-version: '25' + + - name: Probe Maven Central and run the smoke + shell: bash + env: + MODE: released + VERSION: ${{ needs.publish.outputs.version }} + PLATFORM: ${{ matrix.platform }} + run: bash .github/scripts/verify-central.sh + cleanup-staging: name: Delete the staging copy needs: [publish, verify-staging, promote] diff --git a/CHANGELOG.md b/CHANGELOG.md index 03a408d52..c719a93dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ or "Changed", and [compatibility.md](docs/compatibility.md) states the policy in full. This file covers library releases (the `v*.*.*` tags), published to -https://maven.stirlingpdf.com; releases up to 1.3.0 are also on Maven Central. +https://maven.stirlingpdf.com and mirrored to Maven Central. Infrastructure tags such as `pdfium-*` and `vips-*` are prebuild inputs for the publishing workflows, not library releases, so they are not listed here. @@ -42,10 +42,11 @@ publishing workflows, not library releases, so they are not listed here. ### Changed -- Releases publish to https://maven.stirlingpdf.com instead of Maven Central. - Add `maven("https://maven.stirlingpdf.com")` to your repositories; 1.1.6 and - 1.2.0 are there too. Runtime native downloads (`jpdfium.native.download`) now - default to this repository. +- Releases publish to https://maven.stirlingpdf.com first and are then mirrored + to Maven Central. Add `maven("https://maven.stirlingpdf.com")` to your + repositories to get a release as soon as it is out; earlier releases are there + too. Runtime native downloads (`jpdfium.native.download`) now default to this + repository. - `PdfMerge.mergeFilesToFile` and `PdfSplit.extractPageRangeToFile` write their staging file without fsync and flush once when they publish the output, which now gets the destination's permissions as other saves do. They previously diff --git a/docs/installation.md b/docs/installation.md index 23124a7fe..21f8c7034 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -1,6 +1,6 @@ # Installation -JPDFium publishes to https://maven.stirlingpdf.com under the `com.stirling` group. Releases up to 1.3.0 are also on Maven Central. The current release is **1.3.0**. +JPDFium publishes to https://maven.stirlingpdf.com under the `com.stirling` group, and releases are also published to Maven Central. The current release is **1.3.0**. ## Requirements From 8e55232f4af67b6fa1ed518561541c40b444692a Mon Sep 17 00:00:00 2001 From: Frooodle <77850077+Frooodle@users.noreply.github.com> Date: Fri, 6 Nov 2026 22:40:35 +0000 Subject: [PATCH 06/10] Copy the latest Central releases to a chosen R2 destination in one run --- .github/scripts/upload-to-r2.sh | 6 +- .github/workflows/mirror-central-to-r2.yml | 160 +++++++++++++++++---- 2 files changed, 139 insertions(+), 27 deletions(-) diff --git a/.github/scripts/upload-to-r2.sh b/.github/scripts/upload-to-r2.sh index f3f6a5816..f4673698d 100755 --- a/.github/scripts/upload-to-r2.sh +++ b/.github/scripts/upload-to-r2.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # upload-to-r2.sh [] # Uploads a Maven repo dir to the bucket behind https://maven.stirlingpdf.com. -# Fails if any version is already released at the root. Without a prefix it also +# Fails if any version is already at the destination. Without a prefix it also # rewrites each maven-metadata.xml from the live copy, last; callers must hold the # stirling-maven concurrency group or two releases drop each other's version. set -euo pipefail @@ -30,9 +30,9 @@ if [ "${#VERSION_DIRS[@]}" -eq 0 ]; then fi for dir in "${VERSION_DIRS[@]}"; do - count=$(key_count "$dir/") + count=$(key_count "$PREFIX$dir/") if [ "$count" != "0" ] && [ "$count" != "None" ]; then - echo "ERROR: $dir is already released; published versions are immutable." >&2 + echo "ERROR: $PREFIX$dir already exists; published versions are immutable." >&2 exit 1 fi done diff --git a/.github/workflows/mirror-central-to-r2.yml b/.github/workflows/mirror-central-to-r2.yml index c6977aa1b..bd7a58c5b 100644 --- a/.github/workflows/mirror-central-to-r2.yml +++ b/.github/workflows/mirror-central-to-r2.yml @@ -1,44 +1,138 @@ -name: Copy a Central release to maven.stirlingpdf.com +name: Copy Central releases to maven.stirlingpdf.com on: workflow_dispatch: inputs: - version: - description: 'Version already on Maven Central to copy (e.g. 1.1.6)' + versions: + description: 'Versions to copy: all, or a list such as 1.2.0,1.3.0' required: true + default: 'all' + latest: + description: 'With all, copy only this many of the newest versions' + required: false + default: '5' + source: + description: 'Maven repo to copy from' + required: true + default: 'https://repo1.maven.org/maven2' + destination: + description: 'Bucket prefix to copy to, e.g. staging/mirror-test/. Empty is the live repo root.' + required: false + default: '' + smoke: + description: 'Also run the six-platform smoke against each copied version' + required: false + default: false + type: boolean + dryRun: + description: 'Only list what would be copied' + required: false + default: false + type: boolean permissions: contents: read jobs: + plan: + name: Plan the copy + runs-on: ubuntu-latest + outputs: + versions: ${{ steps.plan.outputs.versions }} + destination: ${{ steps.plan.outputs.destination }} + url: ${{ steps.plan.outputs.url }} + steps: + - name: Resolve versions and destination + id: plan + shell: bash + env: + VERSIONS: ${{ inputs.versions }} + LATEST: ${{ inputs.latest }} + SOURCE: ${{ inputs.source }} + DESTINATION: ${{ inputs.destination }} + run: | + set -euo pipefail + SOURCE="${SOURCE%/}" + DEST="${DESTINATION#/}" + case "$DEST" in + *..*|*//*) echo "ERROR: destination '$DESTINATION' is not a plain prefix"; exit 1 ;; + esac + [ -z "$DEST" ] || DEST="${DEST%/}/" + [[ "$LATEST" =~ ^[1-9][0-9]*$ ]] || { echo "ERROR: latest must be a positive number"; exit 1; } + URL="https://maven.stirlingpdf.com/${DEST}" + + if [ "$VERSIONS" = all ]; then + mapfile -t wanted < <(curl -fsSL --retry 5 --retry-all-errors "$SOURCE/com/stirling/jpdfium/maven-metadata.xml" \ + | grep -o '[^<]*' | sed 's###g' \ + | sort -V | tail -n "$LATEST") + else + mapfile -t wanted < <(echo "$VERSIONS" | tr -s ', ' '\n' | sed '/^$/d') + fi + [ "${#wanted[@]}" -gt 0 ] || { echo "ERROR: no versions to copy"; exit 1; } + + copy=() + { + echo "### Copy from $SOURCE to $URL" + echo "" + echo "| Version | Action |" + echo "|---|---|" + } >> "$GITHUB_STEP_SUMMARY" + for v in "${wanted[@]}"; do + [[ "$v" =~ ^[0-9A-Za-z.+-]+$ ]] || { echo "ERROR: bad version '$v'"; exit 1; } + if curl -fsI "${URL}com/stirling/jpdfium/$v/jpdfium-$v.pom" >/dev/null 2>&1; then + action="already there, skipped" + elif ! curl -fsI "$SOURCE/com/stirling/jpdfium/$v/jpdfium-$v.pom" >/dev/null 2>&1; then + echo "ERROR: $v is not in $SOURCE"; exit 1 + else + action="copy" + copy+=("$v") + fi + echo "$v: $action" + echo "| $v | $action |" >> "$GITHUB_STEP_SUMMARY" + done + + { + echo "versions=$(printf '%s\n' "${copy[@]}" | jq -R . | jq -sc 'map(select(. != ""))')" + echo "destination=$DEST" + echo "url=$URL" + } >> "$GITHUB_OUTPUT" + copy: - name: Copy ${{ inputs.version }} from Central + name: Copy to ${{ needs.plan.outputs.url }} + needs: plan + if: ${{ !inputs.dryRun && needs.plan.outputs.versions != '[]' }} runs-on: ubuntu-latest environment: maven concurrency: group: stirling-maven cancel-in-progress: false env: - VERSION: ${{ inputs.version }} + SOURCE: ${{ inputs.source }} + VERSIONS: ${{ needs.plan.outputs.versions }} + DEST: ${{ needs.plan.outputs.destination }} + URL: ${{ needs.plan.outputs.url }} steps: - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 - - name: Download every JPDFium module at this version from Central + - name: Download every JPDFium module at each version shell: bash run: | - CENTRAL=https://repo1.maven.org/maven2/com/stirling + set -euo pipefail + SRC="${SOURCE%/}/com/stirling" get() { curl -fsSL --retry 5 --retry-all-errors --retry-delay 5 --max-time 300 "$@"; } - modules=$(get "$CENTRAL/" | grep -o 'href="jpdfium[^"/]*/' | cut -d'"' -f2 | tr -d /) - for m in $modules; do - listing=$(curl -fsSL --retry 5 --retry-delay 5 "$CENTRAL/$m/$VERSION/" 2>/dev/null) || continue - for f in $(echo "$listing" | grep -o 'href="[^"]*"' | cut -d'"' -f2 | grep -v '^\.\./'); do - get --create-dirs -o "central-repo/com/stirling/$m/$VERSION/$f" "$CENTRAL/$m/$VERSION/$f" + modules=$(get "$SRC/" | grep -o 'href="jpdfium[^"/]*/' | cut -d'"' -f2 | tr -d /) + for v in $(echo "$VERSIONS" | jq -r '.[]'); do + for m in $modules; do + listing=$(curl -fsSL --retry 5 --retry-delay 5 "$SRC/$m/$v/" 2>/dev/null) || continue + for f in $(echo "$listing" | grep -o 'href="[^"]*"' | cut -d'"' -f2 | grep -v '^\.\./'); do + get --create-dirs -o "central-repo/com/stirling/$m/$v/$f" "$SRC/$m/$v/$f" + done done - echo "$m: $(ls "central-repo/com/stirling/$m/$VERSION" | wc -l) files" + [ -f "central-repo/com/stirling/jpdfium/$v/jpdfium-$v.pom" ] || { echo "ERROR: nothing downloaded for $v"; exit 1; } + echo "$v: $(find central-repo -path "*/$v/*" -type f | wc -l) files" done - [ -d central-repo ] || { echo "ERROR: $VERSION is not on Central"; exit 1; } - - name: Check every file against Central's sha1 + - name: Check every file against the source sha1 shell: bash run: | bad=0 @@ -49,33 +143,50 @@ jobs: done < <(find central-repo -name '*.sha1') exit "$bad" - - name: Upload to the Stirling Maven repo + - name: Upload shell: bash env: AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} R2_BUCKET: s3://${{ vars.R2_BUCKET || 'stirling-maven' }} - run: bash .github/scripts/upload-to-r2.sh central-repo + run: bash .github/scripts/upload-to-r2.sh central-repo "$DEST" + + - name: Check every uploaded file is served unchanged + shell: bash + run: | + cd central-repo + bad=0; ok=0; n=0 + while IFS= read -r f; do + f="${f#./}" + served=$(curl -fsSL --retry 5 --retry-all-errors "$URL$f" | sha1sum | cut -d' ' -f1) || served=missing + if [ "$served" = "$(sha1sum "$f" | cut -d' ' -f1)" ]; then ok=$((ok + 1)); else echo "MISMATCH $URL$f"; bad=1; fi + n=$((n + 1)) + done < <(find . -type f ! -name 'maven-metadata.xml*') + echo "$ok of $n files served unchanged from $URL" | tee -a "$GITHUB_STEP_SUMMARY" + exit "$bad" - verify: - name: Verify maven.stirlingpdf.com (${{ matrix.platform }}) - needs: copy + smoke: + name: Smoke ${{ matrix.version }} (${{ matrix.platform }}) + needs: [plan, copy] + if: ${{ inputs.smoke && !inputs.dryRun && needs.plan.outputs.versions != '[]' }} strategy: fail-fast: false matrix: + version: ${{ fromJSON(needs.plan.outputs.versions) }} + platform: [linux-x64, linux-arm64, darwin-x64, darwin-arm64, windows-x64, windows-arm64] include: - - { platform: linux-x64, runner: ubuntu-latest } + - { platform: linux-x64, runner: ubuntu-24.04 } - { platform: linux-arm64, runner: ubuntu-24.04-arm } - { platform: darwin-x64, runner: macos-15-intel } - - { platform: darwin-arm64, runner: macos-14 } + - { platform: darwin-arm64, runner: macos-15 } - { platform: windows-x64, runner: windows-latest } - { platform: windows-arm64, runner: windows-11-arm } runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 - - uses: actions/setup-java@2a69be27b0baa8a7ec1c0ba665dc022b180664c5 # v5.7.0 + - uses: actions/setup-java@816722acf8fd27c9d1e9ae6ee6085da07e0d44c1 # v5.7.0 with: distribution: ${{ matrix.platform == 'windows-arm64' && 'microsoft' || 'temurin' }} java-version: '25' @@ -84,6 +195,7 @@ jobs: shell: bash env: MODE: r2 - VERSION: ${{ inputs.version }} + R2_REPO_URL: ${{ needs.plan.outputs.url }} + VERSION: ${{ matrix.version }} PLATFORM: ${{ matrix.platform }} run: bash .github/scripts/verify-central.sh From fa0d937ab7168c481100b153bf4147ace45fbdcf Mon Sep 17 00:00:00 2001 From: Frooodle <77850077+Frooodle@users.noreply.github.com> Date: Fri, 6 Nov 2026 23:53:15 +0000 Subject: [PATCH 07/10] Publish through the shared maven-r2-publish actions --- .github/scripts/maven_metadata.py | 59 -------- .github/scripts/upload-to-r2.sh | 59 -------- .github/workflows/mirror-central-to-r2.yml | 153 +++------------------ .github/workflows/release.yml | 72 +++++----- build.gradle.kts | 2 +- 5 files changed, 54 insertions(+), 291 deletions(-) delete mode 100644 .github/scripts/maven_metadata.py delete mode 100755 .github/scripts/upload-to-r2.sh diff --git a/.github/scripts/maven_metadata.py b/.github/scripts/maven_metadata.py deleted file mode 100644 index 7f87d54ac..000000000 --- a/.github/scripts/maven_metadata.py +++ /dev/null @@ -1,59 +0,0 @@ -"""Writes /maven-metadata.xml plus checksums. - -usage: maven_metadata.py ... -Keeps every version the live file lists and adds the new ones; and - become the highest version by Maven-style numeric ordering. -""" - -import hashlib -import re -import sys -import time -import xml.etree.ElementTree as ET -from pathlib import Path - - -def version_key(version: str) -> tuple: - parts = re.split(r"[.\-]", version) - return tuple((0, int(p), "") if p.isdigit() else (-1, 0, p) for p in parts) - - -def main() -> None: - artifact_dir = Path(sys.argv[1]) - live = Path(sys.argv[2]) - new_versions = sys.argv[3:] - group_id, artifact_id = artifact_dir.parent.as_posix().replace("/", "."), artifact_dir.name - - versions = set(new_versions) - if live.is_file(): - root = ET.parse(live).getroot() - if root.findtext("groupId") != group_id or root.findtext("artifactId") != artifact_id: - sys.exit(f"live metadata for {artifact_dir} names a different artifact") - versions.update(v.text for v in root.findall("./versioning/versions/version") if v.text) - - ordered = sorted(versions, key=version_key) - releases = [v for v in ordered if not v.endswith("-SNAPSHOT")] - - metadata = ET.Element("metadata") - ET.SubElement(metadata, "groupId").text = group_id - ET.SubElement(metadata, "artifactId").text = artifact_id - versioning = ET.SubElement(metadata, "versioning") - ET.SubElement(versioning, "latest").text = ordered[-1] - if releases: - ET.SubElement(versioning, "release").text = releases[-1] - versions_el = ET.SubElement(versioning, "versions") - for v in ordered: - ET.SubElement(versions_el, "version").text = v - ET.SubElement(versioning, "lastUpdated").text = time.strftime("%Y%m%d%H%M%S", time.gmtime()) - ET.indent(metadata) - - out = artifact_dir / "maven-metadata.xml" - data = b'\n' + ET.tostring(metadata) + b"\n" - out.write_bytes(data) - for algo in ("md5", "sha1", "sha256", "sha512"): - Path(f"{out}.{algo}").write_text(hashlib.new(algo, data).hexdigest()) - print(f"{artifact_dir}: {', '.join(ordered)}") - - -if __name__ == "__main__": - main() diff --git a/.github/scripts/upload-to-r2.sh b/.github/scripts/upload-to-r2.sh deleted file mode 100755 index f4673698d..000000000 --- a/.github/scripts/upload-to-r2.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env bash -# upload-to-r2.sh [] -# Uploads a Maven repo dir to the bucket behind https://maven.stirlingpdf.com. -# Fails if any version is already at the destination. Without a prefix it also -# rewrites each maven-metadata.xml from the live copy, last; callers must hold the -# stirling-maven concurrency group or two releases drop each other's version. -set -euo pipefail - -REPO_DIR="${1:?usage: upload-to-r2.sh []}" -PREFIX="${2:-}" -BUCKET="${R2_BUCKET:-s3://stirling-maven}" -: "${R2_ENDPOINT:?R2_ENDPOINT is required}" -export AWS_DEFAULT_REGION=auto -# Not every S3-compatible store accepts the CRC checksums newer AWS CLIs send. -export AWS_REQUEST_CHECKSUM_CALCULATION=when_required -export AWS_RESPONSE_CHECKSUM_VALIDATION=when_required -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -s3() { aws s3 "$@" --endpoint-url "$R2_ENDPOINT" --no-progress; } -key_count() { - aws s3api list-objects-v2 --endpoint-url "$R2_ENDPOINT" --bucket "${BUCKET#s3://}" \ - --prefix "$1" --max-items 1 --query 'KeyCount' --output text -} - -cd "$REPO_DIR" -mapfile -t VERSION_DIRS < <(find . -name '*.pom' -printf '%h\n' | sed 's#^\./##' | sort -u) -if [ "${#VERSION_DIRS[@]}" -eq 0 ]; then - echo "ERROR: no publications under $REPO_DIR" >&2 - exit 1 -fi - -for dir in "${VERSION_DIRS[@]}"; do - count=$(key_count "$PREFIX$dir/") - if [ "$count" != "0" ] && [ "$count" != "None" ]; then - echo "ERROR: $PREFIX$dir already exists; published versions are immutable." >&2 - exit 1 - fi -done - -find . -name 'maven-metadata.xml*' -delete -s3 sync . "$BUCKET/$PREFIX" -echo "Uploaded ${#VERSION_DIRS[@]} publications to $BUCKET/$PREFIX" - -if [ -n "$PREFIX" ]; then - exit 0 -fi - -mapfile -t ARTIFACT_DIRS < <(printf '%s\n' "${VERSION_DIRS[@]}" | xargs -n1 dirname | sort -u) -for artifact in "${ARTIFACT_DIRS[@]}"; do - live="$artifact/maven-metadata.live.xml" - s3 cp "$BUCKET/$artifact/maven-metadata.xml" "$live" >/dev/null 2>&1 || rm -f "$live" - mapfile -t new_versions < <(printf '%s\n' "${VERSION_DIRS[@]}" | grep "^$artifact/[^/]*$" | xargs -n1 basename) - python3 -I "$SCRIPT_DIR/maven_metadata.py" "$artifact" "$live" "${new_versions[@]}" - rm -f "$live" - for f in "$artifact"/maven-metadata.xml*; do - s3 cp "$f" "$BUCKET/$f" - done -done -echo "Updated maven-metadata.xml for ${#ARTIFACT_DIRS[@]} artifacts" diff --git a/.github/workflows/mirror-central-to-r2.yml b/.github/workflows/mirror-central-to-r2.yml index bd7a58c5b..eaafbb5f8 100644 --- a/.github/workflows/mirror-central-to-r2.yml +++ b/.github/workflows/mirror-central-to-r2.yml @@ -11,10 +11,6 @@ on: description: 'With all, copy only this many of the newest versions' required: false default: '5' - source: - description: 'Maven repo to copy from' - required: true - default: 'https://repo1.maven.org/maven2' destination: description: 'Bucket prefix to copy to, e.g. staging/mirror-test/. Empty is the live repo root.' required: false @@ -34,146 +30,39 @@ permissions: contents: read jobs: - plan: - name: Plan the copy - runs-on: ubuntu-latest - outputs: - versions: ${{ steps.plan.outputs.versions }} - destination: ${{ steps.plan.outputs.destination }} - url: ${{ steps.plan.outputs.url }} - steps: - - name: Resolve versions and destination - id: plan - shell: bash - env: - VERSIONS: ${{ inputs.versions }} - LATEST: ${{ inputs.latest }} - SOURCE: ${{ inputs.source }} - DESTINATION: ${{ inputs.destination }} - run: | - set -euo pipefail - SOURCE="${SOURCE%/}" - DEST="${DESTINATION#/}" - case "$DEST" in - *..*|*//*) echo "ERROR: destination '$DESTINATION' is not a plain prefix"; exit 1 ;; - esac - [ -z "$DEST" ] || DEST="${DEST%/}/" - [[ "$LATEST" =~ ^[1-9][0-9]*$ ]] || { echo "ERROR: latest must be a positive number"; exit 1; } - URL="https://maven.stirlingpdf.com/${DEST}" - - if [ "$VERSIONS" = all ]; then - mapfile -t wanted < <(curl -fsSL --retry 5 --retry-all-errors "$SOURCE/com/stirling/jpdfium/maven-metadata.xml" \ - | grep -o '[^<]*' | sed 's###g' \ - | sort -V | tail -n "$LATEST") - else - mapfile -t wanted < <(echo "$VERSIONS" | tr -s ', ' '\n' | sed '/^$/d') - fi - [ "${#wanted[@]}" -gt 0 ] || { echo "ERROR: no versions to copy"; exit 1; } - - copy=() - { - echo "### Copy from $SOURCE to $URL" - echo "" - echo "| Version | Action |" - echo "|---|---|" - } >> "$GITHUB_STEP_SUMMARY" - for v in "${wanted[@]}"; do - [[ "$v" =~ ^[0-9A-Za-z.+-]+$ ]] || { echo "ERROR: bad version '$v'"; exit 1; } - if curl -fsI "${URL}com/stirling/jpdfium/$v/jpdfium-$v.pom" >/dev/null 2>&1; then - action="already there, skipped" - elif ! curl -fsI "$SOURCE/com/stirling/jpdfium/$v/jpdfium-$v.pom" >/dev/null 2>&1; then - echo "ERROR: $v is not in $SOURCE"; exit 1 - else - action="copy" - copy+=("$v") - fi - echo "$v: $action" - echo "| $v | $action |" >> "$GITHUB_STEP_SUMMARY" - done - - { - echo "versions=$(printf '%s\n' "${copy[@]}" | jq -R . | jq -sc 'map(select(. != ""))')" - echo "destination=$DEST" - echo "url=$URL" - } >> "$GITHUB_OUTPUT" - copy: - name: Copy to ${{ needs.plan.outputs.url }} - needs: plan - if: ${{ !inputs.dryRun && needs.plan.outputs.versions != '[]' }} + name: Copy from Maven Central runs-on: ubuntu-latest environment: maven concurrency: group: stirling-maven cancel-in-progress: false - env: - SOURCE: ${{ inputs.source }} - VERSIONS: ${{ needs.plan.outputs.versions }} - DEST: ${{ needs.plan.outputs.destination }} - URL: ${{ needs.plan.outputs.url }} + outputs: + versions: ${{ steps.mirror.outputs.versions }} + url: ${{ steps.mirror.outputs.url }} steps: - - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 - - - name: Download every JPDFium module at each version - shell: bash - run: | - set -euo pipefail - SRC="${SOURCE%/}/com/stirling" - get() { curl -fsSL --retry 5 --retry-all-errors --retry-delay 5 --max-time 300 "$@"; } - modules=$(get "$SRC/" | grep -o 'href="jpdfium[^"/]*/' | cut -d'"' -f2 | tr -d /) - for v in $(echo "$VERSIONS" | jq -r '.[]'); do - for m in $modules; do - listing=$(curl -fsSL --retry 5 --retry-delay 5 "$SRC/$m/$v/" 2>/dev/null) || continue - for f in $(echo "$listing" | grep -o 'href="[^"]*"' | cut -d'"' -f2 | grep -v '^\.\./'); do - get --create-dirs -o "central-repo/com/stirling/$m/$v/$f" "$SRC/$m/$v/$f" - done - done - [ -f "central-repo/com/stirling/jpdfium/$v/jpdfium-$v.pom" ] || { echo "ERROR: nothing downloaded for $v"; exit 1; } - echo "$v: $(find central-repo -path "*/$v/*" -type f | wc -l) files" - done - - - name: Check every file against the source sha1 - shell: bash - run: | - bad=0 - while IFS= read -r sum; do - file="${sum%.sha1}" - [ -f "$file" ] || continue - [ "$(sha1sum "$file" | cut -d' ' -f1)" = "$(tr -d ' \n' < "$sum")" ] || { echo "MISMATCH $file"; bad=1; } - done < <(find central-repo -name '*.sha1') - exit "$bad" - - - name: Upload - shell: bash - env: - AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} - R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} - R2_BUCKET: s3://${{ vars.R2_BUCKET || 'stirling-maven' }} - run: bash .github/scripts/upload-to-r2.sh central-repo "$DEST" - - - name: Check every uploaded file is served unchanged - shell: bash - run: | - cd central-repo - bad=0; ok=0; n=0 - while IFS= read -r f; do - f="${f#./}" - served=$(curl -fsSL --retry 5 --retry-all-errors "$URL$f" | sha1sum | cut -d' ' -f1) || served=missing - if [ "$served" = "$(sha1sum "$f" | cut -d' ' -f1)" ]; then ok=$((ok + 1)); else echo "MISMATCH $URL$f"; bad=1; fi - n=$((n + 1)) - done < <(find . -type f ! -name 'maven-metadata.xml*') - echo "$ok of $n files served unchanged from $URL" | tee -a "$GITHUB_STEP_SUMMARY" - exit "$bad" + - id: mirror + uses: Stirling-Tools/maven-r2-publish/mirror@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # main + with: + group: com.stirling + artifact: jpdfium + versions: ${{ inputs.versions }} + latest: ${{ inputs.latest }} + destination: ${{ inputs.destination }} + dry-run: ${{ inputs.dryRun }} + endpoint: ${{ secrets.R2_ENDPOINT }} + access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} + secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} + bucket: ${{ vars.R2_BUCKET || 'stirling-maven' }} smoke: name: Smoke ${{ matrix.version }} (${{ matrix.platform }}) - needs: [plan, copy] - if: ${{ inputs.smoke && !inputs.dryRun && needs.plan.outputs.versions != '[]' }} + needs: copy + if: ${{ inputs.smoke && !inputs.dryRun && needs.copy.outputs.versions != '[]' }} strategy: fail-fast: false matrix: - version: ${{ fromJSON(needs.plan.outputs.versions) }} + version: ${{ fromJSON(needs.copy.outputs.versions) }} platform: [linux-x64, linux-arm64, darwin-x64, darwin-arm64, windows-x64, windows-arm64] include: - { platform: linux-x64, runner: ubuntu-24.04 } @@ -195,7 +84,7 @@ jobs: shell: bash env: MODE: r2 - R2_REPO_URL: ${{ needs.plan.outputs.url }} + R2_REPO_URL: ${{ needs.copy.outputs.url }} VERSION: ${{ matrix.version }} PLATFORM: ${{ matrix.platform }} run: bash .github/scripts/verify-central.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 52a7b12ee..9ca459617 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -960,6 +960,7 @@ jobs: environment: maven outputs: version: ${{ steps.v.outputs.version }} + staging-url: ${{ steps.stage.outputs.staging-url }} permissions: contents: write steps: @@ -1029,17 +1030,22 @@ jobs: echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "Publishing version: $VERSION" - - name: Stage on the Stirling Maven repo + - name: Build the signed release repo env: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} GPG_SIGNING_PASSWORD: ${{ secrets.GPG_SIGNING_PASSWORD }} - AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} - R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} - R2_BUCKET: s3://${{ vars.R2_BUCKET || 'stirling-maven' }} - run: | - ./gradlew publishAllToR2Staging -Pjpdfium.version=${{ steps.v.outputs.version }} --no-daemon --stacktrace - bash .github/scripts/upload-to-r2.sh build/r2-repo "staging/${{ github.run_id }}/" + run: ./gradlew publishAllToR2Staging -Pjpdfium.version=${{ steps.v.outputs.version }} --no-daemon --stacktrace + + - name: Stage on the Stirling Maven repo + id: stage + uses: Stirling-Tools/maven-r2-publish/release@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # main + with: + step: stage + repo-dir: build/r2-repo + endpoint: ${{ secrets.R2_ENDPOINT }} + access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} + secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} + bucket: ${{ vars.R2_BUCKET || 'stirling-maven' }} - name: Publish to Maven Local (dry run) if: inputs.dryRun == true @@ -1075,7 +1081,7 @@ jobs: run: | echo "### Staged com.stirling:*:${{ steps.v.outputs.version }}" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "https://maven.stirlingpdf.com/staging/${{ github.run_id }}/ - released to the root once every platform verifies." >> $GITHUB_STEP_SUMMARY + echo "${{ steps.stage.outputs.staging-url }} - released to the root once every platform verifies." >> $GITHUB_STEP_SUMMARY # ── Pre-release verification: every artifact in the staged deployment ── @@ -1120,7 +1126,7 @@ jobs: shell: bash env: MODE: r2 - R2_REPO_URL: https://maven.stirlingpdf.com/staging/${{ github.run_id }} + R2_REPO_URL: ${{ needs.publish.outputs.staging-url }} VERSION: ${{ steps.v.outputs.version }} PLATFORM: ${{ matrix.platform }} run: bash .github/scripts/verify-central.sh @@ -1135,29 +1141,15 @@ jobs: concurrency: group: stirling-maven cancel-in-progress: false - env: - AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: auto - AWS_REQUEST_CHECKSUM_CALCULATION: when_required - AWS_RESPONSE_CHECKSUM_VALIDATION: when_required - R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} - R2_BUCKET: s3://${{ vars.R2_BUCKET || 'stirling-maven' }} steps: - - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 - - - name: Fetch the verified staging set - run: aws s3 sync "$R2_BUCKET/staging/${{ github.run_id }}/" staged/ --endpoint-url "$R2_ENDPOINT" --no-progress - - - name: Release - run: bash .github/scripts/upload-to-r2.sh staged - - - name: Summary - env: - VERSION: ${{ needs.publish.outputs.version }} - run: | - curl -fsSI "https://maven.stirlingpdf.com/com/stirling/jpdfium/$VERSION/jpdfium-$VERSION.pom" >/dev/null - echo "### Released com.stirling:*:$VERSION to https://maven.stirlingpdf.com" >> $GITHUB_STEP_SUMMARY + - name: Release the verified staging set + uses: Stirling-Tools/maven-r2-publish/release@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # main + with: + step: promote + endpoint: ${{ secrets.R2_ENDPOINT }} + access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} + secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} + bucket: ${{ vars.R2_BUCKET || 'stirling-maven' }} publish-central: name: Publish to Maven Central @@ -1258,11 +1250,11 @@ jobs: runs-on: ubuntu-latest environment: maven steps: - - name: Delete staging/${{ github.run_id }} - env: - AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: auto - AWS_REQUEST_CHECKSUM_CALCULATION: when_required - AWS_RESPONSE_CHECKSUM_VALIDATION: when_required - run: aws s3 rm "s3://${{ vars.R2_BUCKET || 'stirling-maven' }}/staging/${{ github.run_id }}/" --recursive --endpoint-url "${{ secrets.R2_ENDPOINT }}" --only-show-errors + - name: Delete this run's staging copy + uses: Stirling-Tools/maven-r2-publish/release@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # main + with: + step: cleanup + endpoint: ${{ secrets.R2_ENDPOINT }} + access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} + secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} + bucket: ${{ vars.R2_BUCKET || 'stirling-maven' }} diff --git a/build.gradle.kts b/build.gradle.kts index 4b9c9795b..6f5e21ef9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -330,7 +330,7 @@ tasks.register("publishAllToCentralPortal") { } // Release layout for https://maven.stirlingpdf.com; release.yml uploads it with -// .github/scripts/upload-to-r2.sh. +// Stirling-Tools/maven-r2-publish. val r2StagingDir = layout.buildDirectory.dir("r2-repo") subprojects { From 4931c38a081a9f1481335b031c92d23d8a2b908a Mon Sep 17 00:00:00 2001 From: Frooodle <77850077+Frooodle@users.noreply.github.com> Date: Fri, 6 Nov 2026 23:55:22 +0000 Subject: [PATCH 08/10] Label the maven-r2-publish pins with v1.0.0 --- .github/workflows/mirror-central-to-r2.yml | 2 +- .github/workflows/release.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mirror-central-to-r2.yml b/.github/workflows/mirror-central-to-r2.yml index eaafbb5f8..33ab331d5 100644 --- a/.github/workflows/mirror-central-to-r2.yml +++ b/.github/workflows/mirror-central-to-r2.yml @@ -42,7 +42,7 @@ jobs: url: ${{ steps.mirror.outputs.url }} steps: - id: mirror - uses: Stirling-Tools/maven-r2-publish/mirror@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # main + uses: Stirling-Tools/maven-r2-publish/mirror@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # v1.0.0 with: group: com.stirling artifact: jpdfium diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ca459617..913d74eae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1038,7 +1038,7 @@ jobs: - name: Stage on the Stirling Maven repo id: stage - uses: Stirling-Tools/maven-r2-publish/release@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # main + uses: Stirling-Tools/maven-r2-publish/release@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # v1.0.0 with: step: stage repo-dir: build/r2-repo @@ -1143,7 +1143,7 @@ jobs: cancel-in-progress: false steps: - name: Release the verified staging set - uses: Stirling-Tools/maven-r2-publish/release@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # main + uses: Stirling-Tools/maven-r2-publish/release@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # v1.0.0 with: step: promote endpoint: ${{ secrets.R2_ENDPOINT }} @@ -1251,7 +1251,7 @@ jobs: environment: maven steps: - name: Delete this run's staging copy - uses: Stirling-Tools/maven-r2-publish/release@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # main + uses: Stirling-Tools/maven-r2-publish/release@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # v1.0.0 with: step: cleanup endpoint: ${{ secrets.R2_ENDPOINT }} From 99195c7f88af54d3432b173e19c02728d4ee0a98 Mon Sep 17 00:00:00 2001 From: Frooodle <77850077+Frooodle@users.noreply.github.com> Date: Sat, 7 Nov 2026 15:49:47 +0000 Subject: [PATCH 09/10] Validate the release version, keep staging on failure and attach CLI binaries after the release --- .github/workflows/mirror-central-to-r2.yml | 2 +- .github/workflows/release.yml | 114 +++++++++--------- docs/native-loading.md | 4 +- .../jpdfium/panama/NativeDownloaderTest.java | 6 + 4 files changed, 66 insertions(+), 60 deletions(-) diff --git a/.github/workflows/mirror-central-to-r2.yml b/.github/workflows/mirror-central-to-r2.yml index 33ab331d5..d28f3f2b5 100644 --- a/.github/workflows/mirror-central-to-r2.yml +++ b/.github/workflows/mirror-central-to-r2.yml @@ -42,7 +42,7 @@ jobs: url: ${{ steps.mirror.outputs.url }} steps: - id: mirror - uses: Stirling-Tools/maven-r2-publish/mirror@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # v1.0.0 + uses: Stirling-Tools/maven-r2-publish/mirror@137b6b342d035155657660adf93da370b518ed8d # main with: group: com.stirling artifact: jpdfium diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 913d74eae..2d5f04dbc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -961,8 +961,6 @@ jobs: outputs: version: ${{ steps.v.outputs.version }} staging-url: ${{ steps.stage.outputs.staging-url }} - permissions: - contents: write steps: - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 @@ -994,13 +992,6 @@ jobs: path: .artifacts pattern: natives-* - - name: Download all CLI binaries - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.1 - continue-on-error: true # CLI legs can fail independently; natives still publish - with: - path: .artifacts - pattern: cli-* - - name: Flatten into native/dist// run: | mkdir -p native/dist @@ -1023,8 +1014,8 @@ jobs: REF="${GITHUB_REF_NAME}" VERSION="${REF#v}" fi - if [ -z "$VERSION" ]; then - echo "ERROR: could not resolve version" + if ! [[ "$VERSION" =~ ^[0-9A-Za-z._-]+$ ]]; then + echo "ERROR: '$VERSION' is not a valid release version" exit 1 fi echo "version=$VERSION" >> "$GITHUB_OUTPUT" @@ -1034,11 +1025,12 @@ jobs: env: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} GPG_SIGNING_PASSWORD: ${{ secrets.GPG_SIGNING_PASSWORD }} - run: ./gradlew publishAllToR2Staging -Pjpdfium.version=${{ steps.v.outputs.version }} --no-daemon --stacktrace + VERSION: ${{ steps.v.outputs.version }} + run: ./gradlew publishAllToR2Staging "-Pjpdfium.version=$VERSION" --no-daemon --stacktrace - name: Stage on the Stirling Maven repo id: stage - uses: Stirling-Tools/maven-r2-publish/release@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # v1.0.0 + uses: Stirling-Tools/maven-r2-publish/release@137b6b342d035155657660adf93da370b518ed8d # main with: step: stage repo-dir: build/r2-repo @@ -1053,42 +1045,23 @@ jobs: VERSION: ${{ steps.v.outputs.version }} run: ./gradlew publishToMavenLocal "-Pjpdfium.version=$VERSION" --no-daemon --stacktrace - - name: Attach CLI binaries to GitHub Release - if: startsWith(github.ref, 'refs/tags/') && inputs.dryRun != true - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - TAG="${GITHUB_REF_NAME}" - mkdir -p dist/cli - # Download-artifact nests each artifact under .artifacts/cli-/. - for d in .artifacts/cli-*; do - [ -d "$d" ] || continue - cp -v "$d"/jpdfium-* dist/cli/ 2>/dev/null || true - done - if ls dist/cli/* >/dev/null 2>&1; then - gh release view "$TAG" >/dev/null 2>&1 || \ - gh release create "$TAG" --title "JPDFium ${TAG#v}" --generate-notes - gh release upload "$TAG" dist/cli/* --clobber - echo "Attached CLI binaries to release $TAG:" >> $GITHUB_STEP_SUMMARY - ls -la dist/cli/ >> $GITHUB_STEP_SUMMARY - else - echo "No CLI binaries built for this release." >> $GITHUB_STEP_SUMMARY - fi - - name: Summary env: VERSION: ${{ steps.v.outputs.version }} + STAGING_URL: ${{ steps.stage.outputs.staging-url }} run: | - echo "### Staged com.stirling:*:${{ steps.v.outputs.version }}" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "${{ steps.stage.outputs.staging-url }} - released to the root once every platform verifies." >> $GITHUB_STEP_SUMMARY + { + echo "### Staged com.stirling:*:$VERSION" + echo "" + echo "$STAGING_URL - released to the root once every platform verifies." + } >> "$GITHUB_STEP_SUMMARY" # ── Pre-release verification: every artifact in the staged deployment ── verify-staging: name: Verify staged artifacts (${{ matrix.platform }}) needs: publish - if: inputs.dryRun != true && (startsWith(github.ref, 'refs/tags/') || inputs.version != '') + if: startsWith(github.ref, 'refs/tags/') || inputs.version != '' strategy: fail-fast: false matrix: @@ -1108,26 +1081,12 @@ jobs: distribution: ${{ matrix.platform == 'windows-arm64' && 'microsoft' || 'temurin' }} java-version: '25' - - name: Resolve version - id: v - shell: bash - env: - INPUT_VERSION: ${{ inputs.version }} - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "$INPUT_VERSION" ]; then - VERSION="$INPUT_VERSION" - else - REF="${GITHUB_REF_NAME}" - VERSION="${REF#v}" - fi - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - - name: Verify every staged artifact and run the smoke shell: bash env: MODE: r2 R2_REPO_URL: ${{ needs.publish.outputs.staging-url }} - VERSION: ${{ steps.v.outputs.version }} + VERSION: ${{ needs.publish.outputs.version }} PLATFORM: ${{ matrix.platform }} run: bash .github/scripts/verify-central.sh @@ -1143,7 +1102,7 @@ jobs: cancel-in-progress: false steps: - name: Release the verified staging set - uses: Stirling-Tools/maven-r2-publish/release@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # v1.0.0 + uses: Stirling-Tools/maven-r2-publish/release@137b6b342d035155657660adf93da370b518ed8d # main with: step: promote endpoint: ${{ secrets.R2_ENDPOINT }} @@ -1151,11 +1110,52 @@ jobs: secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} bucket: ${{ vars.R2_BUCKET || 'stirling-maven' }} + attach-cli: + name: Attach CLI binaries to the GitHub release + needs: [publish, promote] + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 + + - name: Download all CLI binaries + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.1 + continue-on-error: true # CLI legs can fail independently; the release still ships + with: + path: .artifacts + pattern: cli-* + + - name: Attach CLI binaries to GitHub Release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + TAG="${GITHUB_REF_NAME}" + mkdir -p dist/cli + # Download-artifact nests each artifact under .artifacts/cli-/. + for d in .artifacts/cli-*; do + [ -d "$d" ] || continue + cp -v "$d"/jpdfium-* dist/cli/ 2>/dev/null || true + done + if ls dist/cli/* >/dev/null 2>&1; then + gh release view "$TAG" >/dev/null 2>&1 || \ + gh release create "$TAG" --title "JPDFium ${TAG#v}" --generate-notes + gh release upload "$TAG" dist/cli/* --clobber + echo "Attached CLI binaries to release $TAG:" >> "$GITHUB_STEP_SUMMARY" + ls -la dist/cli/ >> "$GITHUB_STEP_SUMMARY" + else + echo "No CLI binaries built for this release." >> "$GITHUB_STEP_SUMMARY" + fi + publish-central: name: Publish to Maven Central needs: [publish, promote] runs-on: ubuntu-latest continue-on-error: true + concurrency: + group: central-portal + cancel-in-progress: false steps: - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 @@ -1246,12 +1246,12 @@ jobs: cleanup-staging: name: Delete the staging copy needs: [publish, verify-staging, promote] - if: ${{ always() && needs.publish.result == 'success' }} + if: ${{ always() && needs.publish.result == 'success' && needs.verify-staging.result != 'failure' && needs.promote.result != 'failure' }} runs-on: ubuntu-latest environment: maven steps: - name: Delete this run's staging copy - uses: Stirling-Tools/maven-r2-publish/release@0a5de1828b80dc12ff16023a2aadf6dd9a6faff4 # v1.0.0 + uses: Stirling-Tools/maven-r2-publish/release@137b6b342d035155657660adf93da370b518ed8d # main with: step: cleanup endpoint: ${{ secrets.R2_ENDPOINT }} diff --git a/docs/native-loading.md b/docs/native-loading.md index b8d57f97e..95d358e82 100644 --- a/docs/native-loading.md +++ b/docs/native-loading.md @@ -8,9 +8,9 @@ Packaging depends on your deployment model; see [deployment.md](deployment.md). ## Downloading at runtime -As an alternative to bundling, JPDFium can download the matching native artifact from https://maven.stirlingpdf.com the first time it runs and reuse the cached copy afterwards. +As an alternative to bundling, JPDFium can download the matching native artifact from https://maven.stirlingpdf.com, or the repository set in `jpdfium.native.repo`, the first time it runs and reuse the cached copy afterward. -This is disabled by default. Enable it only when network access to maven.stirlingpdf.com is acceptable at runtime: +This is disabled by default. Enable it only when network access to the configured repository is acceptable at runtime: ```bash java -Djpdfium.native.download=true --enable-native-access=ALL-UNNAMED -jar app.jar diff --git a/jpdfium/src/test/java/stirling/software/jpdfium/panama/NativeDownloaderTest.java b/jpdfium/src/test/java/stirling/software/jpdfium/panama/NativeDownloaderTest.java index 2ba759492..b924e1595 100644 --- a/jpdfium/src/test/java/stirling/software/jpdfium/panama/NativeDownloaderTest.java +++ b/jpdfium/src/test/java/stirling/software/jpdfium/panama/NativeDownloaderTest.java @@ -113,6 +113,12 @@ void jarUrlUsesCentralLayout() { NativeDownloader.jarUrl("windows-x64", "1.1.5", "https://repo1.maven.org/maven2")); } + @Test + void repoBaseDefaultsToTheStirlingRepository() { + System.clearProperty(NativeDownloader.REPO_PROPERTY); + assertEquals("https://maven.stirlingpdf.com", NativeDownloader.repoBase()); + } + @Test void repoBaseTrimsSlashesAndRejectsPlainHttp() { System.setProperty(NativeDownloader.REPO_PROPERTY, "https://repo1.maven.org/maven2///"); From 4ca0a748b322719ec9e99be74589ced3e2877c2c Mon Sep 17 00:00:00 2001 From: Frooodle <77850077+Frooodle@users.noreply.github.com> Date: Sat, 7 Nov 2026 16:24:10 +0000 Subject: [PATCH 10/10] Harden the Central and CLI release jobs and refuse smoke for pre-1.1 mirrors --- .github/workflows/mirror-central-to-r2.yml | 14 +++++++++++++- .github/workflows/release.yml | 6 ++++++ docs/installation.md | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mirror-central-to-r2.yml b/.github/workflows/mirror-central-to-r2.yml index d28f3f2b5..baa31b3cf 100644 --- a/.github/workflows/mirror-central-to-r2.yml +++ b/.github/workflows/mirror-central-to-r2.yml @@ -8,7 +8,7 @@ on: required: true default: 'all' latest: - description: 'With all, copy only this many of the newest versions' + description: 'With all, copy only this many of the newest versions (smoke needs 1.1.0 or newer)' required: false default: '5' destination: @@ -41,6 +41,18 @@ jobs: versions: ${{ steps.mirror.outputs.versions }} url: ${{ steps.mirror.outputs.url }} steps: + - name: Refuse smoke for releases older than its artifact set + if: ${{ inputs.smoke && inputs.versions != 'all' }} + env: + VERSIONS: ${{ inputs.versions }} + run: | + for v in $(echo "$VERSIONS" | tr -s ', ' '\n'); do + if [ "$(printf '%s\n1.1.0\n' "$v" | sort -V | head -1)" != 1.1.0 ]; then + echo "ERROR: smoke expects the jpdfium-vips modules added in 1.1.0; $v predates them. Copy it without smoke." + exit 1 + fi + done + - id: mirror uses: Stirling-Tools/maven-r2-publish/mirror@137b6b342d035155657660adf93da370b518ed8d # main with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2d5f04dbc..f92a58391 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1119,6 +1119,8 @@ jobs: contents: write steps: - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 + with: + persist-credentials: false - name: Download all CLI binaries uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.1 @@ -1158,6 +1160,8 @@ jobs: cancel-in-progress: false steps: - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1 + with: + persist-credentials: false - uses: actions/setup-java@816722acf8fd27c9d1e9ae6ee6085da07e0d44c1 # v5.7.0 with: @@ -1166,6 +1170,8 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@c8a326d85724fce2ae59a38810306f4a058f26a4 # v6.3.0 + with: + cache-disabled: true - name: Install jextract # jpdfium/build.gradle.kts uses jextract to generate JpdfiumH.java diff --git a/docs/installation.md b/docs/installation.md index d2f2202a3..2aba1c769 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -1,6 +1,6 @@ # Installation -JPDFium publishes to https://maven.stirlingpdf.com under the `com.stirling` group, and releases are also published to Maven Central. The current release is **1.3.1**. +JPDFium publishes to https://maven.stirlingpdf.com under the `com.stirling` group. Each release is then also sent to Maven Central, but that copy is best effort: a release can be on maven.stirlingpdf.com before, or without, reaching Central. The current release is **1.3.1**. ## Requirements