Certainly! Below is a GitHub Actions workflow that meets your requirements:
- Builds OpenJDK on Windows x64 using Cygwin.
- Allows manual trigger with inputs for branch/tag/commit SHA, boot JDK provider/version, debug level, extra configure flags, and artifact name.
- Runs automatically on sync with the main repo (push to
main branch).
- Uploads the build artifact.
- Supports
--disable-warnings-as-errors flag via checkbox input.
- Uses sensible defaults.
name: Build OpenJDK Windows x64
on:
workflow_dispatch:
inputs:
ref:
description: 'Branch, tag, or commit SHA to build'
required: true
default: 'master'
disable_warnings_as_errors:
description: 'Add --disable-warnings-as-errors flag'
required: false
type: boolean
default: false
debug_level:
description: 'Build debug level'
required: true
default: 'release'
type: choice
options:
- release
- optimized
- fastdebug
- slowdebug
boot_jdk_provider:
description: 'Boot JDK provider'
required: true
default: 'Adoptium'
type: choice
options:
- Adoptium
- Oracle
- Zulu
- AmazonCorretto
boot_jdk_version:
description: 'Boot JDK version'
required: true
default: '21'
extra_configure_flags:
description: 'Extra configure flags (optional)'
required: false
default: ''
artifact_name:
description: 'Artifact name'
required: false
default: '' # Will be set dynamically in job
push:
branches:
- main
jobs:
build:
runs-on: windows-latest
env:
CYGWIN: nodosfilewarning
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || github.ref_name }}
- name: Set up artifact name
id: artifact_name
run: |
repo_name="${{ github.repository }}"
repo_name="${repo_name##*/}"
branch="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || github.ref_name }}"
# Sanitize branch name for artifact
branch="${branch//\//-}"
if [ -z "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifact_name }}" ]; then
echo "artifact=${repo_name}-${branch}-windows-x64.zip" >> $GITHUB_OUTPUT
else
echo "artifact=${{ github.event.inputs.artifact_name }}" >> $GITHUB_OUTPUT
fi
- name: Install Cygwin
shell: powershell
run: |
Invoke-WebRequest -Uri https://cygwin.com/setup-x86_64.exe -OutFile setup-x86_64.exe
./setup-x86_64.exe -q -P make,gcc,g++,autoconf,automake,libtool,perl,zip,unzip,tar,git,openssh,rsync
- name: Download Boot JDK
shell: bash
run: |
PROVIDER="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.boot_jdk_provider || 'Adoptium' }}"
VERSION="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.boot_jdk_version || '21' }}"
# Simple example for Adoptium, extend for other providers as needed
if [ "$PROVIDER" = "Adoptium" ]; then
URL="https://github.com/adoptium/temurin${VERSION}-binaries/releases/latest/download/OpenJDK${VERSION}U-jdk_x64_windows_hotspot_latest.zip"
else
echo "Unsupported boot JDK provider: $PROVIDER"
exit 1
fi
curl -L -o bootjdk.zip "$URL"
unzip bootjdk.zip -d bootjdk
export BOOT_JDK_PATH=$(find bootjdk -maxdepth 1 -type d -name "jdk*" | head -n 1)
echo "BOOT_JDK_PATH=$BOOT_JDK_PATH" >> $GITHUB_ENV
- name: Run configure and build
shell: bash
run: |
set -e
# Enter Cygwin environment
C:/cygwin64/bin/bash.exe -c "
cd $(pwd)
./configure --with-boot-jdk=$BOOT_JDK_PATH --with-debug-level=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_level || 'release' }} $([[ ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.disable_warnings_as_errors }} == 'true' ]] && echo '--disable-warnings-as-errors') ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.extra_configure_flags || '' }}
make images
"
- name: Package build artifact
shell: bash
run: |
C:/cygwin64/bin/bash.exe -c "
cd build/windows-x64-server-release/images/jdk
zip -r ${{ steps.artifact_name.outputs.artifact }} *
"
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.artifact_name.outputs.artifact }}
path: build/windows-x64-server-release/images/jdk/${{ steps.artifact_name.outputs.artifact }}
Explanation
-
Trigger:
- Manual trigger (
workflow_dispatch) with inputs for all your parameters.
- Auto trigger on push to
main branch.
-
Inputs:
ref: branch/tag/commit to checkout (default: master).
disable_warnings_as_errors: checkbox boolean.
debug_level: choice with default release.
boot_jdk_provider: choice with default Adoptium.
boot_jdk_version: default 21.
extra_configure_flags: optional string.
artifact_name: optional string, defaults to ${repo}-${branch}-windows-x64.zip.
-
Steps:
- Checkout the specified ref.
- Install Cygwin with required packages.
- Download Boot JDK from Adoptium (extendable for other providers).
- Run configure and build inside Cygwin bash shell.
- Package the built JDK into a zip artifact.
- Upload the artifact.
Notes
- You may want to customize the Boot JDK download URLs for other providers.
- The build directory path (
build/windows-x64-server-release/images/jdk) assumes a typical OpenJDK build output; adjust if your build system differs.
- Cygwin installation is done every run here for simplicity; consider caching or pre-installed runners if build time is critical.
- The
configure and make commands run inside Cygwin bash shell to simulate a Unix-like environment on Windows.
If you want me to help customize or extend this further, just ask!