diff --git a/action.docker.yml b/action.docker.yml deleted file mode 100644 index ff1f8db..0000000 --- a/action.docker.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: 'Conversational release action' -description: 'Release Quarkus by conversing with a GitHub Action' -inputs: - github-token: - description: 'GitHub token' - required: false -runs: - using: 'docker' - image: 'docker://ghcr.io/quarkusio/conversational-release-action:main' \ No newline at end of file diff --git a/src/main/docker/Dockerfile.jvm b/src/main/docker/Dockerfile.jvm deleted file mode 100644 index 9cacdb0..0000000 --- a/src/main/docker/Dockerfile.jvm +++ /dev/null @@ -1,98 +0,0 @@ -#### -# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode -# -# Before building the container image run: -# -# ./mvnw package -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/conversational-release-action-jvm . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/conversational-release-action-jvm -# -# If you want to include the debug port into your docker image -# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005. -# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005 -# when running the container -# -# Then run the container using : -# -# docker run -i --rm -p 8080:8080 quarkus/conversational-release-action-jvm -# -# This image uses the `run-java.sh` script to run the application. -# This scripts computes the command line to execute your Java application, and -# includes memory/GC tuning. -# You can configure the behavior using the following environment properties: -# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") -# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options -# in JAVA_OPTS (example: "-Dsome.property=foo") -# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is -# used to calculate a default maximal heap memory based on a containers restriction. -# If used in a container without any memory constraints for the container then this -# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio -# of the container available memory as set here. The default is `50` which means 50% -# of the available memory is used as an upper boundary. You can skip this mechanism by -# setting this value to `0` in which case no `-Xmx` option is added. -# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This -# is used to calculate a default initial heap memory based on the maximum heap memory. -# If used in a container without any memory constraints for the container then this -# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio -# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` -# is used as the initial heap size. You can skip this mechanism by setting this value -# to `0` in which case no `-Xms` option is added (example: "25") -# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. -# This is used to calculate the maximum value of the initial heap memory. If used in -# a container without any memory constraints for the container then this option has -# no effect. If there is a memory constraint then `-Xms` is limited to the value set -# here. The default is 4096MB which means the calculated value of `-Xms` never will -# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") -# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output -# when things are happening. This option, if set to true, will set -# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). -# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: -# true"). -# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). -# - CONTAINER_CORE_LIMIT: A calculated core limit as described in -# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") -# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). -# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. -# (example: "20") -# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. -# (example: "40") -# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. -# (example: "4") -# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus -# previous GC times. (example: "90") -# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") -# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") -# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should -# contain the necessary JRE command-line options to specify the required GC, which -# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). -# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") -# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") -# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be -# accessed directly. (example: "foo.example.com,bar.example.com") -# -### -FROM registry.access.redhat.com/ubi8/openjdk-11:1.17 - -ENV LANGUAGE='en_US:en' - - -# We make four distinct layers so if there are application changes the library layers can be re-used -COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/ -COPY --chown=185 target/quarkus-app/*.jar /deployments/ -COPY --chown=185 target/quarkus-app/app/ /deployments/app/ -COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/ - -EXPOSE 8080 -USER 185 -ENV AB_JOLOKIA_OFF="" -ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" -ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" - -ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] - diff --git a/src/main/docker/Dockerfile.legacy-jar b/src/main/docker/Dockerfile.legacy-jar deleted file mode 100644 index c6f052b..0000000 --- a/src/main/docker/Dockerfile.legacy-jar +++ /dev/null @@ -1,94 +0,0 @@ -#### -# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode -# -# Before building the container image run: -# -# ./mvnw package -Dquarkus.package.type=legacy-jar -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/conversational-release-action-legacy-jar . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/conversational-release-action-legacy-jar -# -# If you want to include the debug port into your docker image -# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005. -# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005 -# when running the container -# -# Then run the container using : -# -# docker run -i --rm -p 8080:8080 quarkus/conversational-release-action-legacy-jar -# -# This image uses the `run-java.sh` script to run the application. -# This scripts computes the command line to execute your Java application, and -# includes memory/GC tuning. -# You can configure the behavior using the following environment properties: -# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") -# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options -# in JAVA_OPTS (example: "-Dsome.property=foo") -# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is -# used to calculate a default maximal heap memory based on a containers restriction. -# If used in a container without any memory constraints for the container then this -# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio -# of the container available memory as set here. The default is `50` which means 50% -# of the available memory is used as an upper boundary. You can skip this mechanism by -# setting this value to `0` in which case no `-Xmx` option is added. -# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This -# is used to calculate a default initial heap memory based on the maximum heap memory. -# If used in a container without any memory constraints for the container then this -# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio -# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` -# is used as the initial heap size. You can skip this mechanism by setting this value -# to `0` in which case no `-Xms` option is added (example: "25") -# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. -# This is used to calculate the maximum value of the initial heap memory. If used in -# a container without any memory constraints for the container then this option has -# no effect. If there is a memory constraint then `-Xms` is limited to the value set -# here. The default is 4096MB which means the calculated value of `-Xms` never will -# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") -# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output -# when things are happening. This option, if set to true, will set -# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). -# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: -# true"). -# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). -# - CONTAINER_CORE_LIMIT: A calculated core limit as described in -# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") -# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). -# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. -# (example: "20") -# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. -# (example: "40") -# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. -# (example: "4") -# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus -# previous GC times. (example: "90") -# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") -# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") -# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should -# contain the necessary JRE command-line options to specify the required GC, which -# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). -# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") -# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") -# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be -# accessed directly. (example: "foo.example.com,bar.example.com") -# -### -FROM registry.access.redhat.com/ubi8/openjdk-11:1.17 - -ENV LANGUAGE='en_US:en' - - -COPY target/lib/* /deployments/lib/ -COPY target/*-runner.jar /deployments/quarkus-run.jar - -EXPOSE 8080 -USER 185 -ENV AB_JOLOKIA_OFF="" -ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" -ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" - -ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] diff --git a/src/main/docker/Dockerfile.native b/src/main/docker/Dockerfile.native deleted file mode 100644 index c1aab6a..0000000 --- a/src/main/docker/Dockerfile.native +++ /dev/null @@ -1,27 +0,0 @@ -#### -# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. -# -# Before building the container image run: -# -# ./mvnw package -Dnative -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.native -t quarkus/conversational-release-action . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/conversational-release-action -# -### -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8 -WORKDIR /work/ -RUN chown 1001 /work \ - && chmod "g+rwX" /work \ - && chown 1001:root /work -COPY --chown=1001:root target/*-runner /work/application - -EXPOSE 8080 -USER 1001 - -ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/src/main/docker/Dockerfile.native-micro b/src/main/docker/Dockerfile.native-micro deleted file mode 100644 index 0f02b8c..0000000 --- a/src/main/docker/Dockerfile.native-micro +++ /dev/null @@ -1,30 +0,0 @@ -#### -# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. -# It uses a micro base image, tuned for Quarkus native executables. -# It reduces the size of the resulting container image. -# Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image. -# -# Before building the container image run: -# -# ./mvnw package -Dnative -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/conversational-release-action . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/conversational-release-action -# -### -FROM quay.io/quarkus/quarkus-micro-image:2.0 -WORKDIR /work/ -RUN chown 1001 /work \ - && chmod "g+rwX" /work \ - && chown 1001:root /work -COPY --chown=1001:root target/*-runner /work/application - -EXPOSE 8080 -USER 1001 - -ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/src/main/java/io/quarkus/bot/release/ReleaseAction.java b/src/main/java/io/quarkus/bot/release/ReleaseAction.java index 37ae4fd..bd902b8 100644 --- a/src/main/java/io/quarkus/bot/release/ReleaseAction.java +++ b/src/main/java/io/quarkus/bot/release/ReleaseAction.java @@ -158,7 +158,7 @@ private void handleSteps(Context context, Commands commands, GHIssue issue, Upda // Handle paused, we will continue the process with the next step StepHandler stepHandler = getStepHandler(currentReleaseStatus.getCurrentStep()); - if (stepHandler.shouldContinue(releaseInformation, currentReleaseStatus, issueComment)) { + if (stepHandler.shouldContinue(context, commands, releaseInformation, currentReleaseStatus, issueComment)) { react(commands, issueComment, ReactionContent.PLUS_ONE); currentReleaseStatus = currentReleaseStatus.progress(StepStatus.COMPLETED); updateReleaseStatus(issue, updatedIssueBody, currentReleaseStatus); @@ -182,6 +182,8 @@ private void handleSteps(Context context, Commands commands, GHIssue issue, Upda progressInformation(context, commands, releaseInformation, currentReleaseStatus, issue, "Proceeding to step " + currentReleaseStatus.getCurrentStep().getDescription()); + StepHandler currentStepHandler; + for (Step currentStep : Step.values()) { if (currentStep.ordinal() < currentReleaseStatus.getCurrentStep().ordinal()) { // we already handled this step, skipping to next one @@ -194,19 +196,20 @@ private void handleSteps(Context context, Commands commands, GHIssue issue, Upda commands.notice("Running step " + currentStep.getDescription()); + currentStepHandler = getStepHandler(currentStep); + try { - StepHandler stepHandler = getStepHandler(currentStep); currentReleaseStatus = currentReleaseStatus.progress(currentStep); updateReleaseStatus(issue, updatedIssueBody, currentReleaseStatus); - if (stepHandler.shouldPause(releaseInformation, releaseStatus)) { + if (currentStepHandler.shouldPause(context, commands, releaseInformation, releaseStatus)) { currentReleaseStatus = currentReleaseStatus.progress(StepStatus.PAUSED); updateReleaseStatus(issue, updatedIssueBody, currentReleaseStatus); return; } - int exitCode = stepHandler.run(context, commands, releaseInformation, issue, updatedIssueBody); + int exitCode = currentStepHandler.run(context, commands, releaseInformation, issue, updatedIssueBody); handleExitCode(exitCode, currentStep); currentReleaseStatus = currentReleaseStatus.progress(StepStatus.COMPLETED); @@ -218,11 +221,11 @@ private void handleSteps(Context context, Commands commands, GHIssue issue, Upda } catch (Exception e) { if (currentStep.isRecoverable()) { progressError(context, commands, releaseInformation, currentReleaseStatus, issue, updatedIssueBody, - e.getMessage()); + e.getMessage(), currentStepHandler.getErrorHelp()); throw e; } else { fatalError(context, commands, releaseInformation, currentReleaseStatus, issue, updatedIssueBody, - e.getMessage()); + e.getMessage(), currentStepHandler.getErrorHelp()); throw e; } } @@ -289,11 +292,13 @@ private static void progressInformation(Context context, Commands commands, Rele } private void progressError(Context context, Commands commands, ReleaseInformation releaseInformation, - ReleaseStatus releaseStatus, GHIssue issue, UpdatedIssueBody updatedIssueBody, String error) { + ReleaseStatus releaseStatus, GHIssue issue, UpdatedIssueBody updatedIssueBody, String error, + String errorHelp) { try { ReleaseStatus currentReleaseStatus = releaseStatus.progress(StepStatus.FAILED); issue.setBody(issues.appendReleaseStatus(updatedIssueBody, currentReleaseStatus)); commands.setOutput(Outputs.INTERACTION_COMMENT, ":rotating_light: " + error + + (errorHelp != null && !errorHelp.isBlank() ? "\n\n" + errorHelp : "") + "\n\nYou can find more information about the failure [here](" + getWorkflowRunUrl(context) + ").\n\n" + "This is not a fatal error, you can retry by adding a `" + Command.RETRY.getFullCommand() + "` comment." + youAreHere(releaseInformation, currentReleaseStatus)); @@ -304,10 +309,17 @@ private void progressError(Context context, Commands commands, ReleaseInformatio private void fatalError(Context context, Commands commands, ReleaseInformation releaseInformation, ReleaseStatus releaseStatus, GHIssue issue, UpdatedIssueBody updatedIssueBody, String error) { + fatalError(context, commands, releaseInformation, releaseStatus, issue, updatedIssueBody, error, null); + } + + private void fatalError(Context context, Commands commands, ReleaseInformation releaseInformation, + ReleaseStatus releaseStatus, GHIssue issue, UpdatedIssueBody updatedIssueBody, String error, String errorHelp) { try { ReleaseStatus currentReleaseStatus = releaseStatus.progress(Status.FAILED, StepStatus.FAILED); issue.setBody(issues.appendReleaseStatus(updatedIssueBody, currentReleaseStatus)); - issue.comment(":rotating_light: " + error + "\n\nYou can find more information about the failure [here](" + issue.comment(":rotating_light: " + error + + (errorHelp != null && !errorHelp.isBlank() ? "\n\n" + errorHelp : "") + + "\n\nYou can find more information about the failure [here](" + getWorkflowRunUrl(context) + ").\n\n" + "This is a fatal error, the issue will be closed." + youAreHere(releaseInformation, currentReleaseStatus)); @@ -322,7 +334,7 @@ private static String getWorkflowRunUrl(Context context) { } private static String youAreHere(ReleaseInformation releaseInformation, ReleaseStatus releaseStatus) { - return "\n\n
You are here\n\n" + + return "\n\n
Where am I?\n\n" + Arrays.stream(Step.values()) .filter(s -> releaseInformation.isFinal() || !s.isForFinalReleasesOnly()) .map(s -> { diff --git a/src/main/java/io/quarkus/bot/release/step/ApproveCoreRelease.java b/src/main/java/io/quarkus/bot/release/step/ApproveCoreRelease.java index 7daa032..c0d31da 100644 --- a/src/main/java/io/quarkus/bot/release/step/ApproveCoreRelease.java +++ b/src/main/java/io/quarkus/bot/release/step/ApproveCoreRelease.java @@ -1,6 +1,8 @@ package io.quarkus.bot.release.step; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import jakarta.inject.Singleton; @@ -13,6 +15,7 @@ import io.quarkus.bot.release.ReleaseInformation; import io.quarkus.bot.release.ReleaseStatus; import io.quarkus.bot.release.util.Command; +import io.quarkus.bot.release.util.Outputs; import io.quarkus.bot.release.util.UpdatedIssueBody; @Singleton @@ -20,13 +23,26 @@ public class ApproveCoreRelease implements StepHandler { @Override - public boolean shouldPause(ReleaseInformation releaseInformation, ReleaseStatus releaseStatus) { + public boolean shouldPause(Context context, Commands commands, ReleaseInformation releaseInformation, ReleaseStatus releaseStatus) { + StringBuilder comment = new StringBuilder(); + comment.append("We are going to release the following release:\n\n"); + comment.append("- `").append(releaseInformation.getVersion()).append("`\n"); + if (Files.exists(Path.of("work", "maintenance"))) { + comment.append("- This is a `maintenance` release.\n"); + } + if (Files.exists(Path.of("work", "preview"))) { + comment.append("- This is a preview release (e.g. `Alpha`, `Beta`, `CR`).\n"); + } + comment.append( + "\nPlease approve with a `" + Command.YES.getFullCommand() + "` comment if you want to pursue with the release.\n"); + comment.append("\nIf not, simply close this issue."); + commands.setOutput(Outputs.INTERACTION_COMMENT, comment.toString()); return true; } @Override - public boolean shouldContinue(ReleaseInformation releaseInformation, ReleaseStatus releaseStatus, - GHIssueComment issueComment) { + public boolean shouldContinue(Context context, Commands commands, + ReleaseInformation releaseInformation, ReleaseStatus releaseStatus, GHIssueComment issueComment) { return Command.YES.matches(issueComment.getBody()); } @@ -36,4 +52,11 @@ public int run(Context context, Commands commands, ReleaseInformation releaseInf issue.comment(":white_check_mark: Core release is approved, proceeding..."); return 0; } + + @Override + public String getErrorHelp() { + return "Failure at this stage usually means that something is wrong with this version.\n" + + "It might be a code issue or a javadoc issue.\n\n" + + "If so, you don't have much choice as close this release, adjust the code and start a whole new release."; + } } diff --git a/src/main/java/io/quarkus/bot/release/step/CoreReleasePerform.java b/src/main/java/io/quarkus/bot/release/step/CoreReleasePerform.java index f7886f9..3747239 100644 --- a/src/main/java/io/quarkus/bot/release/step/CoreReleasePerform.java +++ b/src/main/java/io/quarkus/bot/release/step/CoreReleasePerform.java @@ -1,7 +1,9 @@ package io.quarkus.bot.release.step; import java.io.IOException; +import java.util.List; +import jakarta.inject.Inject; import jakarta.inject.Singleton; import org.kohsuke.github.GHIssue; @@ -10,15 +12,28 @@ import io.quarkiverse.githubaction.Context; import io.quarkus.arc.Unremovable; import io.quarkus.bot.release.ReleaseInformation; +import io.quarkus.bot.release.util.Processes; import io.quarkus.bot.release.util.UpdatedIssueBody; @Singleton @Unremovable public class CoreReleasePerform implements StepHandler { + @Inject + Processes processes; + @Override public int run(Context context, Commands commands, ReleaseInformation releaseInformation, GHIssue issue, UpdatedIssueBody updatedIssueBody) throws IOException, InterruptedException { - throw new IllegalStateException("Testing error handling..."); + + return processes.execute(List.of("./release-perform.sh")); + } + + @Override + public String getErrorHelp() { + return "Please check the workflow run logs but there is a good chance " + + "that the issue was due to a problem with accessing s01.oss.sonatype.org " + + "either when authenticating or when uploading the artifacts.\n" + + "If so, please retry."; } } diff --git a/src/main/java/io/quarkus/bot/release/step/PostCoreRelease.java b/src/main/java/io/quarkus/bot/release/step/PostCoreRelease.java new file mode 100644 index 0000000..944740f --- /dev/null +++ b/src/main/java/io/quarkus/bot/release/step/PostCoreRelease.java @@ -0,0 +1,31 @@ +package io.quarkus.bot.release.step; + +import java.io.IOException; +import java.util.List; + +import jakarta.inject.Inject; +import jakarta.inject.Singleton; + +import org.kohsuke.github.GHIssue; + +import io.quarkiverse.githubaction.Commands; +import io.quarkiverse.githubaction.Context; +import io.quarkus.arc.Unremovable; +import io.quarkus.bot.release.ReleaseInformation; +import io.quarkus.bot.release.util.Processes; +import io.quarkus.bot.release.util.UpdatedIssueBody; + +@Singleton +@Unremovable +public class PostCoreRelease implements StepHandler { + + @Inject + Processes processes; + + @Override + public int run(Context context, Commands commands, ReleaseInformation releaseInformation, GHIssue issue, + UpdatedIssueBody updatedIssueBody) throws IOException, InterruptedException { + return processes.execute(List.of("./postcorerelease.java")); + } + +} diff --git a/src/main/java/io/quarkus/bot/release/step/PostPlatformRelease.java b/src/main/java/io/quarkus/bot/release/step/PostPlatformRelease.java new file mode 100644 index 0000000..170a661 --- /dev/null +++ b/src/main/java/io/quarkus/bot/release/step/PostPlatformRelease.java @@ -0,0 +1,31 @@ +package io.quarkus.bot.release.step; + +import java.io.IOException; +import java.util.List; + +import jakarta.inject.Inject; +import jakarta.inject.Singleton; + +import org.kohsuke.github.GHIssue; + +import io.quarkiverse.githubaction.Commands; +import io.quarkiverse.githubaction.Context; +import io.quarkus.arc.Unremovable; +import io.quarkus.bot.release.ReleaseInformation; +import io.quarkus.bot.release.util.Processes; +import io.quarkus.bot.release.util.UpdatedIssueBody; + +@Singleton +@Unremovable +public class PostPlatformRelease implements StepHandler { + + @Inject + Processes processes; + + @Override + public int run(Context context, Commands commands, ReleaseInformation releaseInformation, GHIssue issue, + UpdatedIssueBody updatedIssueBody) throws IOException, InterruptedException { + return processes.execute(List.of("./postplatformrelease.java")); + } + +} diff --git a/src/main/java/io/quarkus/bot/release/step/Prerequisites.java b/src/main/java/io/quarkus/bot/release/step/Prerequisites.java index 5ad3d30..000536a 100644 --- a/src/main/java/io/quarkus/bot/release/step/Prerequisites.java +++ b/src/main/java/io/quarkus/bot/release/step/Prerequisites.java @@ -15,9 +15,7 @@ import io.quarkiverse.githubaction.Context; import io.quarkus.arc.Unremovable; import io.quarkus.bot.release.ReleaseInformation; -import io.quarkus.bot.release.util.Command; import io.quarkus.bot.release.util.Issues; -import io.quarkus.bot.release.util.Outputs; import io.quarkus.bot.release.util.Processes; import io.quarkus.bot.release.util.UpdatedIssueBody; @@ -52,20 +50,6 @@ public int run(Context context, Commands commands, ReleaseInformation releaseInf releaseInformation.setVersion(Files.readString(Path.of("work", "newVersion")).trim()); issues.appendReleaseInformation(updatedIssueBody, releaseInformation); - StringBuilder comment = new StringBuilder(); - comment.append("We are going to release the following release:\n\n"); - comment.append("- `").append(releaseInformation.getVersion()).append("`\n"); - if (Files.exists(Path.of("work", "maintenance"))) { - comment.append("- This is a `maintenance` release.\n"); - } - if (Files.exists(Path.of("work", "preview"))) { - comment.append("- This is a preview release (e.g. `Alpha`, `Beta`, `CR`).\n"); - } - comment.append( - "\nPlease approve with a `" + Command.YES.getFullCommand() + "` comment if you want to pursue with the release.\n"); - comment.append("\nIf not, simply close this issue."); - commands.setOutput(Outputs.INTERACTION_COMMENT, comment.toString()); - return exitCode; } } diff --git a/src/main/java/io/quarkus/bot/release/step/PublishCLI.java b/src/main/java/io/quarkus/bot/release/step/PublishCLI.java new file mode 100644 index 0000000..1b67deb --- /dev/null +++ b/src/main/java/io/quarkus/bot/release/step/PublishCLI.java @@ -0,0 +1,31 @@ +package io.quarkus.bot.release.step; + +import java.io.IOException; +import java.util.List; + +import jakarta.inject.Inject; +import jakarta.inject.Singleton; + +import org.kohsuke.github.GHIssue; + +import io.quarkiverse.githubaction.Commands; +import io.quarkiverse.githubaction.Context; +import io.quarkus.arc.Unremovable; +import io.quarkus.bot.release.ReleaseInformation; +import io.quarkus.bot.release.util.Processes; +import io.quarkus.bot.release.util.UpdatedIssueBody; + +@Singleton +@Unremovable +public class PublishCLI implements StepHandler { + + @Inject + Processes processes; + + @Override + public int run(Context context, Commands commands, ReleaseInformation releaseInformation, GHIssue issue, + UpdatedIssueBody updatedIssueBody) throws IOException, InterruptedException { + return processes.execute(List.of("./publish-cli.sh")); + } + +} diff --git a/src/main/java/io/quarkus/bot/release/step/ReleaseGradlePlugin.java b/src/main/java/io/quarkus/bot/release/step/ReleaseGradlePlugin.java new file mode 100644 index 0000000..538ff62 --- /dev/null +++ b/src/main/java/io/quarkus/bot/release/step/ReleaseGradlePlugin.java @@ -0,0 +1,31 @@ +package io.quarkus.bot.release.step; + +import java.io.IOException; +import java.util.List; + +import jakarta.inject.Inject; +import jakarta.inject.Singleton; + +import org.kohsuke.github.GHIssue; + +import io.quarkiverse.githubaction.Commands; +import io.quarkiverse.githubaction.Context; +import io.quarkus.arc.Unremovable; +import io.quarkus.bot.release.ReleaseInformation; +import io.quarkus.bot.release.util.Processes; +import io.quarkus.bot.release.util.UpdatedIssueBody; + +@Singleton +@Unremovable +public class ReleaseGradlePlugin implements StepHandler { + + @Inject + Processes processes; + + @Override + public int run(Context context, Commands commands, ReleaseInformation releaseInformation, GHIssue issue, + UpdatedIssueBody updatedIssueBody) throws IOException, InterruptedException { + return processes.execute(List.of("./release-gradle-plugin.sh")); + } + +} diff --git a/src/main/java/io/quarkus/bot/release/step/ReleasePlatform.java b/src/main/java/io/quarkus/bot/release/step/ReleasePlatform.java new file mode 100644 index 0000000..964ff6f --- /dev/null +++ b/src/main/java/io/quarkus/bot/release/step/ReleasePlatform.java @@ -0,0 +1,76 @@ +package io.quarkus.bot.release.step; + +import java.io.IOException; + +import jakarta.inject.Singleton; + +import org.kohsuke.github.GHIssue; +import org.kohsuke.github.GHIssueComment; + +import io.quarkiverse.githubaction.Commands; +import io.quarkiverse.githubaction.Context; +import io.quarkus.arc.Unremovable; +import io.quarkus.bot.release.ReleaseInformation; +import io.quarkus.bot.release.ReleaseStatus; +import io.quarkus.bot.release.util.Command; +import io.quarkus.bot.release.util.Outputs; +import io.quarkus.bot.release.util.UpdatedIssueBody; + +@Singleton +@Unremovable +public class ReleasePlatform implements StepHandler { + + @Override + public boolean shouldPause(Context context, Commands commands, ReleaseInformation releaseInformation, + ReleaseStatus releaseStatus) { + StringBuilder comment = new StringBuilder(); + comment.append("Now is time to release the Quarkus Platform. This is a manual process:\n\n"); + comment.append("* Make sure you have merged all the pull requests that should be included in this version of the Platform"); + comment.append("* Then follow (roughly) this process:\n\n"); + comment.append("```\n"); + comment.append("cd \n"); + comment.append("git checkout " + releaseInformation.getBranch() + "\n"); + comment.append("git pull upstream " + releaseInformation.getBranch() + "\n"); + comment.append("git checkout -b quarkus-" + releaseInformation.getVersion() + "\n"); + comment.append("./update-quarkus-version.sh " + releaseInformation.getVersion() + "\n"); + comment.append("```\n\n"); + comment.append("* Check the diff with `git diff`\n\n"); + comment.append("```\n"); + comment.append("git commit -a -m 'Upgrade to Quarkus " + releaseInformation.getVersion() + "'\n"); + comment.append("git push origin quarkus-" + releaseInformation.getVersion() + "\n"); + comment.append("```\n\n"); + comment.append("* Create a pull request\n"); + comment.append("* Wait for CI to go green\n"); + comment.append("* Merge the pull request\n\n"); + comment.append("```\n"); + comment.append("git checkout " + releaseInformation.getBranch() + "\n"); + comment.append("git pull upstream " + releaseInformation.getBranch() + "\n"); + comment.append("```\n\n"); + comment.append("* Then actually release the branch with the following line:\n\n"); + comment.append("> TAG=" + releaseInformation.getVersion() + " && ./check-version.sh $TAG && ./mvnw release:prepare release:perform -DdevelopmentVersion=999-SNAPSHOT -DreleaseVersion=$TAG -Dtag=$TAG -DperformRelease -Prelease,releaseNexus -DskipTests -Darguments=-DskipTests\n\n"); + comment.append( + ":warning: You need to wait for them to be synced to Maven Central before pursuing with the release:\n\n"); + comment.append("* Wait for 40 minutes\n"); + comment.append("* Check that https://repo1.maven.org/maven2/io/quarkus/platform/quarkus-bom/" + releaseInformation.getVersion() + "/" + + " does not return a 404\n\n"); + comment.append( + "Once these two conditions are true, you can pursue the release by adding a `" + + Command.CONTINUE.getFullCommand() + "` comment."); + commands.setOutput(Outputs.INTERACTION_COMMENT, comment.toString()); + + return true; + } + + @Override + public boolean shouldContinue(Context context, Commands commands, + ReleaseInformation releaseInformation, ReleaseStatus releaseStatus, GHIssueComment issueComment) { + return Command.CONTINUE.matches(issueComment.getBody()); + } + + @Override + public int run(Context context, Commands commands, ReleaseInformation releaseInformation, GHIssue issue, + UpdatedIssueBody updatedIssueBody) throws IOException, InterruptedException { + issue.comment(":white_check_mark: Platform artifacts have been synced to Maven Central, pursuing..."); + return 0; + } +} diff --git a/src/main/java/io/quarkus/bot/release/step/Step.java b/src/main/java/io/quarkus/bot/release/step/Step.java index bfa4c3e..3ccae45 100644 --- a/src/main/java/io/quarkus/bot/release/step/Step.java +++ b/src/main/java/io/quarkus/bot/release/step/Step.java @@ -5,20 +5,18 @@ public enum Step { PREREQUISITES("Prerequisites", Prerequisites.class, false, false), APPROVE_CORE_RELEASE("Approve the core release", ApproveCoreRelease.class, true, false), CORE_RELEASE_PREPARE("Prepare the core release", CoreReleasePrepare.class, true, false), - CORE_RELEASE_PERFORM("Perform the core release", CoreReleasePrepare.class, true, false); -// SYNC_CORE_RELEASE_TO_MAVEN_CENTRAL("Sync core release to Maven Central", true, false), -// RELEASE_GRADLE_PLUGIN("Release Gradle plugin", true, false), -// POST_CORE_RELEASE("Execute post-core-release operations", true, false), -// TRIGGER_PERFORMANCE_LAB("Trigger performance lab", true, false), -// APPROVE_PLATFORM_RELEASE("Approve Quarkus Platform release", true, false), -// RELEASE_PLATFORM("Release the Quarkus Platform", true, false), -// SYNC_PLATFORM_RELEASE_TO_MAVEN_CENTRAL("Sync Quarkus Platform release to Maven Central", true, false), -// RELEASE_EXTENSION_CATALOG("Release extension catalog", true, false), -// POST_PLATFORM_RELEASE("Execute post-Platform-release operations", true, false), -// UPDATE_JBANG_CATALOG("Update JBang catalog", true, true), -// UPDATE_QUICKSTARTS("Update quickstarts", true, true), -// UPDATE_DOCUMENTATION("Update documentation", true, true), -// SYNC_CODE_QUARKUS_IO("Wait for code.quarkus.io to be updated", true, true); + CORE_RELEASE_PERFORM("Perform the core release", CoreReleasePerform.class, true, false), + SYNC_CORE_RELEASE_TO_MAVEN_CENTRAL("Sync core release to Maven Central", SyncCoreRelease.class, true, false), + RELEASE_GRADLE_PLUGIN("Release Gradle plugin", ReleaseGradlePlugin.class, true, false), + POST_CORE_RELEASE("Execute post-core-release operations", PostCoreRelease.class, true, false), +// TRIGGER_PERFORMANCE_LAB("Trigger performance lab", TriggerPerformanceLab.class, true, false), + RELEASE_PLATFORM("Release the Quarkus Platform", ReleasePlatform.class, true, false), + UPDATE_EXTENSION_CATALOG("Update extension catalog", UpdateExtensionCatalog.class, true, false), + POST_PLATFORM_RELEASE("Execute post-Platform-release operations", PostPlatformRelease.class, true, false), + UPDATE_JBANG_CATALOG("Update JBang catalog", UpdateJBangCatalog.class, true, true), + PUBLISH_CLI("Publish CLI", PublishCLI.class, true, true), + UPDATE_QUICKSTARTS("Update quickstarts", UpdateQuickstarts.class, true, true), + UPDATE_DOCUMENTATION("Update documentation", UpdateDocumentation.class, true, true); private final String description; diff --git a/src/main/java/io/quarkus/bot/release/step/StepHandler.java b/src/main/java/io/quarkus/bot/release/step/StepHandler.java index 2f8c047..abefb3a 100644 --- a/src/main/java/io/quarkus/bot/release/step/StepHandler.java +++ b/src/main/java/io/quarkus/bot/release/step/StepHandler.java @@ -16,12 +16,17 @@ public interface StepHandler { int run(Context context, Commands commands, ReleaseInformation releaseInformation, GHIssue issue, UpdatedIssueBody updatedIssueBody) throws IOException, InterruptedException; - default boolean shouldPause(ReleaseInformation releaseInformation, ReleaseStatus releaseStatus) { + default boolean shouldPause(Context context, Commands commands, ReleaseInformation releaseInformation, + ReleaseStatus releaseStatus) { return false; } - default boolean shouldContinue(ReleaseInformation releaseInformation, ReleaseStatus releaseStatus, - GHIssueComment issueComment) { + default boolean shouldContinue(Context context, Commands commands, + ReleaseInformation releaseInformation, ReleaseStatus releaseStatus, GHIssueComment issueComment) { return false; } + + default String getErrorHelp() { + return null; + } } diff --git a/src/main/java/io/quarkus/bot/release/step/SyncCoreRelease.java b/src/main/java/io/quarkus/bot/release/step/SyncCoreRelease.java new file mode 100644 index 0000000..a0afa1f --- /dev/null +++ b/src/main/java/io/quarkus/bot/release/step/SyncCoreRelease.java @@ -0,0 +1,53 @@ +package io.quarkus.bot.release.step; + +import java.io.IOException; + +import jakarta.inject.Singleton; + +import org.kohsuke.github.GHIssue; +import org.kohsuke.github.GHIssueComment; + +import io.quarkiverse.githubaction.Commands; +import io.quarkiverse.githubaction.Context; +import io.quarkus.arc.Unremovable; +import io.quarkus.bot.release.ReleaseInformation; +import io.quarkus.bot.release.ReleaseStatus; +import io.quarkus.bot.release.util.Command; +import io.quarkus.bot.release.util.Outputs; +import io.quarkus.bot.release.util.UpdatedIssueBody; + +@Singleton +@Unremovable +public class SyncCoreRelease implements StepHandler { + + @Override + public boolean shouldPause(Context context, Commands commands, ReleaseInformation releaseInformation, + ReleaseStatus releaseStatus) { + StringBuilder comment = new StringBuilder(); + comment.append("The core artifacts have been pushed to s01.oss.sonatype.org.\n\n"); + comment.append( + ":warning: You need to wait for them to be synced to Maven Central before pursuing with the release:\n\n"); + comment.append("* Wait for one hour\n"); + comment.append("* Check that https://repo1.maven.org/maven2/io/quarkus/quarkus-core/" + releaseInformation.getVersion() + "/" + + " does not return a 404\n\n"); + comment.append( + "Once these two conditions are true, you can pursue the release by adding a `" + + Command.CONTINUE.getFullCommand() + "` comment."); + comment.append("\n\n(Note that we plan to automate this step soonish.)"); + commands.setOutput(Outputs.INTERACTION_COMMENT, comment.toString()); + return true; + } + + @Override + public boolean shouldContinue(Context context, Commands commands, + ReleaseInformation releaseInformation, ReleaseStatus releaseStatus, GHIssueComment issueComment) { + return Command.CONTINUE.matches(issueComment.getBody()); + } + + @Override + public int run(Context context, Commands commands, ReleaseInformation releaseInformation, GHIssue issue, + UpdatedIssueBody updatedIssueBody) throws IOException, InterruptedException { + issue.comment(":white_check_mark: Core artifacts have been synced to Maven Central, pursuing..."); + return 0; + } +} diff --git a/src/main/java/io/quarkus/bot/release/step/UpdateDocumentation.java b/src/main/java/io/quarkus/bot/release/step/UpdateDocumentation.java new file mode 100644 index 0000000..d2789a6 --- /dev/null +++ b/src/main/java/io/quarkus/bot/release/step/UpdateDocumentation.java @@ -0,0 +1,30 @@ +package io.quarkus.bot.release.step; + +import java.io.IOException; +import java.util.List; + +import jakarta.inject.Inject; +import jakarta.inject.Singleton; + +import org.kohsuke.github.GHIssue; + +import io.quarkiverse.githubaction.Commands; +import io.quarkiverse.githubaction.Context; +import io.quarkus.arc.Unremovable; +import io.quarkus.bot.release.ReleaseInformation; +import io.quarkus.bot.release.util.Processes; +import io.quarkus.bot.release.util.UpdatedIssueBody; + +@Singleton +@Unremovable +public class UpdateDocumentation implements StepHandler { + + @Inject + Processes processes; + + @Override + public int run(Context context, Commands commands, ReleaseInformation releaseInformation, GHIssue issue, + UpdatedIssueBody updatedIssueBody) throws IOException, InterruptedException { + return processes.execute(List.of("./update-docs.sh")); + } +} diff --git a/src/main/java/io/quarkus/bot/release/step/UpdateExtensionCatalog.java b/src/main/java/io/quarkus/bot/release/step/UpdateExtensionCatalog.java new file mode 100644 index 0000000..492d25a --- /dev/null +++ b/src/main/java/io/quarkus/bot/release/step/UpdateExtensionCatalog.java @@ -0,0 +1,31 @@ +package io.quarkus.bot.release.step; + +import java.io.IOException; +import java.util.List; + +import jakarta.inject.Inject; +import jakarta.inject.Singleton; + +import org.kohsuke.github.GHIssue; + +import io.quarkiverse.githubaction.Commands; +import io.quarkiverse.githubaction.Context; +import io.quarkus.arc.Unremovable; +import io.quarkus.bot.release.ReleaseInformation; +import io.quarkus.bot.release.util.Processes; +import io.quarkus.bot.release.util.UpdatedIssueBody; + +@Singleton +@Unremovable +public class UpdateExtensionCatalog implements StepHandler { + + @Inject + Processes processes; + + @Override + public int run(Context context, Commands commands, ReleaseInformation releaseInformation, GHIssue issue, + UpdatedIssueBody updatedIssueBody) throws IOException, InterruptedException { + return processes.execute(List.of("./updateextensioncatalog.java")); + } + +} diff --git a/src/main/java/io/quarkus/bot/release/step/UpdateJBangCatalog.java b/src/main/java/io/quarkus/bot/release/step/UpdateJBangCatalog.java new file mode 100644 index 0000000..5e788ec --- /dev/null +++ b/src/main/java/io/quarkus/bot/release/step/UpdateJBangCatalog.java @@ -0,0 +1,31 @@ +package io.quarkus.bot.release.step; + +import java.io.IOException; +import java.util.List; + +import jakarta.inject.Inject; +import jakarta.inject.Singleton; + +import org.kohsuke.github.GHIssue; + +import io.quarkiverse.githubaction.Commands; +import io.quarkiverse.githubaction.Context; +import io.quarkus.arc.Unremovable; +import io.quarkus.bot.release.ReleaseInformation; +import io.quarkus.bot.release.util.Processes; +import io.quarkus.bot.release.util.UpdatedIssueBody; + +@Singleton +@Unremovable +public class UpdateJBangCatalog implements StepHandler { + + @Inject + Processes processes; + + @Override + public int run(Context context, Commands commands, ReleaseInformation releaseInformation, GHIssue issue, + UpdatedIssueBody updatedIssueBody) throws IOException, InterruptedException { + return processes.execute(List.of("./update-jbang-catalog.sh")); + } + +} diff --git a/src/main/java/io/quarkus/bot/release/step/UpdateQuickstarts.java b/src/main/java/io/quarkus/bot/release/step/UpdateQuickstarts.java new file mode 100644 index 0000000..a2f3747 --- /dev/null +++ b/src/main/java/io/quarkus/bot/release/step/UpdateQuickstarts.java @@ -0,0 +1,31 @@ +package io.quarkus.bot.release.step; + +import java.io.IOException; +import java.util.List; + +import jakarta.inject.Inject; +import jakarta.inject.Singleton; + +import org.kohsuke.github.GHIssue; + +import io.quarkiverse.githubaction.Commands; +import io.quarkiverse.githubaction.Context; +import io.quarkus.arc.Unremovable; +import io.quarkus.bot.release.ReleaseInformation; +import io.quarkus.bot.release.util.Processes; +import io.quarkus.bot.release.util.UpdatedIssueBody; + +@Singleton +@Unremovable +public class UpdateQuickstarts implements StepHandler { + + @Inject + Processes processes; + + @Override + public int run(Context context, Commands commands, ReleaseInformation releaseInformation, GHIssue issue, + UpdatedIssueBody updatedIssueBody) throws IOException, InterruptedException { + return processes.execute(List.of("./update-quickstarts.sh")); + } + +} diff --git a/src/test/java/io/quarkus/bot/release/StepInjectionTest.java b/src/test/java/io/quarkus/bot/release/StepInjectionTest.java index 86e4f39..cb8131a 100644 --- a/src/test/java/io/quarkus/bot/release/StepInjectionTest.java +++ b/src/test/java/io/quarkus/bot/release/StepInjectionTest.java @@ -14,7 +14,9 @@ public class StepInjectionTest { @Test void testStepInjection() { for (Step step : Step.values()) { - assertThat(Arc.container().instance(step.getStepHandler()).get()).isNotNull(); + assertThat(Arc.container().instance(step.getStepHandler()).get()) + .as("Step handler for %s does not exist or is not an unremovable CDI bean", step.name()) + .isNotNull(); } } }