Make workflow for github action to build Java jdk for Windows x64. After completing the building, it should upload the artifact. I want to run workflow myself or when syncing with the main repo. Building should work with using cygwin.
It should have input for branch name or tag or commit SHA. Checkbox for adding --disable-warnings-as-errors as configure flag, choose of what build debug level i want (release, optimized, fast debug, slowdebug, etc.), input for boot jdk provider, input for boot jdk version, optional input for extra configure flags, and input for artifact name.
All should have a default:
input for branch and e.g. - master
Boot jdk version - 21
Boot jdk provider - Adoptium
build debug level - release
Optional configure flags should be empty
build artifact name should have default to (repo name)-(branch name)-windows-x64
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Below is a GitHub Actions workflow that meets your requirements for building a Java JDK on Windows x64 using Cygwin, with the ability to upload the resulting artifact. The workflow can be triggered manually or when syncing with the main repository. It includes all the requested inputs with defaults, and it uses Cygwin for the build process.
name: Build Java JDK for Windows x64
on:
workflow_dispatch: # Allows manual triggering
inputs:
branch_or_tag_or_sha:
description: 'Branch, tag, or commit SHA to build'
required: true
default: 'master'
disable_warnings_as_errors:
description: 'Add --disable-warnings-as-errors to configure flags'
type: boolean
default: false
build_debug_level:
description: 'Build debug level (release, optimized, fastdebug, slowdebug)'
type: choice
options:
- release
- optimized
- fastdebug
- slowdebug
default: 'release'
boot_jdk_provider:
description: 'Boot JDK provider (e.g., Adoptium, Oracle, etc.)'
required: true
default: 'Adoptium'
boot_jdk_version:
description: 'Boot JDK version (e.g., 21)'
required: true
default: '21'
extra_configure_flags:
description: 'Optional extra configure flags'
required: false
default: ''
artifact_name:
description: 'Name of the build artifact'
required: true
default: '${{ github.event.repository.name }}-${{ github.event.inputs.branch_or_tag_or_sha || github.ref_name }}-windows-x64'
push: # Trigger on push to main branch for syncing
branches:
- main
jobs:
build-jdk:
runs-on: windows-latest
steps:
# Checkout the repository at the specified branch, tag, or commit SHA
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch_or_tag_or_sha || github.ref }}
# Set up Cygwin
- name: Install Cygwin
uses: cygwin/cygwin-install-action@v4
with:
platform: x64
packages: >-
autoconf,automake,binutils,cmake,gcc-core,gcc-g++,git,libtool,make,mingw64-x86_64-gcc-core,
mingw64-x86_64-gcc-g++,patch,unzip,zip,wget,libiconv-devel,libpng-devel,libjpeg-devel,
freetype-devel,libX11-devel,libXext-devel,libXrender-devel,libXt-devel,libXtst-devel
# Set up Boot JDK
- name: Set up Boot JDK
uses: actions/setup-java@v4
with:
distribution: ${{ github.event.inputs.boot_jdk_provider || 'adopt' }}
java-version: ${{ github.event.inputs.boot_jdk_version || '21' }}
# Configure the build
- name: Configure JDK build
shell: bash
run: |
# Prepare configure flags
CONFIGURE_FLAGS="--with-debug-level=${{ github.event.inputs.build_debug_level || 'release' }}"
# Add --disable-warnings-as-errors if checkbox is checked
if [ "${{ github.event.inputs.disable_warnings_as_errors }}" = "true" ]; then
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --disable-warnings-as-errors"
fi
# Add extra configure flags if provided
if [ -n "${{ github.event.inputs.extra_configure_flags }}" ]; then
CONFIGURE_FLAGS="$CONFIGURE_FLAGS ${{ github.event.inputs.extra_configure_flags }}"
fi
# Run configure in Cygwin
bash configure \
--with-boot-jdk="$JAVA_HOME" \
$CONFIGURE_FLAGS
# Build the JDK
- name: Build JDK
shell: bash
run: |
make images
# Prepare artifact
- name: Prepare artifact
shell: bash
run: |
# Assuming the build output is in 'build/windows-x64-server-release/images/jdk'
ARTIFACT_DIR="build/windows-x64-server-${{ github.event.inputs.build_debug_level || 'release' }}/images/jdk"
if [ -d "$ARTIFACT_DIR" ]; then
# Create a zip file of the JDK
zip -r jdk-windows-x64.zip "$ARTIFACT_DIR"
else
echo "Build output directory not found!"
exit 1
fi
# Upload artifact
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.inputs.artifact_name || format('{0}-{1}-windows-x64', github.event.repository.name, github.event.inputs.branch_or_tag_or_sha || github.ref_name) }}
path: jdk-windows-x64.zip
Explanation of the Workflow
Triggers:
workflow_dispatch: Allows manual triggering of the workflow with inputs for branch, tag, or commit SHA, and other options.
push: Automatically triggers the workflow when changes are pushed to the main branch, useful for syncing with the main repository.
Inputs:
branch_or_tag_or_sha: Input for the branch, tag, or commit SHA to build, defaulting to master.
disable_warnings_as_errors: A checkbox to add --disable-warnings-as-errors to the configure flags, defaulting to false.
build_debug_level: A dropdown to choose the build debug level, defaulting to release.
boot_jdk_provider: Input for the boot JDK provider, defaulting to Adoptium.
boot_jdk_version: Input for the boot JDK version, defaulting to 21.
extra_configure_flags: Optional input for extra configure flags, defaulting to empty.
artifact_name: Input for the artifact name, defaulting to (repo name)-(branch name)-windows-x64.
Steps:
Checkout repository: Uses actions/checkout to check out the repository at the specified branch, tag, or commit SHA.
Install Cygwin: Uses cygwin/cygwin-install-action to set up Cygwin with necessary packages for building the JDK.
Set up Boot JDK: Uses actions/setup-java to set up the boot JDK based on the provider and version inputs.
Configure JDK build: Runs the configure script with the specified flags, including debug level, boot JDK, and optional flags.
Build JDK: Runs make images to build the JDK.
Prepare artifact: Zips the build output (assumed to be in build/windows-x64-server-<debug-level>/images/jdk).
Upload artifact: Uploads the zipped artifact with the specified name.
Default Artifact Name:
The artifact name defaults to (repo name)-(branch name)-windows-x64, dynamically constructed using GitHub context variables.
How to Use the Workflow
Add the Workflow File:
Create a file named .github/workflows/build-jdk-windows.yml in your repository and paste the above content.
Run the Workflow Manually:
Go to the "Actions" tab in your GitHub repository.
Select the "Build Java JDK for Windows x64" workflow.
Click "Run workflow" and fill in the input fields as needed, or use the defaults.
Syncing with Main:
The workflow will automatically run when changes are pushed to the main branch.
Download Artifacts:
After the workflow completes, go to the workflow run summary page to download the uploaded artifact.
Notes
Cygwin: The workflow uses Cygwin for building, as requested. Ensure your repository is compatible with building in a Cygwin environment.
Boot JDK: The actions/setup-java action supports various JDK providers (e.g., Adoptium, Oracle). Make sure the provider and version you specify are valid.
Build Output: The workflow assumes the build output is in build/windows-x64-server-<debug-level>/images/jdk. Adjust the path in the "Prepare artifact" step if your repository uses a different structure.
Error Handling: Basic error handling is included (e.g., checking if the build output directory exists). You may want to add more robust error handling depending on your needs.
This workflow provides a flexible and reusable way to build and distribute Java JDK artifacts for Windows x64.