Skip to content

Commit 8961a5c

Browse files
SakuzySakuzy
authored andcommitted
ci: add audiowmark windows release workflow
1 parent 1002b8b commit 8961a5c

File tree

1 file changed

+270
-0
lines changed

1 file changed

+270
-0
lines changed
Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
name: Build audiowmark Windows Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: "Release tag (e.g. audiowmark-win-2026-02-03)"
8+
required: true
9+
prerelease:
10+
description: "Mark as prerelease"
11+
type: boolean
12+
default: false
13+
14+
jobs:
15+
build-windows:
16+
runs-on: windows-latest
17+
timeout-minutes: 120
18+
permissions:
19+
contents: write
20+
defaults:
21+
run:
22+
shell: msys2 {0}
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Set up MSYS2
28+
uses: msys2/setup-msys2@v2
29+
with:
30+
msystem: MINGW64
31+
update: true
32+
path-type: inherit
33+
install: >-
34+
git
35+
make
36+
autoconf
37+
automake
38+
libtool
39+
pkgconf
40+
ccache
41+
zip
42+
mingw-w64-x86_64-toolchain
43+
mingw-w64-x86_64-cmake
44+
mingw-w64-x86_64-pkgconf
45+
mingw-w64-x86_64-fftw
46+
mingw-w64-x86_64-libsndfile
47+
mingw-w64-x86_64-libgcrypt
48+
mingw-w64-x86_64-mpg123
49+
mingw-w64-x86_64-opus
50+
mingw-w64-x86_64-libogg
51+
mingw-w64-x86_64-libvorbis
52+
mingw-w64-x86_64-flac
53+
mingw-w64-x86_64-zlib
54+
mingw-w64-x86_64-libiconv
55+
mingw-w64-x86_64-gettext
56+
57+
- name: Cache ccache
58+
uses: actions/cache@v4
59+
with:
60+
path: ${{ github.workspace }}/.ccache
61+
key: ccache-windows-${{ hashFiles('.github/workflows/build-audiowmark-windows-release.yml') }}
62+
restore-keys: |
63+
ccache-windows-
64+
65+
- name: Build zita-resampler
66+
run: |
67+
set -euo pipefail
68+
export PATH="/mingw64/bin:/usr/bin:$PATH"
69+
WORKSPACE_POSIX="$(cygpath -u "$GITHUB_WORKSPACE")"
70+
export CCACHE_DIR="$WORKSPACE_POSIX/.ccache"
71+
mkdir -p "$CCACHE_DIR"
72+
ccache -M 2G
73+
export CC="ccache x86_64-w64-mingw32-gcc"
74+
export CXX="ccache x86_64-w64-mingw32-g++"
75+
76+
cd /tmp
77+
git clone --depth 1 https://github.com/digital-stage/zita-resampler.git
78+
cd zita-resampler
79+
80+
# Build shared library
81+
sed -i 's/add_library(zita-resampler/add_library(zita-resampler SHARED/' CMakeLists.txt
82+
83+
mkdir -p build && cd build
84+
cmake .. -G "MSYS Makefiles" \
85+
-DCMAKE_BUILD_TYPE=Release \
86+
-DCMAKE_INSTALL_PREFIX=/mingw64 \
87+
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
88+
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++
89+
make -j"$(nproc)"
90+
91+
echo "=== Build artifacts ==="
92+
ls -lh | grep -E "(dll|a)$" || echo "No DLL/A files in build dir"
93+
94+
if [ -f "libzita-resampler.dll" ]; then
95+
cp libzita-resampler.dll /mingw64/bin/
96+
echo "✓ Copied libzita-resampler.dll"
97+
elif [ -f "zita-resampler.dll" ]; then
98+
cp zita-resampler.dll /mingw64/bin/
99+
echo "✓ Copied zita-resampler.dll"
100+
else
101+
echo "ERROR: zita-resampler DLL not found"
102+
ls -lh
103+
exit 1
104+
fi
105+
106+
if [ -f "libzita-resampler.dll.a" ]; then
107+
cp libzita-resampler.dll.a /mingw64/lib/
108+
echo "✓ Copied libzita-resampler.dll.a"
109+
fi
110+
111+
mkdir -p /mingw64/include/zita-resampler
112+
cp ../source/zita-resampler/*.h /mingw64/include/zita-resampler/
113+
114+
mkdir -p /mingw64/lib/pkgconfig
115+
printf 'prefix=/mingw64\nexec_prefix=${prefix}\nlibdir=${exec_prefix}/lib\nincludedir=${prefix}/include\n\nName: libzita-resampler\nDescription: Zita resampler library\nVersion: 1.0\nLibs: -L${libdir} -lzita-resampler\nCflags: -I${includedir}\n' > /mingw64/lib/pkgconfig/libzita-resampler.pc
116+
117+
ccache -s
118+
echo "✓ zita-resampler build success"
119+
120+
- name: Build audiowmark
121+
run: |
122+
set -euo pipefail
123+
export PATH="/mingw64/bin:/usr/bin:$PATH"
124+
WORKSPACE_POSIX="$(cygpath -u "$GITHUB_WORKSPACE")"
125+
export CCACHE_DIR="$WORKSPACE_POSIX/.ccache"
126+
mkdir -p "$CCACHE_DIR"
127+
ccache -M 2G
128+
export CC="ccache x86_64-w64-mingw32-gcc"
129+
export CXX="ccache x86_64-w64-mingw32-g++"
130+
export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig:$PKG_CONFIG_PATH"
131+
export PKG_CONFIG="/mingw64/bin/pkg-config"
132+
export LDFLAGS="-L/mingw64/lib"
133+
export CPPFLAGS="-I/mingw64/include"
134+
135+
cd /tmp
136+
git clone --depth 1 https://github.com/swesterfeld/audiowmark.git
137+
cd audiowmark
138+
sed -i '1i#define _GNU_SOURCE' src/utils.cc
139+
python -c 'import textwrap; exec(textwrap.dedent("""
140+
from pathlib import Path
141+
import re
142+
143+
utils_path = Path("src/utils.cc")
144+
utils_text = utils_path.read_text()
145+
utils_text = utils_text.replace(
146+
"#include <sys/resource.h>\\n",
147+
"#if !defined(_WIN32)\\n#include <sys/resource.h>\\n#endif\\n",
148+
)
149+
def repl(match):
150+
original = match.group(0)
151+
stub = (
152+
"#else\\n"
153+
"void\\n"
154+
"print_memory_usage (const std::string& where)\\n"
155+
"{\\n"
156+
" (void) where;\\n"
157+
" printf (\\"=== memory usage (%s): unsupported on Windows ===\\\\n\\", where.c_str());\\n"
158+
"}\\n"
159+
"#endif\\n"
160+
)
161+
return "#if !defined(_WIN32)\\n" + original + stub
162+
utils_text = re.sub(
163+
r"void\\s*\\nprint_memory_usage\\s*\\([^\\)]*\\)\\s*\\{.*?\\n\\}\\n",
164+
repl,
165+
utils_text,
166+
count=1,
167+
flags=re.S,
168+
)
169+
utils_path.write_text(utils_text)
170+
171+
limiter_path = Path("src/limiter.hh")
172+
limiter_text = limiter_path.read_text()
173+
limiter_text = limiter_text.replace(
174+
"#include <sys/types.h>\\n",
175+
"#include <sys/types.h>\\n#if defined(_WIN32) && !defined(__CYGWIN__)\\ntypedef unsigned int uint;\\n#endif\\n",
176+
)
177+
limiter_path.write_text(limiter_text)
178+
179+
hls_path = Path("src/hls.cc")
180+
hls_text = hls_path.read_text()
181+
hls_text = hls_text.replace(
182+
"#include <sys/wait.h>\\n",
183+
"#if !defined(_WIN32)\\n#include <sys/wait.h>\\n#endif\\n",
184+
)
185+
hls_path.write_text(hls_text)
186+
187+
resample_path = Path("src/resample.cc")
188+
resample_text = resample_path.read_text()
189+
resample_text = resample_text.replace(
190+
"#include <math.h>\\n\\n#include <zita-resampler/resampler.h>\\n",
191+
"#include <math.h>\\n\\n#if defined(_WIN32) && !defined(__CYGWIN__)\\ntypedef unsigned int uint;\\n#endif\\n\\n#include <zita-resampler/resampler.h>\\n",
192+
)
193+
resample_path.write_text(resample_text)
194+
"""))'
195+
./autogen.sh
196+
197+
./configure \
198+
--host=x86_64-w64-mingw32 \
199+
--build=x86_64-w64-mingw32 \
200+
LDFLAGS="$LDFLAGS" \
201+
CPPFLAGS="$CPPFLAGS"
202+
203+
make -j"$(nproc)" V=1 \
204+
LDFLAGS="$LDFLAGS -lfftw3f -lsndfile -lmpg123 -lgcrypt -lzita-resampler" \
205+
LIBS="-lfftw3f -lsndfile -lmpg123 -lgcrypt -lzita-resampler"
206+
207+
if [ ! -f src/.libs/audiowmark.exe ]; then
208+
echo "ERROR: Real binary src/.libs/audiowmark.exe not found!"
209+
ls -la src/
210+
exit 1
211+
fi
212+
213+
ccache -s
214+
echo "✓ audiowmark build success"
215+
216+
- name: Collect dependencies
217+
run: |
218+
set -euo pipefail
219+
export PATH="/mingw64/bin:/usr/bin:$PATH"
220+
WORKSPACE_POSIX="$(cygpath -u "$GITHUB_WORKSPACE")"
221+
DIST_DIR="$WORKSPACE_POSIX/audiowmark-dist"
222+
mkdir -p "$DIST_DIR/bin"
223+
224+
cd /tmp/audiowmark
225+
cp src/.libs/audiowmark.exe "$DIST_DIR/bin/"
226+
227+
cd "$DIST_DIR/bin"
228+
DLLS=$(objdump -p audiowmark.exe | awk '/DLL Name/ {print $3}' | sort -u)
229+
for dll in $DLLS; do
230+
if [ -f "/mingw64/bin/$dll" ]; then
231+
cp "/mingw64/bin/$dll" .
232+
fi
233+
done
234+
235+
- name: Verify functionality
236+
run: |
237+
set -euo pipefail
238+
WORKSPACE_POSIX="$(cygpath -u "$GITHUB_WORKSPACE")"
239+
DIST_DIR="$WORKSPACE_POSIX/audiowmark-dist"
240+
export PATH="$DIST_DIR/bin:$PATH"
241+
242+
cd "$DIST_DIR/bin"
243+
./audiowmark.exe --version
244+
./audiowmark.exe gen-key test.key
245+
246+
- name: Package artifact
247+
run: |
248+
set -euo pipefail
249+
WORKSPACE_POSIX="$(cygpath -u "$GITHUB_WORKSPACE")"
250+
DIST_DIR="$WORKSPACE_POSIX/audiowmark-dist"
251+
cd "$DIST_DIR"
252+
zip -r "$WORKSPACE_POSIX/audiowmark-windows-x86_64.zip" .
253+
254+
- name: Ensure tag exists
255+
run: |
256+
set -euo pipefail
257+
TAG="${{ inputs.tag }}"
258+
git fetch --tags --force
259+
if ! git rev-parse "refs/tags/$TAG" >/dev/null 2>&1; then
260+
git tag "$TAG" "$GITHUB_SHA"
261+
git push origin "$TAG"
262+
fi
263+
264+
- name: Create GitHub release
265+
uses: softprops/action-gh-release@v1
266+
with:
267+
tag_name: ${{ inputs.tag }}
268+
name: ${{ inputs.tag }}
269+
prerelease: ${{ inputs.prerelease }}
270+
files: ${{ github.workspace }}/audiowmark-windows-x86_64.zip

0 commit comments

Comments
 (0)