-
Notifications
You must be signed in to change notification settings - Fork 1
169 lines (152 loc) · 5.44 KB
/
Copy pathbuild-windows-release.yml
File metadata and controls
169 lines (152 loc) · 5.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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 }}