furnace/.github/workflows/build.yml

344 lines
11 KiB
YAML
Raw Normal View History

2022-01-20 07:58:44 +00:00
name: Build furnace
on:
push:
branches: master
pull_request:
branches: master
defaults:
run:
shell: bash
env:
BUILD_TYPE: Release
2022-04-02 14:48:05 +00:00
WINDOWS_ARCH: x86
2022-01-20 07:58:44 +00:00
jobs:
# Do a plain build, like we would expect a user to do it on their end.
2022-01-20 07:58:44 +00:00
build:
strategy:
matrix:
config:
2022-04-01 00:55:20 +00:00
- { name: 'Windows MSVC', os: windows-latest, compiler: msvc }
- { name: 'Windows MinGW', os: ubuntu-20.04, compiler: mingw }
- { name: 'macOS', os: macos-latest }
- { name: 'Ubuntu', os: ubuntu-18.04 }
2022-01-20 07:58:44 +00:00
fail-fast: false
name: "Build: ${{ matrix.config.name }}"
2022-01-20 07:58:44 +00:00
runs-on: ${{ matrix.config.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
2022-04-02 14:48:05 +00:00
- name: Set Windows arch identifiers
id: windows-identify
if: ${{ matrix.config.compiler == 'msvc' || matrix.config.compiler == 'mingw' }}
run: |
vswhere_target="${{ env.WINDOWS_ARCH }}"
msvc_target="${{ env.WINDOWS_ARCH }}"
mingw_target="${{ env.WINDOWS_ARCH }}"
if [ '${{ env.WINDOWS_ARCH }}' == 'x86' ]; then
msvc_target="Win32"
elif [ '${{ env.WINDOWS_ARCH }}' == 'x86_64' ]; then
vswhere_target="amd64"
msvc_target="x64"
fi
if [ '${{ matrix.config.compiler }}' == 'msvc' ]; then
echo "vswhere target: ${vswhere_target}"
echo "MSVC target: ${msvc_target}"
else
echo "MinGW cross target: ${mingw_target}"
fi
echo "::set-output name=vswhere-target::${vswhere_target}"
echo "::set-output name=msvc-target::${msvc_target}"
echo "::set-output name=mingw-target::${mingw_target}"
2022-01-20 07:58:44 +00:00
- name: Setup Toolchain [Windows MSVC]
2022-04-01 00:55:20 +00:00
if: ${{ matrix.config.compiler == 'msvc' }}
2022-01-20 07:58:44 +00:00
uses: seanmiddleditch/gha-setup-vsdevenv@v3
2022-04-02 14:48:05 +00:00
with:
arch: ${{ steps.windows-identify.outputs.vswhere-target }}
2022-01-20 07:58:44 +00:00
- name: Setup Toolchain [Windows MinGW]
2022-04-01 00:55:20 +00:00
if: ${{ matrix.config.compiler == 'mingw' }}
run: |
sudo apt update
sudo apt install \
mingw-w64 \
mingw-w64-tools
2022-01-20 07:58:44 +00:00
- name: Install Dependencies [macOS]
if: ${{ runner.os == 'macOS' }}
run: |
export HOMEBREW_NO_INSTALL_CLEANUP=1
brew update
brew install \
pkg-config \
sdl2 \
libsndfile \
zlib \
jack
- name: Install Dependencies [Ubuntu]
2022-04-01 00:55:20 +00:00
if: ${{ runner.os == 'Linux' && matrix.config.compiler != 'mingw' }}
2022-01-20 07:58:44 +00:00
run: |
sudo apt update
sudo apt install \
libsdl2-dev \
libsndfile1-dev \
zlib1g-dev \
libjack-jackd2-dev
- name: Configure
run: |
export USE_WAE=ON
2022-01-20 07:58:44 +00:00
export CMAKE_EXTRA_ARGS=()
2022-04-01 00:55:20 +00:00
if [ '${{ matrix.config.compiler }}' == 'msvc' ]; then
2022-04-02 14:48:05 +00:00
CMAKE_EXTRA_ARGS+=('-DCMAKE_GENERATOR_PLATFORM=${{ steps.windows-identify.outputs.msvc-target }}')
2022-04-01 00:55:20 +00:00
# FIXME We don't want all the MSVC warnings to cause errors yet
export USE_WAE=OFF
elif [ '${{ matrix.config.compiler }}' == 'mingw' ]; then
2022-04-02 14:48:05 +00:00
CMAKE_EXTRA_ARGS+=('-DCMAKE_TOOLCHAIN_FILE=scripts/Cross-MinGW-${{ steps.windows-identify.outputs.mingw-target }}.cmake')
2022-01-20 07:58:44 +00:00
fi
cmake \
-B ${PWD}/build \
-DCMAKE_INSTALL_PREFIX=${PWD}/target \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DWARNINGS_ARE_ERRORS=${USE_WAE} \
2022-01-20 07:58:44 +00:00
"${CMAKE_EXTRA_ARGS[@]}"
- name: Build
run: |
export VERBOSE=1
cmake \
--build ${PWD}/build \
--config ${{ env.BUILD_TYPE }} \
--parallel 2
- name: Install
run: |
cmake \
--install ${PWD}/build \
--config ${{ env.BUILD_TYPE }}
# Now do a build that we can package. (static runtime linking on MSVC, zipping on Windows, CPack on Darwin, appimage stuff on Ubuntu)
# We rebuild here because the build dependencies may be slightly different and might trigger a full rebuild anyway.
package:
needs: build
strategy:
matrix:
config:
2022-04-01 00:55:20 +00:00
- { name: 'Windows MSVC', os: windows-latest, compiler: msvc }
- { name: 'Windows MinGW', os: ubuntu-20.04, compiler: mingw }
- { name: 'macOS', os: macos-latest }
- { name: 'Ubuntu', os: ubuntu-18.04 }
fail-fast: false
name: "Package: ${{ matrix.config.name }}"
runs-on: ${{ matrix.config.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
2022-04-02 14:48:05 +00:00
- name: Set Windows arch identifiers
id: windows-identify
if: ${{ matrix.config.compiler == 'msvc' || matrix.config.compiler == 'mingw' }}
run: |
vswhere_target="${{ env.WINDOWS_ARCH }}"
msvc_target="${{ env.WINDOWS_ARCH }}"
mingw_target="${{ env.WINDOWS_ARCH }}"
if [ '${{ env.WINDOWS_ARCH }}' == 'x86' ]; then
msvc_target="Win32"
elif [ '${{ env.WINDOWS_ARCH }}' == 'x86_64' ]; then
vswhere_target="amd64"
msvc_target="x64"
fi
if [ '${{ matrix.config.compiler }}' == 'msvc' ]; then
echo "vswhere target: ${vswhere_target}"
echo "MSVC target: ${msvc_target}"
else
echo "MinGW cross target: ${mingw_target}"
fi
echo "::set-output name=vswhere-target::${vswhere_target}"
echo "::set-output name=msvc-target::${msvc_target}"
echo "::set-output name=mingw-target::${mingw_target}"
- name: Setup Toolchain [Windows MSVC]
2022-04-01 00:55:20 +00:00
if: ${{ matrix.config.compiler == 'msvc' }}
uses: seanmiddleditch/gha-setup-vsdevenv@v3
2022-04-02 14:48:05 +00:00
with:
arch: ${{ steps.windows-identify.outputs.vswhere-target }}
- name: Setup Toolchain [Windows MinGW]
2022-04-01 00:55:20 +00:00
if: ${{ matrix.config.compiler == 'mingw' }}
run: |
sudo apt update
sudo apt install \
mingw-w64 \
mingw-w64-tools
- name: Install Dependencies [macOS]
if: ${{ runner.os == 'macOS' }}
run: |
export HOMEBREW_NO_INSTALL_CLEANUP=1
brew update
brew install \
pkg-config \
sdl2 \
libsndfile \
zlib \
jack
- name: Install Dependencies [Ubuntu]
2022-04-01 00:55:20 +00:00
if: ${{ runner.os == 'Linux' && matrix.config.compiler != 'mingw' }}
run: |
sudo apt update
sudo apt install \
libsdl2-dev \
libsndfile1-dev \
zlib1g-dev \
libjack-jackd2-dev \
appstream
wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
chmod +x appimagetool-x86_64.AppImage
2022-04-02 14:48:05 +00:00
- name: Set package identifier
id: package-identify
run: |
package_name="furnace-${GITHUB_SHA}"
package_ext=""
2022-04-01 00:55:20 +00:00
if [ '${{ runner.os }}' == 'Windows' ] || [ '${{ matrix.config.compiler }}' == 'mingw' ]; then
package_name="${package_name}-Windows"
if [ '${{ matrix.config.compiler }}' == 'mingw' ]; then
package_name="${package_name}-MinGW"
else
package_name="${package_name}-MSVC"
fi
package_ext="" # Directory, uploading will automatically zip it
elif [ '${{ runner.os }}' == 'macOS' ]; then
package_name="${package_name}-macOS"
package_ext=".dmg"
else
package_name="${package_name}-Linux"
package_ext=".AppImage"
fi
2022-04-02 14:48:05 +00:00
echo "Package identifier: ${package_name}"
echo "Package file: ${package_name}${package_ext}"
echo "::set-output name=id::${package_name}"
echo "::set-output name=filename::${package_name}${package_ext}"
- name: Configure
run: |
export USE_WAE=ON
export CMAKE_EXTRA_ARGS=()
2022-04-01 00:55:20 +00:00
if [ '${{ matrix.config.compiler }}' == 'msvc' ]; then
2022-04-02 14:48:05 +00:00
CMAKE_EXTRA_ARGS+=('-DCMAKE_GENERATOR_PLATFORM=${{ steps.windows-identify.outputs.msvc-target }}')
2022-04-01 00:55:20 +00:00
# FIXME We don't want all the MSVC warnings to cause errors yet
export USE_WAE=OFF
# Force static linking
# 1. Make MSVC runtime configurable
CMAKE_EXTRA_ARGS+=('-DCMAKE_POLICY_DEFAULT_CMP0091=NEW')
# 2. Use static (debug) runtime
if [ '${{ env.BUILD_TYPE }}' == 'Debug' ]; then
CMAKE_EXTRA_ARGS+=('-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug')
else
CMAKE_EXTRA_ARGS+=('-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded')
fi
2022-04-01 00:55:20 +00:00
elif [ '${{ matrix.config.compiler }}' == 'mingw' ]; then
2022-04-02 14:48:05 +00:00
CMAKE_EXTRA_ARGS+=('-DCMAKE_TOOLCHAIN_FILE=scripts/Cross-MinGW-${{ steps.windows-identify.outputs.mingw-target }}.cmake')
elif [ '${{ runner.os }}' == 'macOS' ]; then
CMAKE_EXTRA_ARGS+=('-DCMAKE_OSX_DEPLOYMENT_TARGET="10.9"')
fi
cmake \
-B ${PWD}/build \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DWARNINGS_ARE_ERRORS=${USE_WAE} \
"${CMAKE_EXTRA_ARGS[@]}"
- name: Build
run: |
export VERBOSE=1
cmake \
--build ${PWD}/build \
--config ${{ env.BUILD_TYPE }} \
--parallel 2
- name: Package [Windows]
2022-04-01 00:55:20 +00:00
if: ${{ runner.os == 'Windows' || matrix.config.compiler == 'mingw' }}
run: |
binPath=build
if [ '${{ matrix.config.compiler }}' == 'msvc' ]; then
binPath="${binPath}/${{ env.BUILD_TYPE }}"
fi
2022-04-01 00:55:20 +00:00
if [ '${{ matrix.config.compiler }}' == 'mingw' ] && [ '${{ env.BUILD_TYPE }}' == 'Release' ]; then
# FIXME arch-specific strip prefix
2022-04-01 00:55:20 +00:00
i686-w64-mingw32-strip -s "${binPath}/furnace.exe"
fi
mkdir ${{ steps.package-identify.outputs.filename }}
pushd ${{ steps.package-identify.outputs.filename }}
cp -v ../LICENSE LICENSE.txt
cp -v ../README.md README.txt
cp -vr ../{papers,demos} ../${binPath}/furnace.exe ./
popd
- name: Package [macOS]
if: ${{ runner.os == 'macOS' }}
run: |
pushd build
cpack
2022-04-02 14:48:05 +00:00
mv Furnace-*-Darwin.dmg ../${{ steps.package-identify.outputs.filename }}
popd
- name: Package [Ubuntu]
2022-04-01 00:55:20 +00:00
if: ${{ runner.os == 'Linux' && matrix.config.compiler != 'mingw' }}
run: |
2022-04-01 00:55:20 +00:00
if [ '${{ env.BUILD_TYPE }}' == 'Release' ]; then
strip -s build/furnace
fi
mkdir -p target/furnace.AppDir
make -C ${PWD}/build DESTDIR=${PWD}/target/furnace.AppDir install
pushd target
pushd furnace.AppDir
cp -v usr/share/{icons/hicolor/1024x1024/apps/furnace.png,applications/furnace.desktop} ./
ln -s furnace.png .DirIcon
mv -v usr/share/metainfo/{furnace.appdata,org.tildearrow.furnace.metainfo}.xml
cp -v ../../res/AppRun ./
popd
../appimagetool-x86_64.AppImage furnace.AppDir
2022-04-02 14:48:05 +00:00
mv Furnace-*.AppImage ../${{ steps.package-identify.outputs.filename }}
popd
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
2022-04-02 14:48:05 +00:00
name: ${{ steps.package-identify.outputs.id }}
path: ${{ steps.package-identify.outputs.filename }}