Here's a GitHub Actions workflow for building Java JDK on Windows x64 using Cygwin with the requested inputs and defaults:
name: Build JDK with Cygwin
on:
workflow_dispatch:
inputs:
branch_or_ref:
description: 'Branch, tag, or commit SHA'
default: 'master'
disable_warnings:
description: 'Add --disable-warnings-as-errors'
required: false
default: 'false'
type: boolean
build_type:
description: 'Build debug level'
required: true
default: 'release'
type: string
# Options: release, optimized, fastdebug, slowdebug
boot_provider:
description: 'Boot JDK provider'
default: 'Adoptium'
boot_version:
description: 'Boot JDK version'
default: '21'
extra_configure:
description: 'Extra configure flags'
default: ''
artifact_name:
description: 'Artifact name'
default: ''
push:
branches:
- main
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch_or_ref }}
- name: Install Cygwin
run: |
# Download and install Cygwin with necessary packages
Invoke-WebRequest -Uri "https://cygwin.com/setup-x86_64.exe" -OutFile "setup.exe"
Start-Process -FilePath .\setup.exe -ArgumentList "--no-admin", "--quiet-mode", "--root C:\cygwin64", "--local-package-dir C:\cygwin64\var\cache\setup", "--site https://mirrors.kernel.org/sourceware/cygwin/", "--packages make,autoconf,automake,libtool,m4,git,unzip,zip,python,perl,libstdc++6,libgcc1,libwinpthread-git" -Wait
Remove-Item setup.exe
shell: powershell
- name: Set up Boot JDK
uses: actions/setup-java@v3
with:
distribution: 'adoptium'
java-version: ${{ github.event.inputs.boot_version }}
architecture: x64
- name: Configure JDK Build
shell: bash
run: |
cygwin_bash=/cygdrive/c/cygwin64/bin/bash
configure_cmd="JAVA_HOME=${JAVA_HOME} ./configure --with-boot-jdk=${JAVA_HOME} --with-debug-level='${{ github.event.inputs.build_type }}' ${{ github.event.inputs.extra_configure }}"
if [ "${{ github.event.inputs.disable_warnings }}" == "true" ]; then
configure_cmd+=" --disable-warnings-as-errors"
fi
$cygwin_bash -l -c "cd /cygdrive/c/GITHUB_WORKSPACE && $configure_cmd"
- name: Build JDK
shell: bash
run: |
cygwin_bash=/cygdrive/c/cygwin64/bin/bash
$cygwin_bash -l -c "cd /cygdrive/c/GITHUB_WORKSPACE && make"
- name: Make Images
shell: bash
run: |
cygwin_bash=/cygdrive/c/cygwin64/bin/bash
$cygwin_bash -l -c "cd /cygdrive/c/GITHUB_WORKSPACE && make images"
- name: Make Install
shell: bash
run: |
cygwin_bash=/cygdrive/c/cygwin64/bin/bash
$cygwin_bash -l -c "cd /cygdrive/c/GITHUB_WORKSPACE && make install"
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ github.event.inputs.artifact_name != '' ? github.event.inputs.artifact_name : format('{0}-{1}-windows-x64', github.repository.split('/')[1], github.event.inputs.branch_or_ref) }}
path: build/windows-x64/jdk
Key Features:
-
Inputs:
branch_or_ref: Defaults to "master"
disable_warnings: Checkbox for warnings flag
build_type: Defaults to "release"
boot_provider: Defaults to Adoptium
boot_version: Defaults to 21
extra_configure: Optional flags
artifact_name: Defaults to repo-name-branch-windows-x64
-
Workflow Triggers:
- Manual trigger via
workflow_dispatch
- Automatic trigger on pushes to
main
-
Cygwin Setup:
- Installs required packages (make, autoconf, etc.)
- Uses PowerShell for installation
-
Build Process:
- Uses Adoptium as Boot JDK
- Configures build with dynamic flags
- Builds JDK using standard
make commands
-
Artifact Upload:
- Uploads built JDK to GitHub Artifacts
- Uses computed name if not provided
Usage Notes:
- Path Adjustments: The
build/windows-x64/jdk path may need adjustment based on your JDK version/build system
- Package Requirements: The Cygwin packages listed are minimal - additional packages may be required depending on your JDK version
- Environment Variables: The
JAVA_HOME is explicitly passed to the Cygwin environment
- Timeout Considerations: Long-running builds may require increasing the job timeout
To use this workflow:
- Save as
.github/workflows/build-jdk.yml
- Trigger manually via GitHub UI or on
main branch pushes
- Adjust paths/packages if needed for your JDK version
The artifact will be available in the "Artifacts" section of the workflow run.