Skip to content

Commit 649ac5b

Browse files
committed
Add MinGW workflow action
1 parent 2d7075f commit 649ac5b

File tree

4 files changed

+228
-0
lines changed

4 files changed

+228
-0
lines changed

.github/mingw-build.sh

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/bin/bash
2+
3+
buildCyanrip() {
4+
cyan_prepare
5+
build_curl
6+
build_neon
7+
build_libmusicbrainz
8+
# build_libcoverart
9+
build_ffmpeg
10+
build_cyanrip
11+
}
12+
13+
cyan_prepare() {
14+
local rootdir="$(pwd)"
15+
CYANRIPREPODIR="${GITHUB_WORKSPACE:-$(realpath "$rootdir/..")}"
16+
CYANRIPINSTALLDIR="$(realpath "$rootdir/_install")"
17+
CYANRIPBUILDDIR="$(realpath "$rootdir/_build")"
18+
PKG_CONFIG_PATH=$CYANRIPINSTALLDIR/lib/pkgconfig:$PKG_CONFIG_PATH
19+
CPATH="$(cygpath -pm $CYANRIPINSTALLDIR/include:$MINGW_PREFIX/include)"
20+
LIBRARY_PATH="$(cygpath -pm $CYANRIPINSTALLDIR/lib:$MINGW_PREFIX/lib)"
21+
CPPFLAGS="-D_FORTIFY_SOURCE=0 -D__USE_MINGW_ANSI_STDIO=1"
22+
CFLAGS="-mthreads -mtune=generic -O2 -pipe"
23+
CXXFLAGS="${CFLAGS}"
24+
LDFLAGS="-pipe -static-libgcc -static-libstdc++"
25+
export CYANRIPREPODIR CYANRIPBUILDDIR CYANRIPINSTALLDIR PKG_CONFIG_PATH CPATH LIBRARY_PATH CPPFLAGS CFLAGS CXXFLAGS LDFLAGS
26+
mkdir -p "$CYANRIPBUILDDIR" "$CYANRIPINSTALLDIR"
27+
28+
cyan_do_hide_all_sharedlibs
29+
}
30+
31+
cyan_do_vcs() {
32+
local vcsURL=${1#*::} vcsFolder=$2
33+
local vcsBranch=${vcsURL#*#} ref=origin/HEAD
34+
: "${vcsFolder:=$(basename "$vcsURL" .git)}"
35+
36+
cd "$CYANRIPBUILDDIR"
37+
git clone --depth 1 "$vcsURL" "$vcsFolder"
38+
cd "$vcsFolder"
39+
}
40+
41+
cyan_do_hide_all_sharedlibs() {
42+
local files
43+
files="$(find /mingw{32,64}/lib /mingw{32/i686,64/x86_64}-w64-mingw32/lib -name "*.dll.a" 2> /dev/null)"
44+
local tomove=()
45+
for file in $files; do
46+
[[ -f ${file%*.dll.a}.a ]] && tomove+=("$file")
47+
done
48+
printf '%s\0' "${tomove[@]}" | xargs -0ri mv -f '{}' '{}.dyn'
49+
}
50+
51+
cyan_hide_files() {
52+
for opt; do [[ -f $opt ]] && mv -f "$opt" "$opt.bak"; done
53+
}
54+
cyan_hide_conflicting_libs() {
55+
local -a installed
56+
mapfile -t installed < <(find "$CYANRIPINSTALLDIR/lib" -maxdepth 1 -name "*.a")
57+
cyan_hide_files "${installed[@]//$CYANRIPINSTALLDIR/$MINGW_PREFIX}"
58+
}
59+
60+
cyan_do_separate_confmakeinstall() {
61+
rm -rf ./_build &&
62+
mkdir _build && cd _build &&
63+
../configure --disable-shared --enable-static --prefix="$CYANRIPINSTALLDIR" "$@" &&
64+
make && make install
65+
}
66+
67+
cyan_do_cmakeinstall() {
68+
PKG_CONFIG=pkg-config cmake -B _build -G Ninja -DBUILD_SHARED_LIBS=off \
69+
-DCMAKE_INSTALL_PREFIX="$CYANRIPINSTALLDIR" -DUNIX=on \
70+
-DCMAKE_FIND_ROOT_PATH="$(cygpath -pm "$CYANRIPINSTALLDIR:$MINGW_PREFIX:$MINGW_PREFIX/$MINGW_CHOST")" \
71+
-DCMAKE_PREFIX_PATH="$(cygpath -pm "$CYANRIPINSTALLDIR:$MINGW_PREFIX:$MINGW_PREFIX/$MINGW_CHOST")" \
72+
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
73+
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
74+
-DCMAKE_BUILD_TYPE=Release "$@" &&
75+
ninja -C _build && ninja -C _build install
76+
}
77+
78+
build_curl() {
79+
cyan_do_vcs "https://github.com/curl/curl.git" &&
80+
autoreconf -fi &&
81+
sed -ri "s;(^SUBDIRS = lib) src (include) scripts;\1 \2;" Makefile.in &&
82+
CPPFLAGS+=" -DNGHTTP2_STATICLIB" \
83+
cyan_do_separate_confmakeinstall --with-{winssl,winidn,nghttp2} \
84+
--without-{ssl,gnutls,mbedtls,libssh2,random,ca-bundle,ca-path,librtmp,brotli,debug,libpsl}
85+
}
86+
87+
build_neon() {
88+
cyan_do_vcs "https://github.com/notroj/neon.git" &&
89+
./autogen.sh &&
90+
cyan_do_separate_confmakeinstall --disable-{nls,debug,webdav}
91+
}
92+
93+
build_libmusicbrainz() {
94+
cyan_do_vcs "https://github.com/wiiaboo/libmusicbrainz.git" &&
95+
cyan_do_cmakeinstall
96+
}
97+
98+
build_libcoverart() {
99+
cyan_do_vcs "https://github.com/wiiaboo/libcoverart.git" &&
100+
cyan_do_cmakeinstall
101+
}
102+
103+
build_ffmpeg() {
104+
cyan_do_vcs "https://git.ffmpeg.org/ffmpeg.git"
105+
cyan_do_separate_confmakeinstall --pkg-config-flags=--static \
106+
--disable-{programs,devices,filters,decoders,hwaccels,encoders,muxers} \
107+
--disable-{debug,protocols,demuxers,parsers,doc,swscale,postproc,network} \
108+
--disable-{avdevice,autodetect} \
109+
--disable-bsfs --enable-protocol=file \
110+
--enable-encoder=flac,tta,aac,wavpack,alac,pcm_s16le,pcm_s32le \
111+
--enable-muxer=flac,tta,ipod,wv,mp3,opus,ogg,wav,pcm_s16le,pcm_s32le \
112+
--enable-parser=png,mjpeg --enable-decoder=mjpeg,png \
113+
--enable-demuxer=image2,png_pipe,bmp_pipe \
114+
--enable-{bzlib,zlib,lzma,iconv} \
115+
--enable-filter=hdcd \
116+
--enable-lib{mp3lame,vorbis,opus} \
117+
--enable-encoder={libmp3lame,libvorbis,libopus}
118+
}
119+
120+
build_cyanrip() {
121+
cd "$CYANRIPREPODIR"
122+
cyan_hide_conflicting_libs
123+
PKG_CONFIG=pkg-config \
124+
CFLAGS+=" -DLIBXML_STATIC -DCURL_STATICLIB $(printf ' -I%s' "$(cygpath -m "$CYANRIPINSTALLDIR/include")")" \
125+
LDFLAGS+="$(printf ' -L%s' "$(cygpath -m "$CYANRIPINSTALLDIR/lib")")" \
126+
meson build --default-library=static --buildtype=release --prefix="$CYANRIPINSTALLDIR" --backend=ninja &&
127+
ninja -C build && strip --strip-all build/src/cyanrip.exe -o cyanrip.exe
128+
}
129+
130+
cd "$(dirname "$0")"
131+
buildCyanrip

.github/workflows/main.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, workflow ]
6+
release:
7+
types: [ released ]
8+
9+
jobs:
10+
mingw:
11+
runs-on: windows-latest
12+
env:
13+
MSYSTEM: MINGW64
14+
defaults:
15+
run:
16+
shell: msys2 {0}
17+
steps:
18+
- uses: actions/checkout@v2
19+
- uses: msys2/setup-msys2@v2
20+
with:
21+
install: git base-devel zip mingw-w64-x86_64-toolchain mingw-w64-x86_64-meson mingw-w64-x86_64-ninja mingw-w64-x86_64-cmake mingw-w64-x86_64-nasm mingw-w64-x86_64-libcdio-paranoia mingw-w64-x86_64-opus mingw-w64-x86_64-lame mingw-w64-x86_64-libvorbis mingw-w64-x86_64-libxml2 mingw-w64-x86_64-nghttp2
22+
update: true
23+
24+
- name: Build
25+
run: |
26+
.github/mingw-build.sh
27+
zip cyanrip cyanrip.exe
28+
29+
- name: "Upload artifact"
30+
uses: actions/upload-artifact@v2
31+
with:
32+
name: cyanrip
33+
path: cyanrip.exe
34+
35+
- name: Get Release
36+
id: get_release
37+
shell: bash
38+
run: |
39+
echo "::set-output name=upload_url_release::$(curl -sL https://api.github.com/repos/${{ github.repository }}/releases/tags/$(cut -d/ -f3 <<< ${{ github.ref }}) | jq -r ."upload_url")"
40+
echo "::set-output name=upload_url_nightly::$(curl -sL https://api.github.com/repos/${{ github.repository }}/releases/tags/nightly | jq -r ."upload_url")"
41+
echo "::set-output name=nightly_id::$(curl -sL https://api.github.com/repos/${{ github.repository }}/releases/tags/nightly | jq -r ."id")"
42+
43+
- name: Upload a Release Asset
44+
if: steps.get_release.outputs.upload_url_release != 'null'
45+
uses: actions/[email protected]
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
with:
49+
upload_url: ${{ steps.get_release.outputs.upload_url_release }}
50+
asset_path: ./cyanrip.exe
51+
asset_name: cyanrip-win64.exe
52+
asset_content_type: application/vnd.microsoft.portable-executable
53+
54+
- name: Upload versioned Nightly asset
55+
if: steps.get_release.outputs.upload_url_release == 'null' && steps.get_release.outputs.upload_url_nightly != 'null'
56+
uses: WebFreak001/[email protected]
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
with:
60+
upload_url: ${{ steps.get_release.outputs.upload_url_nightly }}
61+
release_id: ${{ steps.get_release.outputs.nightly_id }}
62+
asset_path: ./cyanrip.exe
63+
asset_name: cyanrip-win64-$$.exe
64+
asset_content_type: application/vnd.microsoft.portable-executable
65+
max_releases: 4
66+
67+
- name: Delete existing nightly latest
68+
id: del_nightly_release
69+
if: steps.get_release.outputs.upload_url_release == 'null' && steps.get_release.outputs.upload_url_nightly != 'null'
70+
uses: mknejp/delete-release-assets@v1
71+
with:
72+
token: ${{ secrets.GITHUB_TOKEN }}
73+
tag: nightly
74+
assets: cyanrip-win64-latest.exe
75+
fail-if-no-assets: false
76+
77+
- name: Upload latest Nightly Asset
78+
if: steps.del_nightly_release.conclusion == 'success' && steps.get_release.outputs.upload_url_nightly != 'null'
79+
uses: actions/[email protected]
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
with:
83+
upload_url: ${{ steps.get_release.outputs.upload_url_nightly }}
84+
asset_path: ./cyanrip.exe
85+
asset_name: cyanrip-win64-latest.exe
86+
asset_content_type: application/vnd.microsoft.portable-executable

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
build
22
*.log
3+
.github/_build
4+
.github/_install

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ All are available on any up-to-date Linux distribution's package repositories. T
3737
cyanrip can be also built and ran under Windows using MinGW
3838

3939

40+
Automated Windows builds ![Windows CI](https://github.com/cyanreg/cyanrip/workflows/CI/badge.svg)
41+
--------------
42+
[Latest release Windows build](https://github.com/cyanreg/cyanrip/releases/latest/download/cyanrip-win64.exe)
43+
44+
[Latest Windows build](https://github.com/cyanreg/cyanrip/releases/download/nightly/cyanrip-win64-latest.exe)
45+
46+
If the latest build is broken, you can find older ones in the [nightly release page](https://github.com/cyanreg/cyanrip/releases/tag/nightly)
47+
48+
4049
CLI
4150
---
4251
Arguments are optional. By default cyanrip will rip all tracks from the default CD drive, output to flac only, enables all cd-paranoia error checking and performs a MusicBrainz lookup.

0 commit comments

Comments
 (0)