Merge pull request #282 from ryanjbaxter/publish-antora-docs
Publish antora docs
This commit is contained in:
@@ -104,7 +104,7 @@ releaser:
|
||||
antora:
|
||||
spring-docs-actions-url: https://github.com/ryanjbaxter/spring-doc-actions
|
||||
spring-docs-actions-tag: v0.0.16
|
||||
sync-antora-docs-command: "./jenkins.sh --docs-username {{ssh-username}} --docs-ssh-key-path {{ssh-key-path}} --docs-host docs-ip.spring.io --docs-ssh-host-key {{host-key}} --site-path {{site-path}} --github-repository {{github-repo}}"
|
||||
sync-antora-docs-command: "./spring-docs-action-runner.sh --docs-username {{ssh-username}} --docs-ssh-key-path {{ssh-key-path}} --docs-host docs-ip.spring.io --docs-ssh-host-key {{host-key}} --site-path {{site-path}} --github-repository {{github-repo}}"
|
||||
meta-release:
|
||||
enabled: false
|
||||
release-train-project-name: spring-cloud-release
|
||||
|
||||
@@ -1 +1 @@
|
||||
making jenkins.sh executable
|
||||
removing jenkins.sh
|
||||
|
||||
Binary file not shown.
@@ -6,3 +6,4 @@ c7c3fa38fd33170e7fbb15541066ebe746ba1ad6 18c66e805702c81fc2099cb09d2490f099581f3
|
||||
b460e89cc9afdb4ecc7c1c3e4e0e1dae0cac7e63 9858d6e0d948d69e62cca0e393dfb21cfb4d7781 Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com> 1715712689 -0400 commit: adding jenkins.sh
|
||||
9858d6e0d948d69e62cca0e393dfb21cfb4d7781 ba9d397eb47402a7e9d00a6e529285341a35168b Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com> 1715712751 -0400 commit: removed runme
|
||||
ba9d397eb47402a7e9d00a6e529285341a35168b 3c1914e048ad43880aecf0ce0ad4d3a5220df39b Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com> 1715712928 -0400 commit: making jenkins.sh executable
|
||||
3c1914e048ad43880aecf0ce0ad4d3a5220df39b 018554f12b64fc2fb8a0ea306455c8d0da30b891 Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com> 1716557772 -0400 commit: removing jenkins.sh
|
||||
|
||||
@@ -6,3 +6,4 @@ c7c3fa38fd33170e7fbb15541066ebe746ba1ad6 18c66e805702c81fc2099cb09d2490f099581f3
|
||||
b460e89cc9afdb4ecc7c1c3e4e0e1dae0cac7e63 9858d6e0d948d69e62cca0e393dfb21cfb4d7781 Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com> 1715712689 -0400 commit: adding jenkins.sh
|
||||
9858d6e0d948d69e62cca0e393dfb21cfb4d7781 ba9d397eb47402a7e9d00a6e529285341a35168b Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com> 1715712751 -0400 commit: removed runme
|
||||
ba9d397eb47402a7e9d00a6e529285341a35168b 3c1914e048ad43880aecf0ce0ad4d3a5220df39b Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com> 1715712928 -0400 commit: making jenkins.sh executable
|
||||
3c1914e048ad43880aecf0ce0ad4d3a5220df39b 018554f12b64fc2fb8a0ea306455c8d0da30b891 Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com> 1716557772 -0400 commit: removing jenkins.sh
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
3c1914e048ad43880aecf0ce0ad4d3a5220df39b
|
||||
018554f12b64fc2fb8a0ea306455c8d0da30b891
|
||||
|
||||
@@ -1 +1 @@
|
||||
76ba2479a8e84ab5431193251c8804efb4736575
|
||||
aef500da0cf73a881df5e7d7ddf0d6533d5f2610
|
||||
|
||||
@@ -1113,6 +1113,9 @@ public class ReleaserProperties implements Serializable {
|
||||
private String generateReleaseTrainDocsCommand = "bash release_train.sh "
|
||||
+ "--retrieveversions --version {{version}} --ghpages --auto";
|
||||
|
||||
/**
|
||||
* Command to be executed to run Antora.
|
||||
*/
|
||||
private String runAntoraCommand = "./mvnw antora {{systemProps}}";
|
||||
|
||||
/**
|
||||
@@ -1418,6 +1421,11 @@ public class ReleaserProperties implements Serializable {
|
||||
*/
|
||||
private long waitTimeInMinutes = 20;
|
||||
|
||||
/**
|
||||
* Command to be executed to run Antora.
|
||||
*/
|
||||
private String runAntoraCommand = "./gradlew antora {{systemProps}}";
|
||||
|
||||
@Override
|
||||
public String getBuildCommand() {
|
||||
return this.buildCommand;
|
||||
@@ -1502,6 +1510,14 @@ public class ReleaserProperties implements Serializable {
|
||||
this.ignoredGradleRegex = ignoredGradleRegex;
|
||||
}
|
||||
|
||||
public String getRunAntoraCommand() {
|
||||
return runAntoraCommand;
|
||||
}
|
||||
|
||||
public void setRunAntoraCommand(String runAntoraCommand) {
|
||||
this.runAntoraCommand = runAntoraCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringJoiner(", ", Gradle.class.getSimpleName() + "[", "]")
|
||||
@@ -1511,6 +1527,7 @@ public class ReleaserProperties implements Serializable {
|
||||
.add("deployGuidesCommand='" + deployGuidesCommand + "'")
|
||||
.add("publishDocsCommand=" + publishDocsCommand)
|
||||
.add("generateReleaseTrainDocsCommand='" + generateReleaseTrainDocsCommand + "'")
|
||||
.add("runAntoraCommand='" + runAntoraCommand + "'")
|
||||
.add("systemProperties='" + systemProperties + "'").add("waitTimeInMinutes=" + waitTimeInMinutes)
|
||||
.toString();
|
||||
}
|
||||
|
||||
@@ -136,8 +136,7 @@ public class ProjectGitHandler implements Closeable {
|
||||
|
||||
public File cloneAndCheckoutSpringDocsActions() {
|
||||
File project = cloneProject(this.properties.getAntora().getSpringDocsActionsUrl());
|
||||
// TODO for testing
|
||||
// checkoutTag(project, this.properties.getAntora().getSpringDocsActionsTag());
|
||||
checkoutTag(project, this.properties.getAntora().getSpringDocsActionsTag());
|
||||
return project;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory;
|
||||
import releaser.internal.ReleaserProperties;
|
||||
import releaser.internal.tech.ReleaserProcessExecutor;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -52,6 +53,13 @@ public class ProjectCommandExecutor {
|
||||
|
||||
private static final String NEXT_VERSION_MUSTACHE = "{{nextVersion}}";
|
||||
|
||||
private static final String RSYNC_ACTIONS_PROJECT_DIR = "/rsync-antora-reference/src";
|
||||
|
||||
private static final String SPRING_DOCS_ACTION_RUNNER = "spring-docs-action-runner.sh";
|
||||
|
||||
private static final String RUNNER_DESTINATION = RSYNC_ACTIONS_PROJECT_DIR + File.separator
|
||||
+ SPRING_DOCS_ACTION_RUNNER;
|
||||
|
||||
public void build(ReleaserProperties properties, ProjectVersion originalVersion,
|
||||
ProjectVersion versionFromReleaseTrain) {
|
||||
build(properties, originalVersion, versionFromReleaseTrain, properties.getWorkingDir());
|
||||
@@ -180,17 +188,32 @@ public class ProjectCommandExecutor {
|
||||
}
|
||||
|
||||
public void publishAntoraDocs(File antoraDocsProject, File project, ReleaserProperties properties) {
|
||||
String command = new CommandPicker(properties).publishAntoraDocsCommand(project, properties);
|
||||
log.info("Executing command for publishing Antora docs " + command + " / " + properties);
|
||||
String[] commands = command.split(" ");
|
||||
// TODO fix this hack
|
||||
for (int i = 0; i < commands.length; i++) {
|
||||
if (commands[i].contains("{{host-key}}")) {
|
||||
commands[i] = commands[i].replace("{{host-key}}",
|
||||
"\"" + properties.getAntora().getSpringDocsSshHostKey()) + "\"";
|
||||
try {
|
||||
copyRunnerToActions(antoraDocsProject);
|
||||
String command = new CommandPicker(properties).publishAntoraDocsCommand(project, properties);
|
||||
log.info("Executing command for publishing Antora docs " + command + " / " + properties);
|
||||
String[] commands = command.split(" ");
|
||||
// TODO fix this hack
|
||||
for (int i = 0; i < commands.length; i++) {
|
||||
if (commands[i].contains("{{host-key}}")) {
|
||||
commands[i] = commands[i].replace("{{host-key}}",
|
||||
"\"" + properties.getAntora().getSpringDocsSshHostKey()) + "\"";
|
||||
}
|
||||
}
|
||||
runCommand(properties, antoraDocsProject.getAbsolutePath() + RSYNC_ACTIONS_PROJECT_DIR, commands);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void copyRunnerToActions(File antoraDocsProject) throws IOException {
|
||||
File destination = new File(antoraDocsProject.getAbsolutePath() + RUNNER_DESTINATION);
|
||||
if (!destination.exists()) {
|
||||
ClassPathResource runner = new ClassPathResource(SPRING_DOCS_ACTION_RUNNER);
|
||||
Files.copy(runner.getInputStream(), destination.toPath());
|
||||
destination.setExecutable(true);
|
||||
}
|
||||
runCommand(properties, antoraDocsProject.getAbsolutePath() + "/rsync-antora-reference/src", commands);
|
||||
}
|
||||
|
||||
public void publishDocs(ReleaserProperties properties, ProjectVersion originalVersion,
|
||||
@@ -335,7 +358,9 @@ class CommandPicker {
|
||||
}
|
||||
|
||||
String runAntoraCommand(ProjectVersion version) {
|
||||
// TODO handle gradle and bash?
|
||||
if (projectType == ProjectType.GRADLE) {
|
||||
return gradleCommandWithSystemProps(releaserProperties.getGradle().getRunAntoraCommand());
|
||||
}
|
||||
return mavenCommandWithSystemProps(releaserProperties.getMaven().getRunAntoraCommand(), version);
|
||||
}
|
||||
|
||||
|
||||
122
releaser-core/src/main/resources/spring-docs-action-runner.sh
Executable file
122
releaser-core/src/main/resources/spring-docs-action-runner.sh
Executable file
@@ -0,0 +1,122 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -f
|
||||
|
||||
# Get the current directory
|
||||
current_dir=$(pwd)
|
||||
|
||||
# Add the current directory to the PATH variable
|
||||
export PATH=$PATH:$current_dir
|
||||
|
||||
__action_usage() {
|
||||
echo "usage: action.sh [OPTION]...
|
||||
|
||||
--docs-username=USERNAME the username used to connect to ssh
|
||||
--docs-host=HOST the host to connect to ssh
|
||||
--docs-ssh-key-path=KEY the path to the private key used to connect to ssh
|
||||
--docs-ssh-host-key=HOST_KEY the host key used to connect to ssh
|
||||
--dry-run signals that rsync should be in dry run mode
|
||||
--site-path=PATH the local directory path to sync to the server. Default build/site
|
||||
--github-repository=GH_REPO the github repository (e.g. spring-projects/spring-security)
|
||||
--httpdocs-path=PATH the optional base httpdocs path (e.g. https://docs.spring.io/spring-security/reference would be /spring-security/reference)
|
||||
If this is set, then the project must own the directory by ensuring to have a .github-repository file with the
|
||||
<OWNER>/<REPOSITORY_NAME> as the content. The default is to use /\${REPOSITORY_NAME}/reference
|
||||
from --github-repository
|
||||
"
|
||||
}
|
||||
|
||||
__action_usage_error() {
|
||||
echo "Error: $1" >&2
|
||||
__action_usage
|
||||
exit 1
|
||||
}
|
||||
|
||||
__action() {
|
||||
local docs_username docs_host docs_ssh_key docs_ssh_host_key site_path github_repository httpdocs_path valid_args
|
||||
local rsync_flag_options=''
|
||||
if [ ! -z "$BUILD_REFNAME" ]; then
|
||||
rsync_flag_options="${rsync_flag_options} --build-ref-name $BUILD_REFNAME"
|
||||
fi
|
||||
valid_args=$(getopt --options '' --long docs-username:,docs-host:,docs-ssh-key-path:,docs-ssh-host-key:,dry-run,site-path:,github-repository:,httpdocs-path: -- "$@")
|
||||
if [[ $? -ne 0 ]]; then
|
||||
__action_usage
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
eval set -- "$valid_args"
|
||||
|
||||
while [ : ]; do
|
||||
case "$1" in
|
||||
--docs-username)
|
||||
docs_username="$2"
|
||||
shift 2
|
||||
;;
|
||||
--docs-host)
|
||||
docs_host="$2"
|
||||
shift 2
|
||||
;;
|
||||
--docs-ssh-key-path)
|
||||
docs_ssh_key=$(cat "$2")
|
||||
shift 2
|
||||
;;
|
||||
--docs-ssh-host-key)
|
||||
docs_ssh_host_key="$2"
|
||||
shift 2
|
||||
;;
|
||||
--dry-run)
|
||||
rsync_flag_options="${rsync_flag_options} --dry-run"
|
||||
shift
|
||||
;;
|
||||
--site-path)
|
||||
site_path="$2"
|
||||
shift 2
|
||||
;;
|
||||
--github-repository)
|
||||
github_repository="$2"
|
||||
shift 2
|
||||
;;
|
||||
--httpdocs-path)
|
||||
httpdocs_path="$2"
|
||||
shift 2
|
||||
;;
|
||||
--) shift;
|
||||
break
|
||||
;;
|
||||
*)
|
||||
__action_usage_error "Invalid argument $1 $2"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$docs_username" ]; then
|
||||
__action_usage_error "Missing option '--docs-username'"
|
||||
fi
|
||||
if [ -z "$docs_host" ]; then
|
||||
__action_usage_error "Missing option '--docs-host'"
|
||||
fi
|
||||
if [ -z "$docs_ssh_key" ]; then
|
||||
__action_usage_error "Missing option '--docs-ssh-key'"
|
||||
fi
|
||||
if [ -z "$docs_ssh_host_key" ]; then
|
||||
__action_usage_error "Missing option '--docs-ssh-host-key'"
|
||||
fi
|
||||
if [ -z "$site_path" ]; then
|
||||
site_path="build/site"
|
||||
fi
|
||||
if [ -z "$github_repository" ]; then
|
||||
__action_usage_error "Missing option '--github-repository'"
|
||||
fi
|
||||
|
||||
(
|
||||
set -e
|
||||
set -f
|
||||
|
||||
action.sh --docs-username "$docs_username" --docs-host "$docs_host" --docs-ssh-key "$docs_ssh_key" --docs-ssh-host-key "$docs_ssh_host_key" --site-path "$site_path" --github-repository "$github_repository" $rsync_flag_options
|
||||
)
|
||||
exit_code=$?
|
||||
|
||||
|
||||
exit $exit_code
|
||||
}
|
||||
|
||||
__action "$@"
|
||||
Reference in New Issue
Block a user