From cf489013231c7f9b309de55d83d8b0305988db0a Mon Sep 17 00:00:00 2001 From: George Gastaldi Date: Thu, 25 Jan 2024 15:03:44 -0300 Subject: [PATCH] Update release workflow --- patches/UpdateReleaseWorkflow.java | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 patches/UpdateReleaseWorkflow.java diff --git a/patches/UpdateReleaseWorkflow.java b/patches/UpdateReleaseWorkflow.java new file mode 100755 index 0000000..9e89508 --- /dev/null +++ b/patches/UpdateReleaseWorkflow.java @@ -0,0 +1,45 @@ +///usr/bin/env jbang "$0" "$@" ; exit $? +//DEPS org.l2x6.pom-tuner:pom-tuner:4.2.0 + +import org.l2x6.pom.tuner.PomTransformer; +import org.w3c.dom.Document; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; + +public class UpdateReleaseWorkflow { + + public static void main(String... args) throws Exception { + + // Delete the maven-settings.xml.gpg file + Path path = Path.of(".github/release/maven-settings.xml.gpg"); + Files.deleteIfExists(path); + // Update the release workflow + Path releaseWorkflow = Path.of(".github/workflows/release.yml"); + if (Files.exists(releaseWorkflow)) { + // TODO: use an URL + Files.write(releaseWorkflow, Files.readAllBytes(Path.of("/Users/ggastald/workspace/quarkiverse/quarkus-jsch/.github/workflows/release.yml"))); + } + // Make sure the copy-resources phase is correct + Path docsPom = Path.of("docs/pom.xml"); + if (Files.exists(docsPom)) { + new PomTransformer(docsPom, StandardCharsets.UTF_8, PomTransformer.SimpleElementWhitespace.AUTODETECT_PREFER_EMPTY).transform((Document document, PomTransformer.TransformationContext context) -> { + context.getContainerElement("project", "build", "plugins").ifPresent((plugins) -> { + for (PomTransformer.ContainerElement plugin : plugins.childElements()) { + plugin.getChildContainerElement("artifactId").filter(f -> f.getNode().getTextContent().equals("maven-resources-plugin")).ifPresent((artifactId) -> { + // Iterate executions + plugin.getChildContainerElement("executions").ifPresent((executions) -> { + for (PomTransformer.ContainerElement execution : executions.childElements()) { + execution.getChildContainerElement("id").filter(f -> f.getNode().getTextContent().equals("copy-resources")).ifPresent((id) -> { + execution.addOrSetChildTextElement("phase", "generate-resources"); + }); + } + }); + }); + } + }); + }); + } + } +}