From ea8307908b9f957ba29a36ded0b757f7a8d7ba9c Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Sat, 27 Mar 2021 20:23:46 +0100 Subject: [PATCH] Fix Windows run and merge tag+jar into version input --- action.yml | 27 +++++++++++++-------------- copy.java | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 copy.java diff --git a/action.yml b/action.yml index 88ab83d..c92e4a8 100644 --- a/action.yml +++ b/action.yml @@ -8,32 +8,31 @@ branding: inputs: - tag: - description: 'The GitHub releases tag that points to JReleaser''s executable JAR file.' + version: + description: 'The version of JReleaser to download and execute.' default: 'early-access' required: true - jar: - description: 'The name of the executable JAR file to download and execute.' - default: 'jreleaser-tool-provider-0.1.0-SNAPSHOT.jar' - required: true - arguments: - description: 'The arguments to be passed to JReleaser.' + description: 'The command-line arguments to be passed to JReleaser.' default: 'full-release' required: true runs: using: 'composite' steps: - - name: 'Initialize JReleaser' + - name: 'Download JReleaser' shell: bash run: | - echo "Initialize JReleaser" - wget https://github.com/jreleaser/jreleaser/releases/download/${{ inputs.tag }}/${{ inputs.jar }} + 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 echo "::endgroup::" - - name: 'Launch JReleaser' + - name: 'Execute JReleaser' shell: bash run: | - echo "java -jar ${{ inputs.jar }} ${{ inputs.arguments }}" - java -jar ${{ inputs.jar }} ${{ inputs.arguments }} + JAR="jreleaser-tool-provider-${{ inputs.version }}.jar" + echo "java -jar $JAR ${{ inputs.arguments }}" + java -jar $JAR ${{ inputs.arguments }} diff --git a/copy.java b/copy.java new file mode 100644 index 0000000..c07188d --- /dev/null +++ b/copy.java @@ -0,0 +1,19 @@ +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +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"); + System.exit(1); + } + var url = args[0]; + try (var stream = new URL(url).openStream()) { + var file = Path.of(args[1]); + var size = Files.copy(stream, file, StandardCopyOption.REPLACE_EXISTING); + System.out.printf("%s << copied %d bytes << %s%n", file, size, url); + } + } +}