From 457d7a45797988287acdd155500b99aa2014b79d Mon Sep 17 00:00:00 2001 From: Thomas Broyer Date: Sun, 24 May 2020 20:03:57 +0200 Subject: [PATCH] Add output parameters for the tool path and version This allows calling the action multiple times in the same job and retrieving the path and/or version in other steps. Fixes #65 --- .github/workflows/workflow.yml | 11 +++++++---- __tests__/verify-java.ps1 | 20 ++++++++++++++++++++ __tests__/verify-java.sh | 24 ++++++++++++++++++++++-- action.yml | 5 +++++ dist/index.js | Bin 168248 -> 169053 bytes src/installer.ts | 2 ++ 6 files changed, 56 insertions(+), 6 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index dda7306..1b7aa65 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -35,15 +35,16 @@ jobs: if: runner.os == 'windows' run: move "${{ runner.tool_cache }}" "${{ runner.tool_cache }}.old" - name: Setup Java 13 + id: setup-java uses: ./ with: java-version: 13.0.2 - name: Verify Java 13 if: runner.os != 'windows' - run: __tests__/verify-java.sh 13.0.2 + run: __tests__/verify-java.sh 13.0.2 "${{ steps.setup-java.outputs.path }}" "${{ steps.setup-java.outputs.version }}" - name: Verify Java 13 (Windows) if: runner.os == 'windows' - run: __tests__/verify-java.ps1 13.0.2 + run: __tests__/verify-java.ps1 13.0.2 "${{ steps.setup-java.outputs.path }}" "${{ steps.setup-java.outputs.version }}" test-proxy: runs-on: ubuntu-latest @@ -62,11 +63,12 @@ jobs: - name: Clear tool cache run: rm -rf $RUNNER_TOOL_CACHE/* - name: Setup Java 13 + id: setup-java uses: ./ with: java-version: 13.0.2 - name: Verify Java 13 - run: __tests__/verify-java.sh 13.0.2 + run: __tests__/verify-java.sh 13.0.2 "${{ steps.setup-java.outputs.path }}" "${{ steps.setup-java.outputs.version }}" test-bypass-proxy: runs-on: ubuntu-latest @@ -78,8 +80,9 @@ jobs: - name: Clear tool cache run: rm -rf $RUNNER_TOOL_CACHE/* - name: Setup Java 13 + id: setup-java uses: ./ with: java-version: 13.0.2 - name: Verify Java 13 - run: __tests__/verify-java.sh 13.0.2 + run: __tests__/verify-java.sh 13.0.2 "${{ steps.setup-java.outputs.path }}" "${{ steps.setup-java.outputs.version }}" diff --git a/__tests__/verify-java.ps1 b/__tests__/verify-java.ps1 index 9f675c8..359f291 100644 --- a/__tests__/verify-java.ps1 +++ b/__tests__/verify-java.ps1 @@ -9,3 +9,23 @@ if (!$java_version.Contains($args[0])) { throw "Unexpected version" } + +if ($args.Count -lt 2 -or !$args[1]) +{ + throw "Must supply java path argument" +} + +if ($args[1] -ne $Env:JAVA_HOME) +{ + throw "Unexpected path" +} + +if ($args.Count -lt 3 -or !$args[2]) +{ + throw "Must supply java version argument" +} + +if ($args[0] -ne $args[2]) +{ + throw "Unexpected version" +} diff --git a/__tests__/verify-java.sh b/__tests__/verify-java.sh index f34aba5..e0da7d3 100755 --- a/__tests__/verify-java.sh +++ b/__tests__/verify-java.sh @@ -1,13 +1,33 @@ #!/bin/sh if [ -z "$1" ]; then - echo "Must supply java version argument" + echo "::error::Must supply java version argument" exit 1 fi java_version="$(java -version 2>&1)" echo "Found java version: $java_version" if [ -z "$(echo $java_version | grep --fixed-strings $1)" ]; then - echo "Unexpected version" + echo "::error::Unexpected version" + exit 1 +fi + +if [ -z "$2" ]; then + echo "::error::Must supply java path argument" + exit 1 +fi + +if [ "$2" != "$JAVA_HOME" ]; then + echo "::error::Unexpected path" + exit 1 +fi + +if [ -z "$3" ]; then + echo "::error::Must supply java version argument" + exit 1 +fi + +if [ "$1" != "$3" ]; then + echo "::error::Unexpected version" exit 1 fi diff --git a/action.yml b/action.yml index de7711f..d41f286 100644 --- a/action.yml +++ b/action.yml @@ -36,6 +36,11 @@ inputs: settings-path: description: 'Path to where the settings.xml file will be written. Default is ~/.m2.' required: false +outputs: + path: + description: 'Path to where the java environment has been installed (same as $JAVA_HOME)' + version: + description: 'Actual version of the java environment that has been installed' runs: using: 'node12' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index 9663265367c82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