Below is a ready-to-drop-in workflow file (e.g. .github/workflows/build-jdk-windows.yml).
It does exactly what you asked:
• Runs on Windows x64, installs Cygwin, builds OpenJDK, uploads the built image as an artifact.
• Can be triggered manually (workflow _dispatch) or whenever you sync/push to your “up-stream” (push to master/main – tweak if you want another trigger).
• All requested inputs with sensible defaults (branch/tag/SHA, debug-level, boot-JDK provider & version, extra flags, “disable-warnings-as-errors”, artifact name).
• If no artifact name is given it automatically becomes --windows-x64.
# File: .github/workflows/build-jdk-windows.yml
name: Build OpenJDK (Windows x64)
on:
# 1) Manual trigger
workflow_dispatch:
inputs:
ref:
description: 'Branch / tag / commit SHA to build'
default: 'master'
required: false
disable_warnings_as_errors:
description: 'Add --disable-warnings-as-errors to configure'
type: boolean
default: false
debug_level:
description: 'Debug level'
type: choice
options: [ release, optimized, fastdebug, slowdebug ]
default: release
boot_jdk_provider:
description: 'Boot JDK provider (Adoptium, Zulu, …)'
default: 'Adoptium'
required: false
boot_jdk_version:
description: 'Boot JDK major version (e.g. 21)'
default: '21'
required: false
extra_configure_flags:
description: 'Extra ./configure flags (optional)'
default: ''
required: false
artifact_name:
description: 'Override artifact file name (optional)'
default: ''
required: false
# 2) Automatic build when the fork is synchronised / code is updated
push:
branches: [ master, main ]
jobs:
build:
name: Build JDK (Windows x64 w/ Cygwin)
runs-on: windows-latest
env:
# Re-usable environment variables
DEBUG_LEVEL: ${{ inputs.debug_level || 'release' }}
BOOT_JDK_VERSION: ${{ inputs.boot_jdk_version || 21 }}
BOOT_JDK_PROVIDER: ${{ inputs.boot_jdk_provider || 'Adoptium' }}
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || 'master' }}
submodules: recursive
# ------------------------------------------------------------
# Install Cygwin and the toolchain required for building JDK
# ------------------------------------------------------------
- name: Install Cygwin & packages
run: |
choco install -y cygwin
choco install -y cyg-get
cyg-get wget unzip zip make autoconf mercurial \
gcc-g++ pkg-config zip \
file git
# ------------------------------------------------------------
# Download Boot JDK
# ------------------------------------------------------------
- name: Resolve boot-JDK URL
id: bootjdk
shell: bash
run: |
# Currently supports Adoptium or generic URL override
PROVIDER=${{ env.BOOT_JDK_PROVIDER,, }} # to lower case
VERSION=${{ env.BOOT_JDK_VERSION }}
if [[ "$PROVIDER" == "adoptium" ]]; then
URL="https://api.adoptium.net/v3/binary/latest/${VERSION}/ga/windows/x64/jdk/hotspot/normal/eclipse?project=jdk"
else
echo "::warning::Unknown provider '$PROVIDER', please edit workflow."
exit 1
fi
echo "url=$URL" >> $GITHUB_OUTPUT
- name: Download & extract boot-JDK
shell: powershell
run: |
curl -L -o bootjdk.zip "${{ steps.bootjdk.outputs.url }}"
7z x bootjdk.zip -o"$env:USERPROFILE\bootjdk" -y
echo "BOOT_JDK=$env:USERPROFILE\bootjdk" | Out-File -FilePath $env:GITHUB_ENV -Append
# ------------------------------------------------------------
# Build OpenJDK
# ------------------------------------------------------------
- name: Configure
shell: C:\cygwin64\bin\bash.exe -l -eo pipefail -c "bash {0}"
run: |
set -eux
cd "$GITHUB_WORKSPACE"
export PATH="$PATH:$BOOT_JDK/bin"
FLAGS="--with-boot-jdk=$BOOT_JDK --with-debug-level=${DEBUG_LEVEL}"
if [[ "${{ inputs.disable_warnings_as_errors }}" == "true" ]]; then
FLAGS="$FLAGS --disable-warnings-as-errors"
fi
if [[ -n "${{ inputs.extra_configure_flags }}" ]]; then
FLAGS="$FLAGS ${{ inputs.extra_configure_flags }}"
fi
bash ./configure $FLAGS
- name: Build (make images)
shell: C:\cygwin64\bin\bash.exe -l -eo pipefail -c "bash {0}"
run: |
set -eux
cd "$GITHUB_WORKSPACE"
make images
# ------------------------------------------------------------
# Decide artifact name (override or default)
# ------------------------------------------------------------
- name: Compute artifact name
id: artname
shell: bash
run: |
if [[ -n "${{ inputs.artifact_name }}" ]]; then
echo "name=${{ inputs.artifact_name }}" >> $GITHUB_OUTPUT
else
REF="${{ inputs.ref || 'master' }}"
REF=${REF//\//-} # replace '/' with '-' for nice file names
echo "name=${{ github.event.repository.name }}-${REF}-windows-x64" >> $GITHUB_OUTPUT
fi
# ------------------------------------------------------------
# Upload the build (images are placed under build/<conf>/images)
# ------------------------------------------------------------
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artname.outputs.name }}
path: build/windows-*-*/images/**/*
retention-days: 30
How to use
Manual run
• Click Actions → “Build OpenJDK (Windows x64)” → “Run workflow”.
• Fill in / tweak the inputs, or just hit Run to accept the defaults (master branch, release build, Boot JDK 21 from Adoptium, no extra flags).
Automatic run
• Whenever you push to master or main (or change those branches via sync), the build will kick off automatically.
Things you may still want to customise
- Extra Cygwin packages (depending on how exotic your build is).
- Another boot-JDK provider (add a new case in the “Resolve boot-JDK URL” step).
- Change branch filters under on.push if you track other branches.
Have fun compiling 🌟