This is an automated email from the ASF dual-hosted git repository. luigidemasi pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-kit.git
commit c1f0bf233886abe0c2876a17614869134817a717 Author: Luigi De Masi <[email protected]> AuthorDate: Fri Dec 4 09:41:50 2026 +0100 Fix #125: Stage locally signed candidates in Apache Nexus Build and sign Maven releases from the verified source archive on the release manager's hardware. Rehearse the same scoped build without credentials and have voters compare the signed artifacts before promotion. Include the project notices in source and Javadoc attachments, keep local checkout paths out of the launcher sources, and isolate Codex discovery from background shell snapshots during verification. Co-authored-by: OpenAI Codex <[email protected]> --- .github/workflows/release.sh | 13 -- .github/workflows/release.yml | 55 +----- CHANGELOG.md | 4 +- docs/modules/ROOT/pages/contributing.adoc | 17 +- docs/releasing.md | 189 +++++++++++++++------ .../camel/kit/generator/CodexCliSmokeTest.java | 4 + kit/camel-kit-main/pom.xml | 15 +- pom.xml | 50 ++++-- tools/build_release.sh | 33 ++++ tools/release_source.sh | 2 +- tools/test_release_target.py | 64 ++++--- 11 files changed, 268 insertions(+), 178 deletions(-) diff --git a/.github/workflows/release.sh b/.github/workflows/release.sh deleted file mode 100755 index fd184842..00000000 --- a/.github/workflows/release.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Bound the reactor to the selected product; never deploy the root reactor here. -arguments=$(python3 tools/release_target.py "${RELEASE_TARGET:?}" --tag "${RELEASE_TAG:?}") -mapfile -t target_args <<< "$arguments" -profiles=sourcecheck,release -if [[ "$RELEASE_TARGET" == kit ]]; then - profiles+=,linux-ship-certification -fi -# Central validates and stages the upload. Promotion is a separate release-manager action. -exec ./mvnw -B "${target_args[@]}" -P"$profiles" -Deval.requireVectors=true \ - -DdeployAtEnd=true -Dgpg.keyname="${GPG_ID:?}" -Dgpg.passphrase= clean deploy diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 16e87c2d..971b0cd7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,10 @@ -name: Stage Maven Release +name: Verify Maven Release Candidate on: workflow_dispatch: inputs: target: - description: Product to stage independently + description: Product to verify independently required: true type: choice options: [parent, kit, knowledge] @@ -53,55 +53,18 @@ jobs: [[ "$(git for-each-ref --format='%(tag)' "$ref")" == "$RELEASE_TAG" ]] git verify-tag "$ref" python3 tools/release_target.py "$RELEASE_TARGET" --tag "$RELEASE_TAG" --check-published-parent - mkdir "$RUNNER_TEMP/candidate" - source_name="apache-${RELEASE_TAG%-rc*}-src" - tools/release_source.sh "$RELEASE_TARGET" "$RELEASE_TAG" > "$RUNNER_TEMP/candidate/$source_name.tar.gz" - tar -xzf "$RUNNER_TEMP/candidate/$source_name.tar.gz" -C "$RUNNER_TEMP" - echo "SOURCE_DIR=$RUNNER_TEMP/$source_name" >> "$GITHUB_ENV" + mkdir "$RUNNER_TEMP/source" + tools/release_source.sh "$RELEASE_TARGET" "$RELEASE_TAG" | + tar -xz --strip-components=1 -C "$RUNNER_TEMP/source" - - name: Set up JDK 21 and Maven Central settings + - name: Set up JDK 21 uses: actions/[email protected] with: java-version: '21' distribution: temurin cache: maven - server-id: central - server-username: MAVEN_USERNAME - server-password: MAVEN_PASSWORD - - name: Prepare release signing - env: - GPG_KEY: ${{ secrets.GPG_KEY }} - GPG_ID: ${{ secrets.GPG_ID }} - MAVEN_USERNAME: ${{ secrets.MVN_CENTRAL_USER }} - MAVEN_PASSWORD: ${{ secrets.MVN_CENTRAL_PASSWORD }} + - name: Rebuild the candidate without signing or publishing run: | - set -euo pipefail - : "${GPG_KEY:?Configure the GPG_KEY secret with the base64-encoded signing key}" - : "${GPG_ID:?Configure the GPG_ID signing-key secret}" - : "${MAVEN_USERNAME:?Configure the MVN_CENTRAL_USER secret}" - : "${MAVEN_PASSWORD:?Configure the MVN_CENTRAL_PASSWORD secret}" - export GNUPGHOME="$RUNNER_TEMP/camel-kit-release-gnupg" - install -d -m 700 "$GNUPGHOME" - printf '%s' "$GPG_KEY" | base64 --decode | gpg --batch --import - echo "GNUPGHOME=$GNUPGHOME" >> "$GITHUB_ENV" - - - name: Test, sign and stage release artifacts - env: - GPG_ID: ${{ secrets.GPG_ID }} - MAVEN_USERNAME: ${{ secrets.MVN_CENTRAL_USER }} - MAVEN_PASSWORD: ${{ secrets.MVN_CENTRAL_PASSWORD }} - run: | - cd "$SOURCE_DIR" - ./.github/workflows/release.sh - shopt -s globstar nullglob - bundles=(**/target/central-publishing/central-bundle.zip) - [[ ${#bundles[@]} == 1 ]] - cp "${bundles[0]}" "$RUNNER_TEMP/candidate/" - - - name: Save the source archive and Maven staging bundle for review - uses: actions/[email protected] - with: - name: ${{ inputs.tag }}-run-${{ github.run_attempt }} - path: ${{ runner.temp }}/candidate/ - if-no-files-found: error + cd "$RUNNER_TEMP/source" + tools/build_release.sh "$RELEASE_TARGET" "$RELEASE_TAG" rebuild "$(mktemp -d)" diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a337358..c010cafd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Maven releases now build from the signed RC tag’s source archive. The release manager stages the source - for a Camel PMC vote and promotes the approved source and Central deployment together (#125). +- Maven releases now build from the signed RC tag’s source archive. The release manager signs on trusted hardware + and stages the source and Apache Nexus repository for a Camel PMC vote before publication (#125). - The development Camel CLI plugin ships its skill catalog, parser providers and runtime dependencies in one JAR for JBang and Camel Launcher. Packaging rejects duplicate pack resources and verifies Mule parsing from the built JAR (#201). diff --git a/docs/modules/ROOT/pages/contributing.adoc b/docs/modules/ROOT/pages/contributing.adoc index e78a318b..d95cd6bd 100644 --- a/docs/modules/ROOT/pages/contributing.adoc +++ b/docs/modules/ROOT/pages/contributing.adoc @@ -447,14 +447,15 @@ release; never deploy the root reactor to release one product. The final tags are `camel-kit-parent-X.Y.Z`, `camel-kit-X.Y.Z` and `camel-kit-knowledge-X.Y.Z`. Append `-rc1`, `-rc2` and so on for successive signed candidate tags. -Dispatch `Stage Maven Release` from `main` with the target, RC tag and reviewed commit SHA. -It verifies the tag, builds and signs that target from its source archive, and stages the Maven artifacts in Central. - -The release manager signs the source archive, stages it with its signature and SHA-512 in -`dist/dev/camel/camel-kit/<rc-tag>/`, and calls a vote on `[email protected]`. -PMC voters verify and build the staged source. After a passing vote, the release manager copies -the approved SVN revision to `dist/release`, publishes the voted Central deployment, and creates -the final tag at the same commit. +Dispatch `Verify Maven Release Candidate` from `main` with the target, RC tag and reviewed commit SHA. +It verifies the tag and rehearses an unsigned build from the source archive. + +The release manager builds and signs the source archive and Maven artifacts on trusted hardware. +Stage the source, signature and SHA-512 in `dist/dev/camel/camel-kit/<rc-tag>/`, close the Apache +Nexus staging repository, and call a vote on `[email protected]`. Voters rebuild from the voted +source and check the staged Maven artifacts. After a passing vote, copy the approved SVN revision +to `dist/release`, release the voted Nexus repository to Maven Central, and create the final tag +at the same commit. Remove the promoted RC and retire archived releases superseded on the same branch. See the https://github.com/apache/camel-kit/blob/main/docs/releasing.md[release instructions], the https://www.apache.org/legal/release-policy.html[ASF release policy] and the Camel xref:manual::release-guide.adoc[release guide]. diff --git a/docs/releasing.md b/docs/releasing.md index 069bd604..18d4d645 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -1,13 +1,13 @@ # Independent Camel Kit releases The repository contains three Maven release targets and a separate index-data release. -Run all commands below from the repository root with `./mvnw`. +Start in the repository root. The release builds use the Maven wrapper. | Target | POM | Final tag | Scope | |---|---|---|---| | Shared parent | `pom.xml` | `camel-kit-parent-X.Y.Z` | Parent POM only (`-N`) | | Kit | `kit/pom.xml` | `camel-kit-X.Y.Z` | Kit and its modules | -| Knowledge | `knowledge/pom.xml` | `camel-kit-knowledge-X.Y.Z` | Knowledge code; excludes index data | +| Knowledge | `knowledge/pom.xml` | `camel-kit-knowledge-X.Y.Z` | Knowledge Maven artifacts; index data ships separately | | Index | `knowledge/index/src/main/resources/` | `knowledge-index-v2-YYYY.MM.DD-HHMMSS` | Validated ZIP and manifest | Versions and release schedules are independent. A product release must reference an @@ -17,7 +17,7 @@ Kit's server pin automatically. ## Prepare a Maven release -Use JDK 21 or later for every release target; the release and snapshot workflows use JDK 21. +Use Linux and a full JDK 21 for the release build and voter rebuild. The snapshot workflow also uses JDK 21. Kit release validation rejects snapshot, timestamped snapshot, and prerelease Camel CLI host pins. Set `camel.cli.version` in `distribution.properties` to a tested released Aesh-based Camel host (4.24.0 or later), synchronize the Maven mirror, and run the hosted compatibility suite before staging. @@ -88,9 +88,12 @@ a v1 directory for the released 0.0.2 runner. Lucene 10 runners accept v1 and v2 `-rcN` to the final tag. The Maven version and POM SCM tag stay final so the approved candidate can be published without rebuilding. Sign the annotated RC tag with an OpenPGP key in [Camel KEYS](https://downloads.apache.org/camel/KEYS). - For example, from the reviewed Kit release commit: + Set and export `FINGERPRINT` to the full primary-key fingerprint of the release manager's + signing key. Use `gpg --list-secret-keys --with-fingerprint` and check it against + Camel KEYS. For example, from the reviewed Kit release commit: ```bash + export FINGERPRINT="${FINGERPRINT:?set the full Camel signing key fingerprint}" target=kit final=camel-kit-0.4.2 rc="$final-rc1" @@ -109,36 +112,57 @@ archive, including the vendored graph visualization libraries for Kit and the mo tokenizer and test data for Knowledge. Correct any missing licensing material in the release commit before calling the vote. -Configure Maven staging with a Central token for the project's namespace -(`MVN_CENTRAL_USER` and `MVN_CENTRAL_PASSWORD`) and the existing Maven signing -secrets (`GPG_KEY`, base64-encoded, and `GPG_ID`). The source archive is signed -on the release manager's workstation. - -Dispatch **Stage Maven Release** from `main` with the target, RC tag and reviewed -40-character commit SHA. The workflow verifies the tag against Camel KEYS, archives -the shared build files and selected target from that commit, and builds the Maven -artifacts from the unpacked source. Central stops at `VALIDATED`. Record the -deployment ID from the build log and the successful Actions run and attempt. -Download its artifact named `<rc>-run-<attempt>`. It contains the source tarball and -the exact `central-bundle.zip` supplied to Central. Voters can inspect the bundle -using the Actions run link. - -On the release manager's workstation, set `candidate` to the absolute directory -containing the two downloaded files. From the checked-out, verified RC, compare the -source tar streams before signing the downloaded archive. Use the release manager's -full OpenPGP fingerprint from Camel KEYS. +Dispatch **Verify Maven Release Candidate** from `main` with the target, signed RC +tag and reviewed 40-character commit SHA. CI checks the tag against Camel KEYS and +rehearses the build from the extracted archive without signing or publishing. +Wait for that run to succeed before staging. +ASF automated signing requires an Infra-provisioned CI key and bit-for-bit +reproduction on trusted hardware. This workflow needs only read access to Git. + +The release manager builds and signs both the source and Maven artifacts on trusted +hardware under their control. Use a personal OpenPGP key whose private material +has stayed under the release manager's control. Run staging interactively so +the local GnuPG agent can prompt for a passphrase or hardware token. +Configure a Maven server named `apache.releases.https` in your private +`~/.m2/settings.xml` with your Apache committer (LDAP) credentials. The release profile deploys to +the ASF Nexus staging repository for `org.apache.camel`. See the +[ASF Maven publishing instructions](https://infra.apache.org/publishing-maven-artifacts.html), +[Camel release guide](https://camel.apache.org/manual/release-guide.html) and +[ASF signing guidance](https://infra.apache.org/release-signing.html#automated-release-signing). + +In a clean checkout of the signed RC on that machine, set `target`, `rc`, `final`, +`sha` and `FINGERPRINT` to the reviewed values. Verify the signed tag in a separate +keyring containing Camel KEYS and check the signer's fingerprint before building. ```bash set -euo pipefail +candidate=$(mktemp -d) +ref="refs/tags/$rc" +[[ $(git rev-parse HEAD) == "$sha" && $(git rev-parse "$ref^{commit}") == "$sha" ]] +[[ $(git for-each-ref --format='%(tag)' "$ref") == "$rc" ]] +( + export GNUPGHOME="$candidate/keys" + install -d -m 700 "$GNUPGHOME" + curl -fsSL https://downloads.apache.org/camel/KEYS | gpg --batch --import + git verify-tag --raw "$ref" 2> "$candidate/tag.status" + awk -v key="$FINGERPRINT" '$2 == "VALIDSIG" && $NF == key { found = 1 } END { exit !found }' "$candidate/tag.status" +) +python3 tools/release_target.py "$target" --tag "$rc" --check-published-parent archive="apache-$final-src.tar.gz" -tools/release_source.sh "$target" "$rc" | gzip -dc > "$candidate/from-tag.tar" -gzip -dc "$candidate/$archive" | cmp "$candidate/from-tag.tar" - +tools/release_source.sh "$target" "$rc" > "$candidate/$archive" cd "$candidate" gpg --armor --local-user "$FINGERPRINT" --detach-sign "$archive" sha512sum "$archive" > "$archive.sha512" -sha512sum central-bundle.zip +tar -xzf "$archive" +(cd "apache-$final-src" && FINGERPRINT="$FINGERPRINT" tools/build_release.sh "$target" "$rc" stage) ``` +In [Apache Nexus](https://repository.apache.org/#stagingRepositories), select the +staging repository created by this build, check that it contains only this candidate, +and **Close** it. Wait for the close checks to pass. Record its repository ID and +closed content URL for voters. If staging fails, drop the partial repository before +retrying. The **Release** action requires a passing vote. + Use the ASF distribution Subversion repository. For the first release, create `dev/camel/camel-kit` and `release/camel/camel-kit` under `https://dist.apache.org/repos/dist` with `svn mkdir` if absent. Stage the three @@ -157,34 +181,74 @@ svnmucc -m "Stage $rc" mkdir "$dev" \ Start a `[VOTE] Release Apache Camel Kit <target> <version> (RC N)` thread. Identify the target and version, signed tag and full Git SHA, source URL and SVN revision, source SHA-512, signing key fingerprint and Camel KEYS URL. -Include the Actions artifact link, Maven bundle SHA-512, Central deployment ID -and the vote deadline (normally at least 72 hours). Invite binding and -nonbinding votes. For Knowledge include the licensing review described above. - -Before casting a binding +1, each PMC voter downloads the three source files at -the stated revision, checks the digest against the vote email, verifies the -signature and fingerprint against Camel KEYS, inspects LICENSE, NOTICE and -bundled material, and builds and tests the source on their own machine. -Set `dev`, `revision`, `archive` and `final` from the vote email. Export the exact -revision into a new directory: +Include the closed Nexus repository ID and content URL, Linux and JDK versions +used to build it, the CI rehearsal link and the vote deadline (normally at least +72 hours). Invite binding and nonbinding votes. + +For Knowledge, give the actual compressed size (`wc -c < "$archive"`) and flag +the model and index licensing material for review. The current archive is about +93 MiB compressed. It includes the committed ONNX model weights and tokenizers +used by the offline runner, and Lucene segments used by the vector retrieval tests. +The index ZIP has its own release schedule and is excluded from Maven staging. +Include the Windows native-library licensing review described above. + +Before casting a binding +1, rebuild from the voted revision on your own trusted +Linux machine with the release JDK. Set `dev`, `revision`, `archive`, `final`, +`target`, `rc`, `FINGERPRINT` and `staging` (the closed repository content URL) +from the vote. Use GnuPG 2.4.1 or later for the signer check. Compare the source +SHA-512 with the vote email, confirm the signing fingerprint against Camel KEYS, +and inspect LICENSE, NOTICE and the bundled files. The rebuild runs the target's +tests, attaches its release artifacts and writes them to a new local Maven repository. ```bash +set -euo pipefail svn export -r "$revision" "$dev@$revision" verify-rc cd verify-rc -curl -fsSLo KEYS https://downloads.apache.org/camel/KEYS -gpg --import KEYS +export GNUPGHOME="$PWD/keys" +install -d -m 700 "$GNUPGHOME" +curl -fsSL https://downloads.apache.org/camel/KEYS | gpg --batch --import sha512sum -c "$archive.sha512" -gpg --verify "$archive.asc" "$archive" +gpg --assert-signer "$FINGERPRINT" --verify "$archive.asc" "$archive" tar -xzf "$archive" cd "apache-$final-src" -# Run the line for the target under vote with JDK 21: -./mvnw -B -N clean verify # parent -./mvnw -B -f kit/pom.xml -Plinux-ship-certification clean verify # Kit, on Linux -./mvnw -B -f knowledge/pom.xml -Deval.requireVectors=true clean verify # Knowledge +rebuilt=$(mktemp -d) +tools/build_release.sh "$target" "$rc" rebuild "$rebuilt" ``` -Compare the bundle digest with the vote email, inspect its Maven coordinates and -verify the artifact signatures. The release manager posts a `[RESULT][VOTE]` +Compare the closed Nexus file listing with the rebuilt coordinates and classifiers. +Check every staged POM and JAR, including sources, Javadocs and the Knowledge +runner. Inspect `META-INF/LICENSE` and `META-INF/NOTICE` in the sources and +Javadoc JARs. Verify each signature against the voted key and compare the artifact +with your rebuild: + +```bash +download=$(mktemp -d) +cd "$rebuilt" +shopt -s nullglob +files=(org/apache/camel/*/*/*.pom org/apache/camel/*/*/*.jar) +(( ${#files[@]} > 0 )) +for file in "${files[@]}"; do + mkdir -p "$download/$(dirname "$file")" + curl -fsSLo "$download/$file" "${staging%/}/$file" + curl -fsSLo "$download/$file.asc" "${staging%/}/$file.asc" + gpg --assert-signer "$FINGERPRINT" --verify "$download/$file.asc" "$download/$file" + if ! cmp "$file" "$download/$file"; then + printf '%s\n' "$file" >> "$download/differences" + fi +done +``` + +Investigate every entry in `$download/differences` with +`diffoscope "$rebuilt/$file" "$download/$file"`. The Knowledge runner uses +Quarkus build-time bytecode generation. Two builds can assign different +`proxykey` numbers to the same recorder operations, or register configuration +mappings and MCP converters in a different order. Use `javap -p -c -classpath <jar> <class>` +on each copy to inspect the operations that write and read each key. Check that +the application classes, models and dependencies match. Report what differed and why on the +vote thread. Withhold a binding +1 for any unexplained difference, missing or +extra artifact, or invalid signature. + +The release manager posts a `[RESULT][VOTE]` on the same list with the tally, distinguishing Camel PMC votes. Approval requires at least three binding +1 votes and more binding +1 than binding -1 votes. See the [ASF release policy](https://www.apache.org/legal/release-policy.html#release-approval) @@ -192,7 +256,7 @@ and the [Camel release guide](https://camel.apache.org/manual/release-guide.html ## Promote the approved candidate -After the passing result, use the SVN revision, Git SHA and Central deployment ID +After the passing result, use the SVN revision, Git SHA and closed Nexus repository ID recorded in the vote. Copy the voted source, signature and checksum in one server-side operation. The destination is a new directory named after the final tag. @@ -201,26 +265,39 @@ svnmucc -m "Release $final (approved $rc)" cp "$revision" "$dev" "$dist/release/ ``` Confirm the files and checksum on [Apache Downloads](https://downloads.apache.org/camel/). -In [Central Portal](https://central.sonatype.com/publishing/deployments), select the voted -deployment ID, choose **Publish**, and verify that it reaches `PUBLISHED`. From the Git -checkout, create and push the signed final tag at the approved SHA. If promotion is -interrupted, inspect the destination, deployment ID and tag and resume the missing steps -with the same artifacts. +In Apache Nexus, select the voted repository ID, choose **Release**, and verify that +its artifacts sync to Maven Central. From the Git checkout, create and push the +signed final tag at the approved SHA. If promotion is interrupted, inspect the +destination, Nexus repository and tag and resume with the same artifacts. ```bash git -c gpg.format=openpgp tag -s -u "$FINGERPRINT" -m "$final" "$final" "$sha" git push origin "refs/tags/$final" ``` -Verify clean-cache installation from the public repository. Update the download page, +Verify clean-cache installation from Maven Central. Update the download page, publish any GitHub release against the final tag and announce the release on the Camel -lists. Advance only the released target to its next snapshot, restore its SCM tag to +lists. After confirming the promoted files on Apache Downloads, remove the approved RC +from `dist/dev` at its voted revision: + +```bash +svnmucc -r "$revision" -m "Remove promoted $rc" rm "$dev" +``` + +Keep the latest release of each active branch for each target in `dist/release`. +Set `previous` to the superseded final tag on the same branch. Verify its archive, signature +and checksum are available under +`https://archive.apache.org/dist/camel/camel-kit/<previous-final-tag>/`, then +remove that specific directory with +`svn delete -m "Retire $previous" "$dist/release/camel/camel-kit/$previous"`. +Other targets and active branches have independent versions. See the [ASF distribution policy](https://infra.apache.org/release-distribution.html#archival). + +Advance only the released target to its next snapshot, restore its SCM tag to `HEAD`, and synchronize Kit's launcher versions when releasing Kit. -If the vote fails or the candidate changes, announce the outcome, drop its Central -deployment and remove the abandoned directory from `dist/dev`. Preserve the old tag. -Prepare a new signed RC with the next number, stage it and start a fresh vote. A -rerun that produces a different bundle also requires a fresh candidate and vote. +If the vote fails or the candidate changes, announce the outcome, **Drop** its Nexus +staging repository and remove the abandoned directory from `dist/dev`. Preserve the +old tag. Prepare a new signed RC with the next number, stage it and start a fresh vote. Before the nightly and manual Kit snapshot deployments, `python3 tools/check_camel_mcp_runner.py` resolves the pinned runner with an empty Maven repository. When the pin is a snapshot and its release JAR appears on Maven diff --git a/kit/camel-kit-core/src/test/java/org/apache/camel/kit/generator/CodexCliSmokeTest.java b/kit/camel-kit-core/src/test/java/org/apache/camel/kit/generator/CodexCliSmokeTest.java index 8d6a03ae..9c145567 100644 --- a/kit/camel-kit-core/src/test/java/org/apache/camel/kit/generator/CodexCliSmokeTest.java +++ b/kit/camel-kit-core/src/test/java/org/apache/camel/kit/generator/CodexCliSmokeTest.java @@ -112,6 +112,10 @@ class CodexCliSmokeTest { Path codexHome = Files.createDirectories(home.resolve(".codex")); String trustedPath = workspace.toAbsolutePath().normalize().toString().replace("\\", "\\\\"); Files.writeString(codexHome.resolve("config.toml"), String.format(Locale.ROOT, """ + # Discovery needs no login shell. A background snapshot can outlive the isolated home. + [features] + shell_snapshot = false + [projects."%s"] trust_level = "trusted" """, trustedPath)); diff --git a/kit/camel-kit-main/pom.xml b/kit/camel-kit-main/pom.xml index 766a7991..aba92c52 100644 --- a/kit/camel-kit-main/pom.xml +++ b/kit/camel-kit-main/pom.xml @@ -31,15 +31,6 @@ </dependencies> <build> - <resources> - <resource> - <directory>src/main/jbang/main</directory> - <targetPath>${basedir}/dist</targetPath> - <includes> - <include>**/*.java</include> - </includes> - </resource> - </resources> <sourceDirectory>src/main/jbang</sourceDirectory> <plugins> @@ -47,15 +38,15 @@ <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> - <phase>prepare-package</phase> + <phase>process-resources</phase> <configuration> <target> <copy todir="${dist.dir}"> - <fileset dir="${project.build.directory}"> + <fileset dir="src/main/jbang/main"> <include name="**/*.java" /> </fileset> </copy> - <chmod file="${dist.dir}/*.java" perm="u+x" /> + <chmod dir="${dist.dir}" includes="**/*.java" perm="u+x" /> </target> </configuration> <goals> diff --git a/pom.xml b/pom.xml index d0e4cd84..efe53943 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,7 @@ <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <project.legal.outputDirectory>${project.build.outputDirectory}/META-INF</project.legal.outputDirectory> <bundle.license.path>META-INF/LICENSE</bundle.license.path> <bundle.notice.path>META-INF/NOTICE</bundle.notice.path> <jdk.version>21</jdk.version> @@ -111,10 +112,10 @@ <executions> <execution> <id>project-license-and-notice</id> - <phase>process-resources</phase> + <phase>generate-resources</phase> <goals><goal>copy-resources</goal></goals> <configuration> - <outputDirectory>${project.build.outputDirectory}/META-INF</outputDirectory> + <outputDirectory>${project.legal.outputDirectory}</outputDirectory> <resources> <resource> <directory>${maven.multiModuleProjectDirectory}</directory> @@ -340,8 +341,38 @@ </profile> <profile> <id>release</id> + <properties> + <archive.resourcesDirectory>${project.build.directory}/maven-shared-archive-resources</archive.resourcesDirectory> + <project.legal.outputDirectory>${archive.resourcesDirectory}/META-INF</project.legal.outputDirectory> + </properties> + <distributionManagement> + <repository> + <id>apache.releases.https</id> + <url>https://repository.apache.org/service/local/staging/deploy/maven2</url> + </repository> + </distributionManagement> <build> <plugins> + <!-- Both archive plugins pick up Maven's shared archive resource directory. --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>3.8.0</version> + <executions> + <execution> + <id>add-archive-resources</id> + <phase>generate-resources</phase> + <goals><goal>add-resource</goal></goals> + <configuration> + <resources> + <resource> + <directory>${archive.resourcesDirectory}</directory> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> <!-- Attach source JARs --> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -388,21 +419,6 @@ </execution> </executions> </plugin> - <!-- Central Publishing Maven Plugin --> - <plugin> - <groupId>org.sonatype.central</groupId> - <artifactId>central-publishing-maven-plugin</artifactId> - <version>0.9.0</version> - <extensions>true</extensions> - <configuration> - <publishingServerId>central</publishingServerId> - <autoPublish>false</autoPublish> - <waitUntil>validated</waitUntil> - <excludeArtifacts> - <excludeArtifact>camel-kit-knowledge-index</excludeArtifact> - </excludeArtifacts> - </configuration> - </plugin> </plugins> </build> </profile> diff --git a/tools/build_release.sh b/tools/build_release.sh new file mode 100755 index 00000000..6228ab93 --- /dev/null +++ b/tools/build_release.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# Build the selected target from the unpacked candidate on Linux with JDK 21. +set -euo pipefail + +target=${1:?expected parent, kit or knowledge} +tag=${2:?expected candidate tag} +arguments=$(python3 tools/release_target.py "$target" --tag "$tag") +mapfile -t target_args <<< "$arguments" +profiles=sourcecheck,release +if [[ "$target" == kit ]]; then + profiles+=,linux-ship-certification +fi + +case "${3:-}" in + stage) + options=("-Dgpg.keyname=${FINGERPRINT:?set your full OpenPGP fingerprint}") + ;; + rebuild) + repository=$(cd "${4:?expected an empty directory for the rebuilt artifacts}" && pwd -P) + options=(-B -Dgpg.skip=true "-DaltReleaseDeploymentRepository=rebuild::file://$repository") + ;; + *) + echo "Usage: $0 TARGET RC {stage|rebuild DIRECTORY}" >&2 + exit 2 + ;; +esac +# ZIP tools encode local time and Javadoc uses the default locale. +export TZ=UTC LC_ALL=C.UTF-8 +# git archive gives every source file the candidate commit timestamp. +timestamp=$(date -u -r pom.xml +%FT%TZ) +exec ./mvnw "${target_args[@]}" -P"$profiles" -Deval.requireVectors=true \ + -Dproject.build.outputTimestamp="$timestamp" -Dquarkus.package.output-timestamp="$timestamp" \ + -DdeployAtEnd=true "${options[@]}" clean deploy diff --git a/tools/release_source.sh b/tools/release_source.sh index 8f349ce0..8226cfe9 100755 --- a/tools/release_source.sh +++ b/tools/release_source.sh @@ -12,7 +12,7 @@ if [[ "$(git rev-parse HEAD)" != "$commit" ]]; then fi # Include shared build inputs and the data used by the selected product's tests. -paths=(LICENSE NOTICE README.md CONTRIBUTING.md CHANGELOG.md docs tools .github/workflows/release.sh .mvn mvnw mvnw.cmd +paths=(LICENSE NOTICE README.md CONTRIBUTING.md CHANGELOG.md docs tools .mvn mvnw mvnw.cmd pom.xml camel-kit-formatter-config.xml distribution.properties) if [[ "$target" != parent ]]; then paths+=("$target") diff --git a/tools/test_release_target.py b/tools/test_release_target.py index 5bc60d17..569352d4 100644 --- a/tools/test_release_target.py +++ b/tools/test_release_target.py @@ -11,6 +11,9 @@ from pathlib import Path from release_target import validate +REPOSITORY = Path(__file__).resolve().parents[1] + + class ReleaseTargetTest(unittest.TestCase): def setUp(self): self.tmp = tempfile.TemporaryDirectory() @@ -113,12 +116,11 @@ class ReleaseTargetTest(unittest.TestCase): validate(self.root, "kit", "camel-kit-0.4.2-rc1") def test_source_archive_contains_the_selected_product_at_the_tag(self): - repository = Path(__file__).resolve().parent.parent for path in ("LICENSE", "NOTICE", "README.md", "CONTRIBUTING.md", "CHANGELOG.md", "docs/releasing.md", ".mvn/wrapper/maven-wrapper.properties", "mvnw", "mvnw.cmd", "camel-kit-formatter-config.xml", - ".github/workflows/release.sh", "tools/release_target.py", "tools/sync_distribution_mirrors.py"): + "tools/build_release.sh", "tools/release_target.py", "tools/sync_distribution_mirrors.py"): (self.root / path).parent.mkdir(parents=True, exist_ok=True) - shutil.copy(repository / path, self.root / path) + shutil.copy(REPOSITORY / path, self.root / path) (self.root / "jbang-catalog.json").write_text("{}") self.pom("knowledge/pom.xml", "camel-kit-knowledge", "0.0.3", "camel-kit-parent", "1.0.0", ["mcp"]) self.pom("knowledge/mcp/pom.xml", "camel-kit-knowledge-mcp", None, "camel-kit-knowledge", "0.0.3") @@ -137,11 +139,11 @@ class ReleaseTargetTest(unittest.TestCase): tag = final_tag + "-rc1" git("tag", tag) (self.root / "NOTICE").write_text("uncommitted change") - result = subprocess.check_output([repository / "tools/release_source.sh", target, tag], cwd=self.root) + result = subprocess.check_output([REPOSITORY / "tools/release_source.sh", target, tag], cwd=self.root) prefix = "apache-" + final_tag + "-src/" with tarfile.open(fileobj=io.BytesIO(result), mode="r:gz") as archive: names = archive.getnames() - self.assertEqual((repository / "NOTICE").read_bytes(), archive.extractfile(prefix + "NOTICE").read()) + self.assertEqual((REPOSITORY / "NOTICE").read_bytes(), archive.extractfile(prefix + "NOTICE").read()) self.assertIn(prefix + "LICENSE", names) self.assertTrue(archive.getmember(prefix + "mvnw").mode & 0o100) self.assertEqual(target == "kit", prefix + "kit/core/pom.xml" in names) @@ -149,42 +151,58 @@ class ReleaseTargetTest(unittest.TestCase): self.assertEqual(target == "kit", prefix + "jbang-catalog.json" in names) git("add", "NOTICE") git("commit", "-m", "Move HEAD beyond candidate") - result = subprocess.run([repository / "tools/release_source.sh", "kit", "camel-kit-0.4.2-rc1"], + result = subprocess.run([REPOSITORY / "tools/release_source.sh", "kit", "camel-kit-0.4.2-rc1"], cwd=self.root, capture_output=True) self.assertNotEqual(0, result.returncode) self.assertEqual(b"", result.stdout) - def test_central_release_stops_at_validation(self): - pom = ET.parse(Path(__file__).resolve().parents[1] / "pom.xml") + def test_release_deploys_to_apache_staging(self): + pom = ET.parse(REPOSITORY / "pom.xml") release = pom.find(".//{*}profile[{*}id='release']") - plugin = release.find(".//{*}plugin[{*}artifactId='central-publishing-maven-plugin']/{*}configuration") - self.assertEqual("false", plugin.findtext("{*}autoPublish")) - self.assertEqual("validated", plugin.findtext("{*}waitUntil")) + repository = release.find("{*}distributionManagement/{*}repository") + self.assertEqual("apache.releases.https", repository.findtext("{*}id")) + self.assertEqual("https://repository.apache.org/service/local/staging/deploy/maven2", + repository.findtext("{*}url")) + self.assertIsNone(pom.find(".//{*}plugin[{*}artifactId='central-publishing-maven-plugin']")) def test_release_script_invokes_only_the_selected_reactor(self): - repository = Path(__file__).resolve().parent.parent (self.root / "tools").mkdir() - shutil.copy(repository / "tools/release_target.py", self.root / "tools/release_target.py") - shutil.copy(repository / "tools/sync_distribution_mirrors.py", self.root / "tools/sync_distribution_mirrors.py") + shutil.copy(REPOSITORY / "tools/release_target.py", self.root / "tools/release_target.py") + shutil.copy(REPOSITORY / "tools/sync_distribution_mirrors.py", self.root / "tools/sync_distribution_mirrors.py") wrapper = self.root / "mvnw" wrapper.write_text('#!/usr/bin/env bash\nprintf "%s\\n" "$@"\n') wrapper.chmod(0o755) self.pom("knowledge/pom.xml", "camel-kit-knowledge", "0.0.3", "camel-kit-parent", "1.0.0", ["mcp"]) self.pom("knowledge/mcp/pom.xml", "camel-kit-knowledge-mcp", None, "camel-kit-knowledge", "0.0.3") + os.utime(self.root / "pom.xml", (946684800, 946684800)) + rebuilt = self.root / "rebuilt" + rebuilt.mkdir() for target, tag, scope in [ ("parent", "camel-kit-parent-1.0.0-rc1", ["-N"]), ("kit", "camel-kit-0.4.2-rc1", ["-f", "kit/pom.xml"]), ("knowledge", "camel-kit-knowledge-0.0.3-rc1", ["-f", "knowledge/pom.xml"]), ]: - with self.subTest(target=target): - result = subprocess.run(["bash", str(repository / ".github/workflows/release.sh")], - cwd=self.root, capture_output=True, text=True, check=True, - env={**os.environ, "RELEASE_TARGET": target, "RELEASE_TAG": tag, - "GPG_ID": "test-key"}) - arguments = result.stdout.splitlines() - self.assertEqual(scope, arguments[1:1 + len(scope)]) - self.assertNotIn("-am", arguments) - self.assertEqual(["clean", "deploy"], arguments[-2:]) + for mode in ("stage", "rebuild"): + with self.subTest(target=target, mode=mode): + cmd = [REPOSITORY / "tools/build_release.sh", target, tag, mode] + if mode == "rebuild": + cmd.append(rebuilt) + result = subprocess.run(cmd, cwd=self.root, capture_output=True, text=True, check=True, + env={**os.environ, "FINGERPRINT": "test-key"}) + arguments = result.stdout.splitlines() + self.assertEqual(scope, arguments[:len(scope)]) + self.assertEqual(mode == "rebuild", "-B" in arguments) + self.assertNotIn("-am", arguments) + profiles = "-Psourcecheck,release" + (",linux-ship-certification" if target == "kit" else "") + self.assertIn(profiles, arguments) + self.assertIn("-Deval.requireVectors=true", arguments) + self.assertIn("-Dproject.build.outputTimestamp=2000-01-01T00:00:00Z", arguments) + self.assertIn("-Dquarkus.package.output-timestamp=2000-01-01T00:00:00Z", arguments) + self.assertEqual(mode == "stage", "-Dgpg.keyname=test-key" in arguments) + self.assertEqual(mode == "rebuild", "-Dgpg.skip=true" in arguments) + self.assertEqual(mode == "rebuild", + f"-DaltReleaseDeploymentRepository=rebuild::file://{rebuilt}" in arguments) + self.assertEqual(["clean", "deploy"], arguments[-2:]) if __name__ == "__main__":
