Skip to content

OpenJDK Static Builds #21

OpenJDK Static Builds

OpenJDK Static Builds #21

Workflow file for this run

#
# Copyright (c) 2024, Gluon and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
name: 'OpenJDK Static Builds'
on:
workflow_dispatch:
inputs:
platforms:
description: 'Platform(s) to execute on (comma separated, e.g. "android-linux-aarch64, ios-macos-aarch64, linux-x64, macos, aarch64")'
required: true
default: 'android-linux-aarch64, ios-macos-aarch64, linux-x64, macos-x64, macos-aarch64, windows-x64, windows-aarch64'
configure-arguments:
description: 'Additional configure arguments'
required: false
make-arguments:
description: 'Additional make arguments'
required: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
###
### Determine platforms to include
###
select:
name: 'Select platforms'
runs-on: ubuntu-22.04
env:
# List of platforms to exclude by default
EXCLUDED_PLATFORMS: 'alpine-linux-x64'
outputs:
android-linux-aarch64: ${{ steps.include.outputs.android-linux-aarch64 }}
ios-macos-aarch64: ${{ steps.include.outputs.ios-macos-aarch64 }}
linux-x64: ${{ steps.include.outputs.linux-x64 }}
linux-x86-hs: ${{ steps.include.outputs.linux-x86-hs }}
linux-x64-variants: ${{ steps.include.outputs.linux-x64-variants }}
linux-cross-compile: ${{ steps.include.outputs.linux-cross-compile }}
alpine-linux-x64: ${{ steps.include.outputs.alpine-linux-x64 }}
macos-x64: ${{ steps.include.outputs.macos-x64 }}
macos-aarch64: ${{ steps.include.outputs.macos-aarch64 }}
windows-x64: ${{ steps.include.outputs.windows-x64 }}
windows-aarch64: ${{ steps.include.outputs.windows-aarch64 }}
docs: ${{ steps.include.outputs.docs }}
steps:
# This function must be inlined in main.yml, or we'd be forced to checkout the repo
- name: 'Check what jobs to run'
id: include
run: |
# Determine which platform jobs to run
# Returns 'true' if the input platform list matches any of the platform monikers given as argument,
# 'false' otherwise.
# arg $1: platform name or names to look for
# Convert EXCLUDED_PLATFORMS from a comma-separated string to an array
IFS=',' read -r -a excluded_array <<< "$EXCLUDED_PLATFORMS"
function check_platform() {
if [[ $GITHUB_EVENT_NAME == workflow_dispatch ]]; then
input='${{ github.event.inputs.platforms }}'
elif [[ $GITHUB_EVENT_NAME == push ]]; then
if [[ '${{ !secrets.JDK_SUBMIT_FILTER || startsWith(github.ref, 'refs/heads/submit/') }}' == 'false' ]]; then
# If JDK_SUBMIT_FILTER is set, and this is not a "submit/" branch, don't run anything
>&2 echo 'JDK_SUBMIT_FILTER is set and not a "submit/" branch'
echo 'false'
return
else
input='android-linux-aarch64, ios-macos-aarch64' # what should we do here?
fi
fi
normalized_input="$(echo ,$input, | tr -d ' ')"
if [[ "$normalized_input" == ",," ]]; then
# For an empty input, assume all platforms should run, except those in the EXCLUDED_PLATFORMS list
for excluded in "${excluded_array[@]}"; do
if [[ "$1" == "$excluded" ]]; then
echo 'false'
return
fi
done
echo 'true'
return
else
# Check for all acceptable platform names
for part in $* ; do
if echo "$normalized_input" | grep -q -e ",$part," ; then
echo 'true'
return
fi
done
# If not explicitly included, check against the EXCLUDED_PLATFORMS list
for excluded in "${excluded_array[@]}"; do
if [[ "$1" == "$excluded" ]]; then
echo 'false'
return
fi
done
fi
echo 'false'
}
echo "android-linux-aarch64=$(check_platform android-linux-aarch64 android linux aarch64)" >> $GITHUB_OUTPUT
echo "ios-macos-aarch64=$(check_platform ios-macos-aarch64 ios macos aarch64)" >> $GITHUB_OUTPUT
echo "linux-x64=$(check_platform linux-x64 linux x64)" >> $GITHUB_OUTPUT
echo "linux-x86-hs=$(check_platform linux-x86-hs linux x86)" >> $GITHUB_OUTPUT
echo "linux-x64-variants=$(check_platform linux-x64-variants variants)" >> $GITHUB_OUTPUT
echo "linux-cross-compile=$(check_platform linux-cross-compile cross-compile)" >> $GITHUB_OUTPUT
echo "alpine-linux-x64=$(check_platform alpine-linux-x64 alpine-linux x64)" >> $GITHUB_OUTPUT
echo "macos-x64=$(check_platform macos-x64 macos x64)" >> $GITHUB_OUTPUT
echo "macos-aarch64=$(check_platform macos-aarch64 macos aarch64)" >> $GITHUB_OUTPUT
echo "windows-x64=$(check_platform windows-x64 windows x64)" >> $GITHUB_OUTPUT
echo "windows-aarch64=$(check_platform windows-aarch64 windows aarch64)" >> $GITHUB_OUTPUT
echo "docs=$(check_platform docs)" >> $GITHUB_OUTPUT
###
### Build jobs
###
build-android-linux-aarch64:
name: android-linux-aarch64
needs: select
uses: ./.github/workflows/build-android-linux.yml
with:
platform: android-linux-aarch64
make-target: 'static-libs'
gcc-major-version: '10'
debug-levels: '[ "release" ]'
configure-arguments: ${{ github.event.inputs.configure-arguments }}
make-arguments: ${{ github.event.inputs.make-arguments }}
if: needs.select.outputs.android-linux-aarch64 == 'true'
build-ios-macos-aarch64:
name: ios-macos-aarch64
needs: select
uses: ./.github/workflows/build-ios-macos.yml
with:
platform: ios-macos-aarch64
runs-on: 'macos-14'
make-target: 'static-libs'
xcode-toolset-version: '14.3.1'
debug-levels: '[ "release" ]'
configure-arguments: ${{ github.event.inputs.configure-arguments }}
make-arguments: ${{ github.event.inputs.make-arguments }}
if: needs.select.outputs.ios-macos-aarch64 == 'true'
build-linux-x64:
name: linux-x64
needs: select
uses: ./.github/workflows/build-linux.yml
with:
platform: linux-x64
make-target: 'static-libs'
gcc-major-version: '10'
debug-levels: '[ "release" ]'
configure-arguments: ${{ github.event.inputs.configure-arguments }}
make-arguments: ${{ github.event.inputs.make-arguments }}
if: needs.select.outputs.linux-x64 == 'true'
build-macos-x64:
name: macos-x64
needs: select
uses: ./.github/workflows/build-macos.yml
with:
platform: macos-x64
runs-on: 'macos-13'
make-target: 'static-libs'
xcode-toolset-version: '14.3.1'
debug-levels: '[ "release" ]'
configure-arguments: ${{ github.event.inputs.configure-arguments }}
make-arguments: ${{ github.event.inputs.make-arguments }}
if: needs.select.outputs.macos-x64 == 'true'
build-macos-aarch64:
name: macos-aarch64
needs: select
uses: ./.github/workflows/build-macos.yml
with:
platform: macos-aarch64
runs-on: 'macos-14'
make-target: 'static-libs'
xcode-toolset-version: '14.3.1'
debug-levels: '[ "release" ]'
configure-arguments: ${{ github.event.inputs.configure-arguments }}
make-arguments: ${{ github.event.inputs.make-arguments }}
if: needs.select.outputs.macos-aarch64 == 'true'
build-windows-x64:
name: windows-x64
needs: select
uses: ./.github/workflows/build-windows.yml
with:
platform: windows-x64
make-target: 'static-libs'
msvc-toolset-version: '14.29'
msvc-toolset-architecture: 'x86.x64'
debug-levels: '[ "release" ]'
configure-arguments: ${{ github.event.inputs.configure-arguments }}
make-arguments: ${{ github.event.inputs.make-arguments }}
if: needs.select.outputs.windows-x64 == 'true'
build-windows-aarch64:
name: windows-aarch64
needs: select
uses: ./.github/workflows/build-windows.yml
with:
platform: windows-aarch64
make-target: 'static-libs'
msvc-toolset-version: '14.29'
msvc-toolset-architecture: 'arm64'
extra-conf-options: '--openjdk-target=aarch64-unknown-cygwin'
debug-levels: '[ "release" ]'
configure-arguments: ${{ github.event.inputs.configure-arguments }}
make-arguments: ${{ github.event.inputs.make-arguments }}
if: needs.select.outputs.windows-aarch64 == 'true'
# Remove bundles so they are not misconstrued as binary distributions from the JDK project
remove-bundles:
name: 'Remove bundle artifacts'
runs-on: ubuntu-22.04
if: always()
needs:
- build-android-linux-aarch64
- build-ios-macos-aarch64
- build-linux-x64
- build-macos-x64
- build-macos-aarch64
- build-windows-x64
- build-windows-aarch64
steps:
- name: 'Remove bundle artifacts'
if: needs.select.outputs.android-linux-aarch64 == 'false' # should this be here?
run: |
# Find and remove all bundle artifacts
# See: https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28
ALL_ARTIFACT_IDS="$(curl -sL \
-H 'Accept: application/vnd.github+json' \
-H 'Authorization: Bearer ${{ github.token }}' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
'${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts?per_page=100')"
BUNDLE_ARTIFACT_IDS="$(echo "$ALL_ARTIFACT_IDS" | jq -r -c '.artifacts | map(select(.name|startswith("bundles-"))) | .[].id')"
for id in $BUNDLE_ARTIFACT_IDS; do
echo "Removing $id"
curl -sL \
-X DELETE \
-H 'Accept: application/vnd.github+json' \
-H 'Authorization: Bearer ${{ github.token }}' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
"${{ github.api_url }}/repos/${{ github.repository }}/actions/artifacts/$id" \
|| echo "Failed to remove bundle"
done