This is an automated email from the ASF dual-hosted git repository. vy pushed a commit to branch release/0.4.0 in repository https://gitbox.apache.org/repos/asf/logging-log4j-tools.git
commit 8626ac2776b9439f30b3e3598f303c047dbc6376 Author: Volkan Yazıcı <[email protected]> AuthorDate: Fri Jun 30 16:34:28 2023 +0200 Make distribution ZIP generation platform-agnostic --- .github/workflows/build.yml | 7 ++- RELEASING.adoc | 11 ++-- pom.xml | 141 +++++++++++++++++++++++++++++--------------- 3 files changed, 103 insertions(+), 56 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a1fe4c..5335ad6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -179,8 +179,11 @@ jobs: - name: Create artifacts (RELEASE) if: startsWith(github.ref, 'refs/heads/release/') run: | - export ZIP_FILEPATH="/tmp/apache-log4j-tools-${PROJECT_VERSION}-src.zip" - git ls-files -z | xargs -0 zip -9 "$ZIP_FILEPATH" -- + ./mvnw \ + --show-version --batch-mode --errors --no-transfer-progress \ + --non-recursive -P distribution + export ZIP_FILEPATH="/tmp/apache-log4j-tools-${PROJECT_VERSION}.zip" + mv "target/dist.zip" "$ZIP_FILEPATH" gpg --armor --detach-sign --yes --pinentry-mode error "$ZIP_FILEPATH" sha512sum "$ZIP_FILEPATH" > "$ZIP_FILEPATH.sha512" diff --git a/RELEASING.adoc b/RELEASING.adoc index d45adc2..329a12d 100644 --- a/RELEASING.adoc +++ b/RELEASING.adoc @@ -29,18 +29,17 @@ In the code examples below, assuming the version to be released is `7.8.0`. .. Set the `revision` property to `7.8.0` in xref:pom.xml[`pom.xml`] .. For release notes ... Run `./mvnw -N -P changelog-release` and verify `src/changelog` content (e.g., `.release-notes.md.ftl`) -... Run `./mvnw -N -P changelog-export` and verify `target/generated-sources/site/changelog` content -... Replace `RELEASE-NOTES.md` with `target/generated-sources/site/changelog/7.8.0.md` +... Run `./mvnw -N -P changelog-export` and verify `target/release-notes` content . Make sure that `./mvnw clean verify` succeeds – if not, implement necessary fixes . Commit and push the `release/7.8.0` branch . Make sure the associated https://github.com/apache/logging-log4j-tools/actions[GitHub Actions workflow] succeeds: .. *Signed artifacts* are uploaded to the _Staging Repositories_ in https://repository.apache.org/[repository.apache.org] -.. *Signed sources and their checksum* are uploaded as GitHub Actions workflow artifacts +.. *Signed distribution and its checksum* are uploaded as GitHub Actions workflow artifacts + If not, commit necessary fixes, push, and repeat. . _Close_ the repository in https://repository.apache.org/[repository.apache.org] -. Commit _the signed sources and their checksum_ (e.g., `apache-log4j-tools-7.8.0-src.{zip,.zip.asc,.zip.sha512}`) to https://dist.apache.org/repos/dist/dev/logging/log4j[dist.apache.org/repos/dist/**dev**/logging/log4j] Subversion repository and delete any artifacts from old releases +. Commit _the signed sources and their checksum_ (e.g., `apache-log4j-tools-7.8.0.{zip,.zip.asc,.zip.sha512}`) to https://dist.apache.org/repos/dist/dev/logging/log4j[dist.apache.org/repos/dist/**dev**/logging/log4j] Subversion repository and delete any artifacts from old releases == Vote the release @@ -93,7 +92,7 @@ With that, the release passes with 3 binding +1 votes from me, Piotr, and Matt. ==== The ASF infrastructure treats ``rel/``-prefixed git tags special and ensures they are immutable for provenance reasons. ==== -. If you have committed any fixes to `release/7.8.0`, `cherry-pick` them onto `master` +. Merge `release/7.8.0` to `master` . Set the revision property to the next development version (e.g., `7.9.0-SNAPSHOT`) in xref:pom.xml[`pom.xml`] . Commit changes and push the `master` branch . Delete the local and remote copies of the `release/7.8.0` branch @@ -112,4 +111,4 @@ The ASF infrastructure treats ``rel/``-prefixed git tags special and ensures the Once the artifacts are visible in https://central.sonatype.dev/[central.sonatype.dev], https://github.com/apache/logging-log4j-tools/releases/new[create a new release in GitHub] . Use the `rel/7.8.0` tag -. Copy release notes from the generated `target/generated-sources/site/changelog/7.8.0.md` +. Copy release notes from the generated `target/release-notes/7.8.0.md` diff --git a/pom.xml b/pom.xml index 5ff4dc2..4727cc0 100644 --- a/pom.xml +++ b/pom.xml @@ -128,7 +128,7 @@ <properties> <!-- project version --> - <revision>0.4.0-SNAPSHOT</revision> + <revision>0.4.0</revision> <!-- `minimalJavaBuildVersion` is employed by `org.apache:apache`, which is the parent of `org.apache.logging:logging-parent`, which is the parent of us. `minimalJavaBuildVersion` is used for enforcing the compiler version. @@ -381,8 +381,7 @@ <version>${log4j-changelog-maven-plugin.version}</version> <inherited>false</inherited> <configuration> - <!-- `outputDirectory` was broken in 0.3.0, below line can be removed in 0.4.0 onwards: --> - <outputDirectory>${project.build.directory}/generated-sources/site/release-notes</outputDirectory> + <outputDirectory>${project.build.directory}/release-notes</outputDirectory> <indexTemplates> <template> <source>.index.md.ftl</source> @@ -401,7 +400,7 @@ </profile> <!-- `changelog-release` profile to move `src/changelog/.0.x.x` contents to their associated release directory. - It is manually enabled by users to while cutting a release. + It is manually enabled by users while cutting a release. See `RELEASING.adoc` for instructions. --> <profile> <id>changelog-release</id> @@ -421,11 +420,45 @@ </build> </profile> + <!-- `distribution` profile creating the distribution ZIP containing: + 1. Git-tracked sources + 2. Generated JAR files + 3. Release notes + + This profile must be executed after a successful `package` phase, since we need JARs. + This profile is manually enabled by `.github/workflows/build.yml` while releasing. --> <profile> + <id>distribution</id> + <build> - <defaultGoal>bsh:run</defaultGoal> + + <defaultGoal>log4j-changelog:export bsh:run</defaultGoal> + <plugins> + + <!-- Generate release notes --> + <plugin> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-changelog-maven-plugin</artifactId> + <version>${log4j-changelog-maven-plugin.version}</version> + <configuration> + <outputDirectory>${project.build.directory}/generated-sources/site/release-notes</outputDirectory> + <indexTemplates> + <template> + <source>.index.md.ftl</source> + </template> + </indexTemplates> + <changelogTemplates> + <template> + <source>.release-notes.md.ftl</source> + <target>%v.md</target> + </template> + </changelogTemplates> + </configuration> + </plugin> + + <!-- Create the distribution ZIP --> <plugin> <groupId>com.github.genthaler</groupId> <artifactId>beanshell-maven-plugin</artifactId> @@ -442,7 +475,24 @@ import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.storage.file.FileRepositoryBuilder; - // Read tracked file paths + zip(String zipFileName, Map pathByFile) { + OutputStream outputStream = new FileOutputStream(zipFileName); + ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream); + try { + for (String file : pathByFile.keySet()) { + Path path = pathByFile.get(file); + ZipEntry zipEntry = new ZipEntry(file); + zipEntry.setTime(0); + zipOutputStream.putNextEntry(zipEntry); + zipOutputStream.write(Files.readAllBytes(path)); + zipOutputStream.closeEntry(); + } + } finally { + zipOutputStream.close(); + } + } + + // Find Git-tracked files SortedMap pathByFile = new TreeMap(); Repository repo = new FileRepositoryBuilder().readEnvironment().findGitDir().build(); DirCache repoCache = repo.readDirCache(); @@ -453,54 +503,46 @@ pathByFile.put(repoCacheEntryPath, new File(repoDirectoryParent, repoCacheEntryPath).toPath()); } - // Compress tracked files - OutputStream outputStream = new FileOutputStream("target/src.zip"); - ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream); + // Create `src.zip` using Git-tracked files + zip("target/src.zip", pathByFile); + System.out.format("Generated source ZIP containing %d files.%n", new Object[]{pathByFile.size()}); + + // Find auxiliary files that will go into the distribution + SortedMap pathByFile = new TreeMap(); + pathByFile.put("RELEASE-NOTES.md", new File("target/release-notes/${revision}.md").toPath()); + pathByFile.put("NOTICE.txt", new File("NOTICE.txt").toPath()); + pathByFile.put("LICENSE.txt", new File("LICENSE.txt").toPath()); + + // Find JAR files that will go into the distribution + Stream paths = Files.walk(new File(repoDirectoryParent).toPath(), 8, new FileVisitOption[0]); + int[] jarCount = {0}; try { - for (String file : pathByFile.keySet()) { - Path path = pathByFile.get(file); - ZipEntry zipEntry = new ZipEntry(file); - zipEntry.setTime(0); - zipOutputStream.putNextEntry(zipEntry); - zipOutputStream.write(Files.readAllBytes(path)); - zipOutputStream.closeEntry(); - } + paths.forEach(new Consumer() { + public void accept(Path path) { + File file = path.toFile(); + if (file.getParentFile().getName().equals("target") && + file.getName().matches("^log4j-(.+)-${revision}(-tests|-test-sources|-sources)?\\.jar$")) { + pathByFile.put(file.getName(), path); + jarCount[0]++; + } + } + }); } finally { - zipOutputStream.close(); + paths.close(); } - // Find JAR files along with the created `src.zip` - Stream stream = Files.walk(new File(repoDirectoryParent).toPath(), 8, new FileVisitOption[0]); - List paths; - try { - paths = stream - .filter(new Predicate() { - public boolean test(Path path) { - File file = path.toFile(); - return file.getParentFile().getName().equals("target") && - (file.getName().equals("src.zip") || - file.getName().matches("^log4j-.*[0-9](-SNAPSHOT)?\\.jar$")); - } - }) - .sorted() - .collect(Collectors.toList()); - } finally { - stream.close(); + // Check if no JARs are found + if (jarCount[0] == 0) { + System.err.println("Error: Could not find any JARs!"); + System.err.println("Tip: Have you already executed the Maven `package` goal?"); + System.exit(1); } - // Archive all found JAR files along with the `src.zip` - OutputStream outputStream = new FileOutputStream("target/log4j-tools-${revision}.zip"); - ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream); - try { - for (Path path : paths) { - ZipEntry zipEntry = new ZipEntry(path.toFile().getName()); - zipEntry.setTime(0); - zipOutputStream.putNextEntry(zipEntry); - zipOutputStream.write(Files.readAllBytes(path)); - zipOutputStream.closeEntry(); - } - } finally { - zipOutputStream.close(); + // Create the distribution ZIP + zip("target/dist.zip", pathByFile); + System.out.format("Generated distribution ZIP containing following %d files:%n", new Object[] {pathByFile.size()}); + for (String file : pathByFile.keySet()) { + System.out.println("-> " + file); }]]></script> </configuration> <dependencies> @@ -511,8 +553,11 @@ </dependency> </dependencies> </plugin> + </plugins> + </build> + </profile> <!-- `deploy` profile activating deployment-specific configuration.
