Skip to content

Commit

Permalink
Update release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Jan 25, 2024
1 parent c81e34d commit cf48901
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions patches/UpdateReleaseWorkflow.java
Original file line number Diff line number Diff line change
@@ -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");
});
}
});
});
}
});
});
}
}
}

0 comments on commit cf48901

Please sign in to comment.