Skip to content

Commit 3d309d3

Browse files
authored
feat: Add conditional CLI installation snippets to GitHub release notes (#391)
Show 3 CLI installation variants (Interactive, Headless, Version-Pinned Headless) in GitHub release descriptions only when the app has commands defined in jdeploy.commands. Apps without commands no longer show CLI installation instructions.
1 parent 387b841 commit 3d309d3

File tree

2 files changed

+80
-14
lines changed

2 files changed

+80
-14
lines changed

cli/src/main/java/ca/weblite/jdeploy/helpers/GithubReleaseNotesMutator.java

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ public String createGithubReleaseNotes(
4747
final String repo,
4848
final String branchTag,
4949
final String refType
50+
) {
51+
return createGithubReleaseNotes(repo, branchTag, refType, false, null);
52+
}
53+
54+
public String createGithubReleaseNotes(
55+
final String repo,
56+
final String branchTag,
57+
final String refType,
58+
final boolean hasCommands,
59+
final String version
5060
) {
5161
final String releasesPrefix = "/releases/download/";
5262
final File releaseFilesDir = getGithubReleaseFilesDir();
@@ -114,19 +124,61 @@ public String createGithubReleaseNotes(
114124
.append("<!-- id:").append(BUNDLE_LINUX_ARM64).append("-link -->")
115125
.append("\n"));
116126

117-
if ("branch".equals(refType)) {
118-
notes.append("\nOr launch app installer via command-line on Linux, Mac, or Windows:\n\n");
119-
notes.append("```bash\n");
120-
notes.append("/bin/bash -c \"$(curl -fsSL ").append(JDEPLOY_WEBSITE_URL).append("gh/")
121-
.append(repo).append("/").append(branchTag).append("/install.sh)\"\n");
122-
notes.append("```\n");
123-
notes.append("\nSee [download page](").append(JDEPLOY_WEBSITE_URL).append("gh/").append(repo).append("/").append(branchTag).append(") for more download options.\n\n");
124-
} else {
125-
notes.append("\nOr launch app installer via command-line on Linux, Mac, or Windows:\n\n");
126-
notes.append("```bash\n");
127-
notes.append("/bin/bash -c \"$(curl -fsSL ").append(JDEPLOY_WEBSITE_URL).append("gh/").append(repo).append("/install.sh)\"\n");
128-
notes.append("```\n");
129-
notes.append("\nSee [download page](").append(JDEPLOY_WEBSITE_URL).append("gh/").append(repo).append(") for more download options.\n\n");
127+
// Only show CLI installation section if the app has commands defined
128+
if (hasCommands) {
129+
notes.append("\n## CLI Installation\n\n");
130+
131+
if ("branch".equals(refType)) {
132+
// Branch release - include branch in URL
133+
String baseUrl = JDEPLOY_WEBSITE_URL + "gh/" + repo + "/" + branchTag;
134+
135+
notes.append("### Interactive\n");
136+
notes.append("```bash\n");
137+
notes.append("/bin/bash -c \"$(curl -fsSL '").append(baseUrl).append("/install.sh')\"\n");
138+
notes.append("```\n");
139+
notes.append("Launches graphical installer\n\n");
140+
141+
notes.append("### Headless\n");
142+
notes.append("```bash\n");
143+
notes.append("/bin/bash -c \"$(curl -fsSL '").append(baseUrl).append("/install.sh?headless=true')\"\n");
144+
notes.append("```\n");
145+
notes.append("For CI/CD and automated deployments\n\n");
146+
147+
if (version != null && !version.isEmpty()) {
148+
notes.append("### Version-Pinned Headless\n");
149+
notes.append("```bash\n");
150+
notes.append("/bin/bash -c \"$(curl -fsSL '").append(baseUrl).append("/").append(version).append("/install.sh?headless=true')\"\n");
151+
notes.append("```\n");
152+
notes.append("Install specific version ").append(version).append("\n\n");
153+
}
154+
155+
notes.append("See [download page](").append(baseUrl).append(") for more download options.\n\n");
156+
} else {
157+
// Tag release - no branch in URL
158+
String baseUrl = JDEPLOY_WEBSITE_URL + "gh/" + repo;
159+
160+
notes.append("### Interactive\n");
161+
notes.append("```bash\n");
162+
notes.append("/bin/bash -c \"$(curl -fsSL '").append(baseUrl).append("/install.sh')\"\n");
163+
notes.append("```\n");
164+
notes.append("Launches graphical installer\n\n");
165+
166+
notes.append("### Headless\n");
167+
notes.append("```bash\n");
168+
notes.append("/bin/bash -c \"$(curl -fsSL '").append(baseUrl).append("/install.sh?headless=true')\"\n");
169+
notes.append("```\n");
170+
notes.append("For CI/CD and automated deployments\n\n");
171+
172+
if (version != null && !version.isEmpty()) {
173+
notes.append("### Version-Pinned Headless\n");
174+
notes.append("```bash\n");
175+
notes.append("/bin/bash -c \"$(curl -fsSL '").append(baseUrl).append("/").append(version).append("/install.sh?headless=true')\"\n");
176+
notes.append("```\n");
177+
notes.append("Install specific version ").append(version).append("\n\n");
178+
}
179+
180+
notes.append("See [download page](").append(baseUrl).append(") for more download options.\n\n");
181+
}
130182
}
131183

132184
return notes.toString();

cli/src/main/java/ca/weblite/jdeploy/publishing/github/GitHubPublishDriver.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,24 @@ private String getPackageUrl(PublishTargetInterface target) {
368368

369369

370370
private String createGithubReleaseNotes(PublishingContext context, PublishTargetInterface target) {
371+
// Check if the app has CLI commands defined
372+
boolean hasCommands = false;
373+
try {
374+
JDeployProject project = projectFactory.createProject(context.packagingContext.packageJsonFile.toPath());
375+
hasCommands = !project.getCommandSpecs().isEmpty();
376+
} catch (Exception e) {
377+
// If we can't load the project, assume no commands
378+
context.err().println("Warning: Could not check for CLI commands: " + e.getMessage());
379+
}
380+
381+
String version = context.packagingContext.getVersion();
382+
371383
return new GithubReleaseNotesMutator(context.directory(), context.err()).createGithubReleaseNotes(
372384
getRepository(context, target),
373385
getRefName(context, target),
374-
getRefType(context, target)
386+
getRefType(context, target),
387+
hasCommands,
388+
version
375389
);
376390
}
377391

0 commit comments

Comments
 (0)