Skip to content

Build Windows Release #12

Build Windows Release

Build Windows Release #12

name: Build Windows Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g. v1.5.1)'
required: true
default: 'v1.5.1'
release_notes:
description: 'Release notes'
required: false
default: |
## Release notes
-
permissions:
contents: write
id-token: write
attestations: write
jobs:
build-windows:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: goshujinsama
- name: Set tag name
id: tag
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "TAG=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "TAG=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
fi
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
enable-cache: "auto"
- name: Install project dependencies
shell: cmd
env:
UV_HTTP_CONNECT_TIMEOUT: "15"
UV_HTTP_TIMEOUT: "45"
UV_HTTP_RETRIES: "10"
run: uv --project . sync
- name: Download libvips v8.18.2 (win64 all)
shell: pwsh
run: |
$url = "https://github.com/libvips/build-win64-mxe/releases/download/v8.18.2/vips-dev-x64-web-8.18.2-static-ffi.zip"
Invoke-WebRequest -Uri $url -OutFile "vips.zip"
- name: Extract required libvips DLLs into src\
shell: pwsh
run: |
$needed = @(
"libglib-2.0-0.dll",
"libgobject-2.0-0.dll",
"libvips-42.dll",
"libvips-cpp-42.dll"
)
Add-Type -AssemblyName System.IO.Compression.FileSystem
$zip = [System.IO.Compression.ZipFile]::OpenRead("vips.zip")
foreach ($entry in $zip.Entries) {
# Files live at vips-dev-8.18/bin/<name>.dll inside the zip
if ($entry.FullName -like "vips-dev-8.18/bin/*") {
$file = [System.IO.Path]::GetFileName($entry.FullName)
if ($needed -contains $file) {
$dest = Join-Path "src" $file
Write-Host "Extracting $($entry.FullName) -> $dest"
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $dest, $true)
}
}
}
$zip.Dispose()
- name: Verify DLLs are present
shell: pwsh
run: |
$needed = @(
"src\libglib-2.0-0.dll",
"src\libgobject-2.0-0.dll",
"src\libvips-42.dll",
"src\libvips-cpp-42.dll"
)
foreach ($f in $needed) {
if (-not (Test-Path $f)) { Write-Error "Missing: $f"; exit 1 }
Write-Host "OK: $f ($('{0:N0}' -f (Get-Item $f).Length) bytes)"
}
- name: Build with Nuitka
shell: cmd
env:
NUITKA_ALLOW_DOWNLOADS: "1"
run: |
uv --project . run python -m nuitka ^
--mode=standalone ^
--lto=yes ^
--assume-yes-for-downloads ^
--output-dir=build ^
--follow-imports ^
--nofollow-import-to=tkinter ^
--nofollow-import-to=pillow ^
--windows-console-mode=attach ^
--windows-icon-from-ico=.\src\icon.png ^
--include-module=wx._xml ^
--include-data-file=.\src\icon.png=icon.png ^
--include-data-file=.\src\libglib-2.0-0.dll=libglib-2.0-0.dll ^
--include-data-file=.\src\libgobject-2.0-0.dll=libgobject-2.0-0.dll ^
--include-data-file=.\src\libvips-42.dll=libvips-42.dll ^
--include-data-file=.\src\libvips-cpp-42.dll=libvips-cpp-42.dll ^
--include-data-dir=.\src\filters=filters ^
--include-data-dir=.\src\locale=locale ^
.\src\wxReader.py
- name: Package release ZIP
shell: pwsh
run: |
$tag = "${{ steps.tag.outputs.TAG }}"
$zipName = "wxReader_${tag}_msvc_x64.zip"
# Nuitka puts the dist folder at build\wxReader.dist
Compress-Archive -Path "build\wxReader.dist\*" -DestinationPath $zipName
Write-Host "Created: $zipName ($('{0:N0}' -f (Get-Item $zipName).Length) bytes)"
echo "ZIP_NAME=$zipName" >> $env:GITHUB_ENV
- name: Generate SHA256 checksum
shell: pwsh
run: |
$hash = Get-FileHash "${{ env.ZIP_NAME }}" -Algorithm SHA256
$checksumFile = "${{ env.ZIP_NAME }}.sha256"
"$($hash.Hash.ToLower()) ${{ env.ZIP_NAME }}" | Out-File -Encoding ascii $checksumFile
echo "CHECKSUM_NAME=$checksumFile" >> $env:GITHUB_ENV
- name: Attest release artifact
uses: actions/attest-build-provenance@v2
with:
subject-path: ${{ env.ZIP_NAME }}
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.TAG }}
name: wxReader ${{ steps.tag.outputs.TAG }}
draft: false
prerelease: false
body: ${{ github.event.inputs.release_notes }}
files: |
${{ env.ZIP_NAME }}
${{ env.CHECKSUM_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}