Improved UX
- Gracefully handle URL not found - Gracefully handle I/O error - Add emojis - Use a stable JAR file name
This commit is contained in:
parent
39f2d2f979
commit
9aff858685
2 changed files with 28 additions and 13 deletions
12
action.yml
12
action.yml
|
@ -25,14 +25,12 @@ runs:
|
|||
shell: bash
|
||||
run: |
|
||||
echo "::group::📦 Download JReleaser"
|
||||
JAR="jreleaser-tool-provider-${{ inputs.version }}.jar"
|
||||
URL="https://github.com/jreleaser/jreleaser/releases/download/${{ inputs.version }}/$JAR"
|
||||
java "${{ github.action_path }}/copy.java" $URL $JAR
|
||||
java -jar $JAR --version
|
||||
java "${{ github.action_path }}/copy.java" ${{ inputs.version }}
|
||||
java -jar jreleaser-cli.jar --version
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: 'Execute JReleaser'
|
||||
shell: bash
|
||||
run: |
|
||||
JAR="jreleaser-tool-provider-${{ inputs.version }}.jar"
|
||||
echo "☕ java -jar $JAR ${{ inputs.arguments }}"
|
||||
java -jar $JAR ${{ inputs.arguments }}
|
||||
echo "☕ java -jar jreleaser-cli.jar ${{ inputs.arguments }}"
|
||||
java -jar jreleaser-cli.jar ${{ inputs.arguments }}
|
||||
|
|
29
copy.java
29
copy.java
|
@ -1,19 +1,36 @@
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
class copy {
|
||||
public static void main(String... args) throws Exception {
|
||||
if (args.length != 2) {
|
||||
System.err.println("Usage: java copy.java URL FILENAME");
|
||||
if (args.length != 1) {
|
||||
System.err.println("Usage: java copy.java VERSION");
|
||||
System.exit(1);
|
||||
}
|
||||
var url = args[0];
|
||||
|
||||
// TODO: handle version = 'latest'
|
||||
|
||||
var version = args[0];
|
||||
var url = "https://github.com/jreleaser/jreleaser/releases/download/" + version + "/jreleaser-tool-provider-" + version + ".jar";
|
||||
var file = Paths.get("jreleaser-cli.jar");
|
||||
|
||||
try (var stream = new URL(url).openStream()) {
|
||||
var file = Path.of(args[1]);
|
||||
System.out.printf("✅ Located JReleaser %s%n", version);
|
||||
System.out.printf("⬇️ Downloading %s%n", url);
|
||||
var size = Files.copy(stream, file, StandardCopyOption.REPLACE_EXISTING);
|
||||
System.out.printf("%s << copied %d bytes << %s%n", file, size, url);
|
||||
System.out.printf("%s << copied %d bytes%n", file, size);
|
||||
System.out.printf("✅ JReleaser installed successfully%n");
|
||||
} catch(FileNotFoundException e) {
|
||||
System.out.printf("❌ JReleaser %s not found%n", version);
|
||||
System.exit(1);
|
||||
} catch(IOException e) {
|
||||
System.out.printf("☠️ JReleaser %s could not be downloaded/copied%n", version);
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue