Merge pull request #66 from tbroyer/outputs
Add output parameters for the tool path and version
This commit is contained in:
		
						commit
						6e1616c588
					
				
							
								
								
									
										11
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							| @ -35,15 +35,16 @@ jobs: | |||||||
|       if: runner.os == 'windows' |       if: runner.os == 'windows' | ||||||
|       run: move "${{ runner.tool_cache }}" "${{ runner.tool_cache }}.old" |       run: move "${{ runner.tool_cache }}" "${{ runner.tool_cache }}.old" | ||||||
|     - name: Setup Java 13 |     - name: Setup Java 13 | ||||||
|  |       id: setup-java | ||||||
|       uses: ./ |       uses: ./ | ||||||
|       with: |       with: | ||||||
|         java-version: 13.0.2 |         java-version: 13.0.2 | ||||||
|     - name: Verify Java 13 |     - name: Verify Java 13 | ||||||
|       if: runner.os != 'windows' |       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) |     - name: Verify Java 13 (Windows) | ||||||
|       if: runner.os == '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: |   test-proxy: | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
| @ -62,11 +63,12 @@ jobs: | |||||||
|     - name: Clear tool cache |     - name: Clear tool cache | ||||||
|       run: rm -rf $RUNNER_TOOL_CACHE/* |       run: rm -rf $RUNNER_TOOL_CACHE/* | ||||||
|     - name: Setup Java 13 |     - name: Setup Java 13 | ||||||
|  |       id: setup-java | ||||||
|       uses: ./ |       uses: ./ | ||||||
|       with: |       with: | ||||||
|         java-version: 13.0.2 |         java-version: 13.0.2 | ||||||
|     - name: Verify Java 13 |     - 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: |   test-bypass-proxy: | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
| @ -78,8 +80,9 @@ jobs: | |||||||
|     - name: Clear tool cache |     - name: Clear tool cache | ||||||
|       run: rm -rf $RUNNER_TOOL_CACHE/* |       run: rm -rf $RUNNER_TOOL_CACHE/* | ||||||
|     - name: Setup Java 13 |     - name: Setup Java 13 | ||||||
|  |       id: setup-java | ||||||
|       uses: ./ |       uses: ./ | ||||||
|       with: |       with: | ||||||
|         java-version: 13.0.2 |         java-version: 13.0.2 | ||||||
|     - name: Verify Java 13 |     - 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 }}" | ||||||
|  | |||||||
| @ -9,3 +9,23 @@ if (!$java_version.Contains($args[0])) | |||||||
| { | { | ||||||
|   throw "Unexpected version" |   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" | ||||||
|  | } | ||||||
|  | |||||||
| @ -1,13 +1,33 @@ | |||||||
| #!/bin/sh | #!/bin/sh | ||||||
| 
 | 
 | ||||||
| if [ -z "$1" ]; then | if [ -z "$1" ]; then | ||||||
|   echo "Must supply java version argument" |   echo "::error::Must supply java version argument" | ||||||
|   exit 1 |   exit 1 | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| java_version="$(java -version 2>&1)" | java_version="$(java -version 2>&1)" | ||||||
| echo "Found java version: $java_version" | echo "Found java version: $java_version" | ||||||
| if [ -z "$(echo $java_version | grep --fixed-strings $1)" ]; then | 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 |   exit 1 | ||||||
| fi | fi | ||||||
|  | |||||||
| @ -36,6 +36,11 @@ inputs: | |||||||
|   settings-path: |   settings-path: | ||||||
|     description: 'Path to where the settings.xml file will be written. Default is ~/.m2.' |     description: 'Path to where the settings.xml file will be written. Default is ~/.m2.' | ||||||
|     required: false |     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: | runs: | ||||||
|   using: 'node12' |   using: 'node12' | ||||||
|   main: 'dist/index.js' |   main: 'dist/index.js' | ||||||
|  | |||||||
							
								
								
									
										
											BIN
										
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -90,6 +90,8 @@ export async function getJava( | |||||||
|   core.exportVariable('JAVA_HOME', toolPath); |   core.exportVariable('JAVA_HOME', toolPath); | ||||||
|   core.exportVariable(extendedJavaHome, toolPath); |   core.exportVariable(extendedJavaHome, toolPath); | ||||||
|   core.addPath(path.join(toolPath, 'bin')); |   core.addPath(path.join(toolPath, 'bin')); | ||||||
|  |   core.setOutput('path', toolPath); | ||||||
|  |   core.setOutput('version', version); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function getCacheVersionString(version: string) { | function getCacheVersionString(version: string) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user