From abf2f3091bcb087021bd5704b160017cf08c29f1 Mon Sep 17 00:00:00 2001 From: Gian Tschingt Date: Mon, 16 Nov 2026 18:28:33 +0100 Subject: [PATCH 1/2] Release workflow: build numbers, manual releases and pre-releases, only finals to Maven Central - the version is base.N[qualifier], N is the highest existing build + 1 (git tags, Maven Central, Central snapshots, maven.lucee-services.com), like the other extensions and Lucee core - a manual run (workflow_dispatch) with deploy ticked publishes the next build as SNAPSHOT, ALPHA, BETA, RC or final release - only a final goes to Maven Central, SNAPSHOT, ALPHA, BETA and RC go to maven.lucee-services.com only (shared extension-s3-upload workflow) - ALPHA, BETA and RC get a GitHub pre-release, a final a GitHub release - deploy only runs for a push to main or a manual run, never for a pull request - deploy.url is set for the deploy of the lite .lex, ${revision} is resolved in the installed pom (flatten) and has a default in source/java/pom.xml - the tests fall back to a fixed 9.0 build when LUCEE_TEST_VERSIONS_9 is not available (pull requests from forks) --- .github/workflows/main.yml | 357 +++++++++++++++++++++++++++++++------ .gitignore | 1 + README.md | 19 ++ pom.xml | 50 +++++- source/java/pom.xml | 3 + 5 files changed, 370 insertions(+), 60 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d4ae41a..873d181 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,81 +1,210 @@ name: Java CI -on: [push, pull_request, workflow_dispatch] +# Push to main publishes a new numbered -SNAPSHOT to maven.lucee-services.com, never Maven Central. +# A manual run with deploy ticked publishes the next build number with the chosen qualifier: +# release (no qualifier): Maven Central and maven.lucee-services.com, plus a GitHub release +# ALPHA / BETA / RC: signed install, maven.lucee-services.com and a GitHub pre-release, never Central +# SNAPSHOT: signed install and maven.lucee-services.com, never Central +# Build numbers come from git tags, Maven Central, the Central snapshot repository, and maven.lucee-services.com. +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + inputs: + deploy: + description: 'Publish a new build number. Finals go to Maven Central; ALPHA, BETA, RC and SNAPSHOT go to maven.lucee-services.com only' + type: boolean + default: false + qualifier: + description: 'Qualifier for this run. "pom" keeps extension.version.qualifier from pom.xml (-SNAPSHOT). SNAPSHOT, ALPHA, BETA and RC are published to maven.lucee-services.com, never Maven Central. "release" (no qualifier) is the final and goes to Maven Central' + type: choice + options: [pom, SNAPSHOT, ALPHA, BETA, RC, release] + default: pom + +# Run builds of the same ref one after another, so every push to main resolves its own +# revision (highest build + 1) only after the previous build has published and created its tag. +# PRs have their own ref (refs/pull/N/merge), so they are not blocked by main builds. +# queue: max keeps up to 100 pending runs (default would keep only one and cancel older pending runs). +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + queue: max jobs: - setup: + build: runs-on: ubuntu-latest + timeout-minutes: 15 + env: + # like Lucee core (LDEV-6516): every push to main publishes a new build, a manual run publishes when deploy is ticked. + # PRs never publish. Runs without the deploy secrets (forks) only build and test, see "Resolve next revision". + DO_DEPLOY: ${{ (github.event_name == 'workflow_dispatch' && inputs.deploy) || (github.event_name == 'push' && github.ref == 'refs/heads/main') }} + QUALIFIER_INPUT: ${{ inputs.qualifier || 'pom' }} outputs: version: ${{ steps.extract-version.outputs.VERSION }} + tag: ${{ steps.extract-version.outputs.TAG }} + deploy: ${{ steps.extract-version.outputs.DEPLOY }} steps: - - name: Checkout repository - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up JDK 21 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: - distribution: 'temurin' java-version: '21' + distribution: 'temurin' - name: Cache Maven packages - uses: actions/cache@v4 + uses: actions/cache@v5 with: - path: ~/.m2 - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- + path: ~/.m2/repository + key: maven-${{ hashFiles('pom.xml') }} + restore-keys: maven- + + # ubuntu-latest moved to Maven 3.10.0 (runner image 20261004). With it, central-publishing-maven-plugin + # leaves maven-metadata-local.xml in the staging dir, which Central rejects. Pin Maven 3.9.x like Lucee core. + - name: Set up Maven 3.9.16 + run: | + MVN_VERSION=3.9.16 + MVN_SHA512=831a8591fe20c8243b1dbe7d71e3244f31d1665b0804b2e825e38cbbe5ce0cafb8338851f90780735568773e0a6cd07bbec107cda0b896b008b861075358b6f6 + curl -fsSL -o "$RUNNER_TEMP/maven.tar.gz" "https://repo1.maven.org/maven2/org/apache/maven/apache-maven/$MVN_VERSION/apache-maven-$MVN_VERSION-bin.tar.gz" + echo "$MVN_SHA512 $RUNNER_TEMP/maven.tar.gz" | sha512sum -c - + tar xzf "$RUNNER_TEMP/maven.tar.gz" -C "$RUNNER_TEMP" + echo "$RUNNER_TEMP/apache-maven-$MVN_VERSION/bin" >> $GITHUB_PATH + "$RUNNER_TEMP/apache-maven-$MVN_VERSION/bin/mvn" -v + + - name: Resolve next revision + run: | + set -euo pipefail + # Only builds that publish allocate a build number: every push to main and manual runs with deploy ticked. + # PRs and runs without the deploy secrets (forks) keep the default POM revision (base.0 + qualifier) and publish nothing. + if [ "$DO_DEPLOY" != "true" ]; then + echo "Skipping revision bump (not a push to main / manual deploy)" + exit 0 + fi + # without deploy credentials nothing gets published, so do not consume a build number + if [ "${{ secrets.GPG_PASSPHRASE }}" == "" ] || [ "${{ secrets.MAVEN_USERNAME }}" == "" ]; then + echo "Skipping revision bump (no GPG / Maven deploy credentials; test-only run)" + exit 0 + fi + + BASE=$(mvn help:evaluate -Dexpression=extension.version.base -q -DforceStdout | tr -d '\r') + QUALIFIER=$(mvn help:evaluate -Dexpression=extension.version.qualifier -q -DforceStdout | tr -d '\r') + # an empty property evaluates to "null" + [ "$QUALIFIER" == "null" ] && QUALIFIER="" + # a manual run can publish the current code as ALPHA, BETA, RC or final release instead of the pom qualifier + case "$QUALIFIER_INPUT" in + pom|"") ;; + release) QUALIFIER="" ;; + SNAPSHOT|ALPHA|BETA|RC) QUALIFIER="-$QUALIFIER_INPUT" ;; + *) echo "::error::unknown qualifier input [$QUALIFIER_INPUT]"; exit 1 ;; + esac + echo "Base=$BASE qualifier=$QUALIFIER" + BASE_RE=$(printf '%s' "$BASE" | sed 's/\./\\./g') + + git fetch --tags --force origin 2>/dev/null || true + + # highest build of this base, from git tags (base.N), Maven Central, the Central snapshot repository + # and maven.lucee-services.com (base.N[-QUALIFIER]). All are checked so a version published without a + # tag (e.g. 1.0.0.0-ALPHA) or only to the Lucee Maven repository is never built twice. + BUILDS=$(git tag -l "${BASE}.*" | sed -nE "s/^${BASE_RE}\.([0-9]+)$/\1/p" || true) + for url in \ + "https://repo1.maven.org/maven2/org/lucee/osgi-extension/maven-metadata.xml" \ + "https://repo1.maven.org/maven2/org/lucee/osgi/maven-metadata.xml" \ + "https://central.sonatype.com/repository/maven-snapshots/org/lucee/osgi-extension/maven-metadata.xml" \ + "https://central.sonatype.com/repository/maven-snapshots/org/lucee/osgi/maven-metadata.xml" \ + "https://maven.lucee-services.com/org/lucee/osgi-extension/maven-metadata.xml" \ + "https://maven.lucee-services.com/org/lucee/osgi/maven-metadata.xml" + do + META=$(curl -fsSL --max-time 30 "$url" 2>/dev/null || true) + BUILDS="$BUILDS"$'\n'$(printf '%s' "$META" | grep -oE "${BASE_RE}\.[0-9]+([-.][^<]*)?" | sed -E "s#${BASE_RE}\.([0-9]+).*#\1#" || true) + done + MAX_BUILD=$(printf '%s\n' "$BUILDS" | grep -E '^[0-9]+$' | sort -n | tail -1 || true) + + if [ -z "$MAX_BUILD" ]; then + NEXT_BUILD=0 + else + NEXT_BUILD=$((MAX_BUILD + 1)) + fi + + VERSION="${BASE}.${NEXT_BUILD}${QUALIFIER}" + # tag shape matches existing tags (1.0.0.0, 1.0.0.1): numeric 4-part without qualifier + TAG="${BASE}.${NEXT_BUILD}" + echo "Resolved VERSION=$VERSION TAG=$TAG (max seen build=${MAX_BUILD:-none})" + echo "VERSION=$VERSION" >> "$GITHUB_ENV" + echo "TAG=$TAG" >> "$GITHUB_ENV" + echo "DEPLOY=true" >> "$GITHUB_ENV" - name: Extract version number id: extract-version run: | - VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + set -euo pipefail + if [ -z "${VERSION:-}" ]; then + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | tr -d '\r') + fi + if ! echo "$VERSION" | grep -Eq '^[0-9]+(\.[0-9]+){3}(-[A-Za-z0-9]+)*$'; then + echo "::error::[$VERSION] is not a valid extension version"; exit 1 + fi + echo "Using VERSION=$VERSION TAG=${TAG:-}" echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + echo "TAG=${TAG:-}" >> $GITHUB_OUTPUT + echo "DEPLOY=${DEPLOY:-false}" >> $GITHUB_OUTPUT - - name: Cache Lucee files - uses: actions/cache@v4 + - name: Build extension + env: + VERSION: ${{ steps.extract-version.outputs.VERSION }} + run: mvn -B -e clean package -Dgoal=install -Drevision="$VERSION" + + - name: Upload Artifact + uses: actions/upload-artifact@v7 with: - path: ~/work/_actions/lucee/script-runner/main/lucee-download-cache - key: lucee-downloads + name: osgi-lex + path: | + target/*.lex + !target/*.lite.lex + + # everything the S3 upload needs (LDEV-6568): full and lite .lex plus the flattened POM + - name: Upload artifact for S3 + if: steps.extract-version.outputs.DEPLOY == 'true' + uses: actions/upload-artifact@v4 + with: + name: osgi-s3 + include-hidden-files: true + path: | + target/*.lex + .flattened-pom.xml - build-and-test: + test: runs-on: ubuntu-latest - needs: setup - env: - LUCEE_TEST_VERSIONS_9: ${{ vars.LUCEE_TEST_VERSIONS_9 }} + timeout-minutes: 30 + needs: build strategy: fail-fast: false matrix: - lucee: ${{ fromJSON(vars.LUCEE_TEST_VERSIONS_9) }} + # repository variables are not available to pull requests from forks, fall back to a fixed 9.0 build + lucee: ${{ fromJSON(vars.LUCEE_TEST_VERSIONS_9 || '[{"version":"9.0.0.1487-ALPHA","query":"9.0/all/light","branch":"9.0"}]') }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up JDK 21 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: java-version: '21' distribution: 'temurin' - - name: Build and Install with Maven - env: - MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - run: | - echo "------- Maven Install -------"; - mvn -B -e -f pom.xml clean install -Dgoal=install - - - name: Set artifact name - id: artifact - run: echo "name=osgi-lex-$(echo '${{ matrix.lucee.query }}' | tr '/' '-')" >> $GITHUB_OUTPUT + - name: Cache Lucee files + uses: actions/cache@v5 + with: + path: ~/work/_actions/lucee/script-runner/main/lucee-download-cache + key: lucee-downloads - - name: Upload Artifact - uses: actions/upload-artifact@v4 + - name: Download extension artifact + uses: actions/download-artifact@v8 with: - name: ${{ steps.artifact.outputs.name }} - path: target/*.lex + name: osgi-lex + path: target - name: Checkout Lucee - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: lucee/lucee path: lucee @@ -85,7 +214,7 @@ jobs: - name: Download Lucee ${{ matrix.lucee.version }} run: | mkdir -p "${{ runner.temp }}/lucee-jar" - curl -fsSL -o "${{ runner.temp }}/lucee-jar/lucee-light-${{ matrix.lucee.version }}.jar" \ + curl -fsSL --retry 3 -o "${{ runner.temp }}/lucee-jar/lucee-light-${{ matrix.lucee.version }}.jar" \ "${{ vars.LUCEE_MAVEN_URL || 'https://maven.lucee-services.com' }}/org/lucee/lucee/${{ matrix.lucee.version }}/lucee-${{ matrix.lucee.version }}-light.jar" - name: Run Lucee Test Suite @@ -104,25 +233,40 @@ jobs: deploy: runs-on: ubuntu-latest - needs: [setup, build-and-test] - if: always() && needs.build-and-test.result == 'success' + timeout-minutes: 15 + needs: [build, test] + # set by the build job: push to the release branch or manual deploy, with the deploy secrets available + if: needs.build.outputs.deploy == 'true' + permissions: + # push the tag of the published revision + contents: write steps: - - name: Checkout repository - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up JDK 21 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: 'temurin' java-version: '21' + # ubuntu-latest moved to Maven 3.10.0 (runner image 20261004). With it, central-publishing-maven-plugin + # leaves maven-metadata-local.xml in the staging dir, which Central rejects. Pin Maven 3.9.x like Lucee core. + - name: Set up Maven 3.9.16 + run: | + MVN_VERSION=3.9.16 + MVN_SHA512=831a8591fe20c8243b1dbe7d71e3244f31d1665b0804b2e825e38cbbe5ce0cafb8338851f90780735568773e0a6cd07bbec107cda0b896b008b861075358b6f6 + curl -fsSL -o "$RUNNER_TEMP/maven.tar.gz" "https://repo1.maven.org/maven2/org/apache/maven/apache-maven/$MVN_VERSION/apache-maven-$MVN_VERSION-bin.tar.gz" + echo "$MVN_SHA512 $RUNNER_TEMP/maven.tar.gz" | sha512sum -c - + tar xzf "$RUNNER_TEMP/maven.tar.gz" -C "$RUNNER_TEMP" + echo "$RUNNER_TEMP/apache-maven-$MVN_VERSION/bin" >> $GITHUB_PATH + "$RUNNER_TEMP/apache-maven-$MVN_VERSION/bin/mvn" -v + - name: Cache Maven packages - uses: actions/cache@v4 + uses: actions/cache@v5 with: - path: ~/.m2 - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- + path: ~/.m2/repository + key: maven-${{ hashFiles('pom.xml') }} + restore-keys: maven- - name: Import GPG key run: | @@ -132,17 +276,112 @@ jobs: - name: Build and Deploy with Maven env: + VERSION: ${{ needs.build.outputs.version }} MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} run: | - if [[ "${{ needs.setup.outputs.version }}" == *-SNAPSHOT ]]; then - echo "------- Maven Deploy snapshot on ${{ github.event_name }} -------"; - mvn -B -e -f pom.xml clean deploy -Dgoal=deploy -DperformRelease=true --settings maven-settings.xml - elif [[ "${{ needs.setup.outputs.version }}" == *-ALPHA ]]; then - echo "------- Maven Install alpha on ${{ github.event_name }} -------"; - mvn -B -e -f pom.xml clean install -Dgoal=install --settings maven-settings.xml + set -euo pipefail + # Only a final release (no qualifier) is deployed to Maven Central, using the same ossrh server + # id, MAVEN_USERNAME / MAVEN_PASSWORD secrets and maven-settings.xml as the other extensions. + # ALPHA, BETA, RC and SNAPSHOT are signed with mvn install and published to maven.lucee-services.com + # by the s3 job (same shared extension-s3-upload.yml as MongoDB, HSQLDB and Image). Never Central. + if [[ "$VERSION" == *-SNAPSHOT ]] || [[ "$VERSION" =~ -(RC|BETA|ALPHA)$ ]]; then + echo "------- Maven Install (signed) $VERSION, Lucee Maven repository (maven.lucee-services.com), never Central -------"; + mvn -B -e clean install -Dgoal=install -DperformRelease=true -Drevision="$VERSION" --settings maven-settings.xml + else + echo "------- Maven Deploy release $VERSION to Maven Central -------"; + mvn -B -e clean deploy -Dgoal=deploy -DperformRelease=true -Drevision="$VERSION" --settings maven-settings.xml + fi + + - name: Tag published revision + if: success() && needs.build.outputs.tag != '' + env: + TAG: ${{ needs.build.outputs.tag }} + VERSION: ${{ needs.build.outputs.version }} + run: | + set -euo pipefail + git fetch --tags --force origin 2>/dev/null || true + if git rev-parse "refs/tags/$TAG" >/dev/null 2>&1; then + echo "Tag $TAG already exists - skipping" + exit 0 + fi + echo "Creating annotated tag $TAG for $VERSION" + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git tag -a "$TAG" -m "$VERSION" + git push origin "refs/tags/$TAG" + + # LDEV-6602: publish every final, ALPHA, BETA and RC build as a GitHub release with its .lex files attached, + # so downloads can be served from GitHub releases. ALPHA, BETA and RC are marked as pre-releases. + # -SNAPSHOT builds get no GitHub release. + # Separate job, so a failure here never blocks the Maven Central or Lucee Maven repository upload. + github-release: + runs-on: ubuntu-latest + timeout-minutes: 10 + needs: [build, deploy] + if: needs.build.outputs.deploy == 'true' && !endsWith(needs.build.outputs.version, '-SNAPSHOT') + permissions: + # create the release (and the tag of a qualifier version) and upload its assets + contents: write + steps: + # the same files the S3 job uploads (built by the build job with the published version) + - name: Download published extension + uses: actions/download-artifact@v8 + with: + name: osgi-s3 + path: release-files + + - name: Create GitHub release + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + VERSION: ${{ needs.build.outputs.version }} + TAG: ${{ needs.build.outputs.tag }} + IS_DEFAULT_BRANCH: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + set -euo pipefail + mapfile -t FILES < <(find release-files -type f -name "*-${VERSION}.lex" -o -type f -name "*-${VERSION}.lite.lex" | sort) + if [ "${#FILES[@]}" -eq 0 ]; then + echo "::error::no .lex files for $VERSION found"; find release-files -type f; exit 1 + fi + printf 'Asset: %s\n' "${FILES[@]}" + + # the release tag is the exact published version. A final release (1.0.0.3) reuses the build tag the deploy job + # pushed, a qualifier version (1.0.0.3-RC) gets its own tag on the same commit. Qualifier tags do not match + # the build number lookup (^BASE\.([0-9]+)$) in "Resolve next revision". + if [[ "$VERSION" == *-* ]]; then + PRE=(--prerelease --latest=false) + elif [ "$IS_DEFAULT_BRANCH" == "true" ]; then + PRE=(--latest) + else + PRE=(--latest=false) + fi + if [ "$VERSION" == "$TAG" ]; then + TARGET=(--verify-tag) else - echo "------- Maven Deploy release on ${{ github.event_name }} -------"; - mvn -B -e -f pom.xml clean deploy -Dgoal=deploy -DperformRelease=true --settings maven-settings.xml + # creates the tag on this commit if it does not exist yet + TARGET=(--target "$GITHUB_SHA") fi + + if gh release view "$VERSION" >/dev/null 2>&1; then + echo "Release $VERSION already exists - uploading assets again" + gh release upload "$VERSION" "${FILES[@]}" --clobber + else + echo "Creating release $VERSION ${PRE[*]} ${TARGET[*]}" + gh release create "$VERSION" "${FILES[@]}" "${PRE[@]}" "${TARGET[@]}" \ + --title "$VERSION" \ + --notes "Build $VERSION from commit $GITHUB_SHA, published by $RUN_URL" + fi + + # upload the published build to cdn.lucee.org in Maven layout, LDEV-6568. + # Cut-off rules (SNAPSHOTs stop on 2027-03-01) live in the called workflow. + s3: + needs: [build, deploy] + if: needs.build.outputs.deploy == 'true' + uses: lucee/lucee/.github/workflows/extension-s3-upload.yml@7.1 + with: + artifact-name: osgi-s3 + version: ${{ needs.build.outputs.version }} + secrets: inherit diff --git a/.gitignore b/.gitignore index eaa8331..ab604b4 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ temp /test-output /.claude .vscode/settings.json +.flattened-pom.xml diff --git a/README.md b/README.md index ff22078..5696bf6 100644 --- a/README.md +++ b/README.md @@ -16,3 +16,22 @@ mvn clean install ``` builds `target/osgi-extension-{version}.lex` (and the `.lite.lex`). + +## Versioning and releases + +Works like Lucee core (LDEV-6516) and the other extensions: every code change gets its own version number, the version is not +edited by hand. `pom.xml` uses a CI-friendly `${revision}` built from `extension.version.base` (`1.0.0`), a build number and +`extension.version.qualifier` (`-SNAPSHOT`). + +* **Every push to `main`** (a merged PR or a direct commit) takes the highest existing build of the base, from the git tags, + Maven Central, the Central snapshot repository and [maven.lucee-services.com](https://maven.lucee-services.com/), adds 1, + builds, tests, publishes that version (e.g. `1.0.0.1-SNAPSHOT`) to maven.lucee-services.com and creates the tag `1.0.0.1`. +* Pushes run one after another (workflow concurrency queue), so two quick merges get two different numbers. +* PR builds, forks and runs without the deploy secrets build and test `1.0.0.0-SNAPSHOT`, never publish and never use up a number. + Pull requests from forks have no repository variables, the tests then run with a fixed 9.0 build. +* **Pre-release or final release**: run the workflow by hand on `main` (Actions > Java CI > Run workflow), tick `deploy` and pick + `ALPHA`, `BETA`, `RC` or `release` as qualifier. That publishes the current code once with the next build number, without a commit. + * `ALPHA`, `BETA`, `RC` and `SNAPSHOT` go to maven.lucee-services.com only, never to Maven Central. `ALPHA`, `BETA` and `RC` + also get a GitHub pre-release with the `.lex` files. + * `release` (no qualifier) is the final: Maven Central, maven.lucee-services.com and a GitHub release. +* To start a new line change `extension.version.base`. diff --git a/pom.xml b/pom.xml index 05524d7..3ff46fa 100644 --- a/pom.xml +++ b/pom.xml @@ -4,11 +4,21 @@ 4.0.0 org.lucee osgi-extension - 1.0.0.0-ALPHA + ${revision} pom OSGi Extension + + 1.0.0 + 0 + -SNAPSHOT + ${extension.version.base}.${extension.version.build}${extension.version.qualifier} + install UTF-8 21 21 @@ -109,6 +119,33 @@ + + org.codehaus.mojo + flatten-maven-plugin + 1.6.0 + + bom + + true + + + + flatten + process-resources + + flatten + + + + flatten.clean + clean + + clean + + + + + org.apache.maven.plugins maven-antrun-plugin @@ -141,6 +178,17 @@ + + + + + + + + + + + true diff --git a/source/java/pom.xml b/source/java/pom.xml index 2fc2947..43eef94 100644 --- a/source/java/pom.xml +++ b/source/java/pom.xml @@ -31,6 +31,9 @@ + + 1.0.0.0-SNAPSHOT 9.0.0.1487-ALPHA From b50b2642932909d25f70277ab8be04a4e98dc014 Mon Sep 17 00:00:00 2001 From: Gian Tschingt Date: Tue, 17 Nov 2026 11:11:07 +0100 Subject: [PATCH 2/2] Address review comments on the release workflow - pass GPG_PASSPHRASE and MAVEN_USERNAME through env and test them with [ -z ], so a secret value never becomes shell syntax - runs that publish share the osgi-extension-deploy concurrency group - S3 and GitHub Releases publish the tested .lex from the build job; only a final is rebuilt, for the signed Maven Central deploy - one osgi-s3 artifact, uploaded and downloaded with matching action versions - parenthesize the GitHub release find --- .github/workflows/main.yml | 62 +++++++++++++++++++------------------- README.md | 7 +++-- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 873d181..3ae7deb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,8 +3,11 @@ name: Java CI # Push to main publishes a new numbered -SNAPSHOT to maven.lucee-services.com, never Maven Central. # A manual run with deploy ticked publishes the next build number with the chosen qualifier: # release (no qualifier): Maven Central and maven.lucee-services.com, plus a GitHub release -# ALPHA / BETA / RC: signed install, maven.lucee-services.com and a GitHub pre-release, never Central -# SNAPSHOT: signed install and maven.lucee-services.com, never Central +# ALPHA / BETA / RC: maven.lucee-services.com and a GitHub pre-release, never Central +# SNAPSHOT: maven.lucee-services.com, never Central +# The .lex files on maven.lucee-services.com and GitHub Releases are the ones built and tested +# in this workflow. A final also runs `mvn deploy` so Maven Central gets a signed rebuild of +# the same commit; that rebuild is not what S3 and GitHub publish. # Build numbers come from git tags, Maven Central, the Central snapshot repository, and maven.lucee-services.com. on: push: @@ -22,12 +25,11 @@ on: options: [pom, SNAPSHOT, ALPHA, BETA, RC, release] default: pom -# Run builds of the same ref one after another, so every push to main resolves its own -# revision (highest build + 1) only after the previous build has published and created its tag. -# PRs have their own ref (refs/pull/N/merge), so they are not blocked by main builds. +# Runs that publish share one group, so a manual deploy and a push to main cannot resolve +# the same build number. Other runs (PRs, manual runs without deploy) stay per-ref. # queue: max keeps up to 100 pending runs (default would keep only one and cancel older pending runs). concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ${{ ((github.event_name == 'workflow_dispatch' && inputs.deploy) || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && 'osgi-extension-deploy' || format('{0}-{1}', github.workflow, github.ref) }} cancel-in-progress: false queue: max @@ -73,6 +75,9 @@ jobs: "$RUNNER_TEMP/apache-maven-$MVN_VERSION/bin/mvn" -v - name: Resolve next revision + env: + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} run: | set -euo pipefail # Only builds that publish allocate a build number: every push to main and manual runs with deploy ticked. @@ -82,7 +87,7 @@ jobs: exit 0 fi # without deploy credentials nothing gets published, so do not consume a build number - if [ "${{ secrets.GPG_PASSPHRASE }}" == "" ] || [ "${{ secrets.MAVEN_USERNAME }}" == "" ]; then + if [ -z "$GPG_PASSPHRASE" ] || [ -z "$MAVEN_USERNAME" ]; then echo "Skipping revision bump (no GPG / Maven deploy credentials; test-only run)" exit 0 fi @@ -154,18 +159,9 @@ jobs: VERSION: ${{ steps.extract-version.outputs.VERSION }} run: mvn -B -e clean package -Dgoal=install -Drevision="$VERSION" - - name: Upload Artifact + # one artifact for test, S3 (LDEV-6568) and the GitHub release: full and lite .lex plus the flattened POM + - name: Upload artifact uses: actions/upload-artifact@v7 - with: - name: osgi-lex - path: | - target/*.lex - !target/*.lite.lex - - # everything the S3 upload needs (LDEV-6568): full and lite .lex plus the flattened POM - - name: Upload artifact for S3 - if: steps.extract-version.outputs.DEPLOY == 'true' - uses: actions/upload-artifact@v4 with: name: osgi-s3 include-hidden-files: true @@ -200,8 +196,10 @@ jobs: - name: Download extension artifact uses: actions/download-artifact@v8 with: - name: osgi-lex - path: target + name: osgi-s3 + # the test runner installs every .lex in extensionDir; keep only the full one + - name: Keep the full lex for the tests + run: rm -f target/*.lite.lex - name: Checkout Lucee uses: actions/checkout@v6 @@ -243,7 +241,10 @@ jobs: steps: - uses: actions/checkout@v6 + # SNAPSHOT, ALPHA, BETA and RC publish the tested .lex from the build job (S3 and GitHub). + # Only a final is rebuilt here, so Maven Central can get a signed deploy of the same commit. - name: Set up JDK 21 + if: ${{ !contains(needs.build.outputs.version, '-') }} uses: actions/setup-java@v5 with: distribution: 'temurin' @@ -252,6 +253,7 @@ jobs: # ubuntu-latest moved to Maven 3.10.0 (runner image 20261004). With it, central-publishing-maven-plugin # leaves maven-metadata-local.xml in the staging dir, which Central rejects. Pin Maven 3.9.x like Lucee core. - name: Set up Maven 3.9.16 + if: ${{ !contains(needs.build.outputs.version, '-') }} run: | MVN_VERSION=3.9.16 MVN_SHA512=831a8591fe20c8243b1dbe7d71e3244f31d1665b0804b2e825e38cbbe5ce0cafb8338851f90780735568773e0a6cd07bbec107cda0b896b008b861075358b6f6 @@ -262,6 +264,7 @@ jobs: "$RUNNER_TEMP/apache-maven-$MVN_VERSION/bin/mvn" -v - name: Cache Maven packages + if: ${{ !contains(needs.build.outputs.version, '-') }} uses: actions/cache@v5 with: path: ~/.m2/repository @@ -269,12 +272,14 @@ jobs: restore-keys: maven- - name: Import GPG key + if: ${{ !contains(needs.build.outputs.version, '-') }} run: | echo "$GPG_PRIVATE_KEY" | base64 --decode | gpg --batch --import env: GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - - name: Build and Deploy with Maven + - name: Deploy final to Maven Central + if: ${{ !contains(needs.build.outputs.version, '-') }} env: VERSION: ${{ needs.build.outputs.version }} MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} @@ -284,15 +289,10 @@ jobs: set -euo pipefail # Only a final release (no qualifier) is deployed to Maven Central, using the same ossrh server # id, MAVEN_USERNAME / MAVEN_PASSWORD secrets and maven-settings.xml as the other extensions. - # ALPHA, BETA, RC and SNAPSHOT are signed with mvn install and published to maven.lucee-services.com - # by the s3 job (same shared extension-s3-upload.yml as MongoDB, HSQLDB and Image). Never Central. - if [[ "$VERSION" == *-SNAPSHOT ]] || [[ "$VERSION" =~ -(RC|BETA|ALPHA)$ ]]; then - echo "------- Maven Install (signed) $VERSION, Lucee Maven repository (maven.lucee-services.com), never Central -------"; - mvn -B -e clean install -Dgoal=install -DperformRelease=true -Drevision="$VERSION" --settings maven-settings.xml - else - echo "------- Maven Deploy release $VERSION to Maven Central -------"; - mvn -B -e clean deploy -Dgoal=deploy -DperformRelease=true -Drevision="$VERSION" --settings maven-settings.xml - fi + # This is a signed rebuild of the same commit; S3 and GitHub Releases keep the tested .lex + # from the build job. ALPHA, BETA, RC and SNAPSHOT are not rebuilt and never go to Central. + echo "------- Maven Deploy release $VERSION to Maven Central (signed rebuild of the tested commit) -------" + mvn -B -e clean deploy -Dgoal=deploy -DperformRelease=true -Drevision="$VERSION" --settings maven-settings.xml - name: Tag published revision if: success() && needs.build.outputs.tag != '' @@ -342,7 +342,7 @@ jobs: RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} run: | set -euo pipefail - mapfile -t FILES < <(find release-files -type f -name "*-${VERSION}.lex" -o -type f -name "*-${VERSION}.lite.lex" | sort) + mapfile -t FILES < <(find release-files -type f \( -name "*-${VERSION}.lex" -o -name "*-${VERSION}.lite.lex" \) | sort) if [ "${#FILES[@]}" -eq 0 ]; then echo "::error::no .lex files for $VERSION found"; find release-files -type f; exit 1 fi diff --git a/README.md b/README.md index 5696bf6..385ec11 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,13 @@ edited by hand. `pom.xml` uses a CI-friendly `${revision}` built from `extension * **Every push to `main`** (a merged PR or a direct commit) takes the highest existing build of the base, from the git tags, Maven Central, the Central snapshot repository and [maven.lucee-services.com](https://maven.lucee-services.com/), adds 1, builds, tests, publishes that version (e.g. `1.0.0.1-SNAPSHOT`) to maven.lucee-services.com and creates the tag `1.0.0.1`. -* Pushes run one after another (workflow concurrency queue), so two quick merges get two different numbers. +* Pushes to `main` and manual deploys share one workflow concurrency group, so a manual deploy and a push cannot get the same number. * PR builds, forks and runs without the deploy secrets build and test `1.0.0.0-SNAPSHOT`, never publish and never use up a number. Pull requests from forks have no repository variables, the tests then run with a fixed 9.0 build. * **Pre-release or final release**: run the workflow by hand on `main` (Actions > Java CI > Run workflow), tick `deploy` and pick `ALPHA`, `BETA`, `RC` or `release` as qualifier. That publishes the current code once with the next build number, without a commit. * `ALPHA`, `BETA`, `RC` and `SNAPSHOT` go to maven.lucee-services.com only, never to Maven Central. `ALPHA`, `BETA` and `RC` - also get a GitHub pre-release with the `.lex` files. - * `release` (no qualifier) is the final: Maven Central, maven.lucee-services.com and a GitHub release. + also get a GitHub pre-release with the `.lex` files. The `.lex` files are the ones that were built and tested. + * `release` (no qualifier) is the final: Maven Central, maven.lucee-services.com and a GitHub release. maven.lucee-services.com + and GitHub get the tested `.lex`; Maven Central gets a signed rebuild of the same commit. * To start a new line change `extension.version.base`.