1 #
  2 # Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
  3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4 #
  5 # This code is free software; you can redistribute it and/or modify it
  6 # under the terms of the GNU General Public License version 2 only, as
  7 # published by the Free Software Foundation.  Oracle designates this
  8 # particular file as subject to the "Classpath" exception as provided
  9 # by Oracle in the LICENSE file that accompanied this code.
 10 #
 11 # This code is distributed in the hope that it will be useful, but WITHOUT
 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14 # version 2 for more details (a copy is included in the LICENSE file that
 15 # accompanied this code).
 16 #
 17 # You should have received a copy of the GNU General Public License version
 18 # 2 along with this work; if not, write to the Free Software Foundation,
 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20 #
 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22 # or visit www.oracle.com if you need additional information or have any
 23 # questions.
 24 #
 25 
 26 name: 'Get BootJDK'
 27 description: 'Download the BootJDK from cache or source location'
 28 inputs:
 29   platform:
 30     description: 'Platform'
 31     required: true
 32 outputs:
 33   path:
 34     description: 'Path to the installed BootJDK'
 35     value: ${{ steps.path-name.outputs.path }}
 36 
 37 runs:
 38   using: composite
 39   steps:
 40     - name: 'Determine platform prefix'
 41       id: platform-prefix
 42       run: |
 43         # Convert platform name to upper case
 44         platform_prefix="$(echo ${{ inputs.platform }} | tr [a-z-] [A-Z_])"
 45         echo "value=$platform_prefix" >> $GITHUB_OUTPUT
 46       shell: bash
 47 
 48     - name: 'Get URL configuration'
 49       id: url
 50       uses: ./.github/actions/config
 51       with:
 52         var: ${{ steps.platform-prefix.outputs.value}}_BOOT_JDK_URL
 53 
 54     - name: 'Get SHA256 configuration'
 55       id: sha256
 56       uses: ./.github/actions/config
 57       with:
 58         var: ${{ steps.platform-prefix.outputs.value}}_BOOT_JDK_SHA256
 59 
 60     - name: 'Get file extension configuration'
 61       id: ext
 62       uses: ./.github/actions/config
 63       with:
 64         var: ${{ steps.platform-prefix.outputs.value}}_BOOT_JDK_EXT
 65 
 66     - name: 'Check cache for BootJDK'
 67       id: get-cached-bootjdk
 68       uses: actions/cache@v3
 69       with:
 70         path: bootjdk/jdk
 71         key: boot-jdk-${{ inputs.platform }}-${{ steps.sha256.outputs.value }}
 72 
 73       # macOS is missing sha256sum
 74     - name: 'Install sha256sum'
 75       run: |
 76         # Run Homebrew installation
 77         brew install coreutils
 78       shell: bash
 79       if: steps.get-cached-bootjdk.outputs.cache-hit != 'true' && runner.os == 'macOS'
 80 
 81     - name: 'Download BootJDK'
 82       run: |
 83         # Download BootJDK and verify checksum
 84         mkdir -p bootjdk/jdk
 85         mkdir -p bootjdk/unpacked
 86         wget --progress=dot:mega -O bootjdk/jdk.${{ steps.ext.outputs.value }} '${{ steps.url.outputs.value }}'
 87         echo '${{ steps.sha256.outputs.value }} bootjdk/jdk.${{ steps.ext.outputs.value }}' | sha256sum -c >/dev/null -
 88       shell: bash
 89       if: steps.get-cached-bootjdk.outputs.cache-hit != 'true'
 90 
 91     - name: 'Unpack BootJDK'
 92       run: |
 93         # Unpack the BootJDK and move files to a common location
 94         if [[ '${{ steps.ext.outputs.value }}' == 'tar.gz' ]]; then
 95           tar -xf bootjdk/jdk.${{ steps.ext.outputs.value }} -C bootjdk/unpacked
 96         else
 97           unzip -q bootjdk/jdk.${{ steps.ext.outputs.value }} -d bootjdk/unpacked
 98         fi
 99         jdk_root="$(dirname $(find bootjdk/unpacked -name bin -type d))"
100         mv "$jdk_root"/* bootjdk/jdk/
101       shell: bash
102       if: steps.get-cached-bootjdk.outputs.cache-hit != 'true'
103 
104     - name: 'Export path to where BootJDK is installed'
105       id: path-name
106       run: |
107         # Export the absolute path
108         echo "path=`pwd`/bootjdk/jdk" >> $GITHUB_OUTPUT
109       shell: bash