audacia/.github/workflows/cmake_build.yml

226 lines
6.8 KiB
YAML

#
# CMake based build for Audacity
#
name: CMake Build
#
# Only execute on "git push" actions
#
on:
push:
# Remove the "#" from the next 2 lines if you need to disable this action
#branches:
# - disable
pull_request:
# Remove the "#" from the next 2 lines if you need to disable this action
#branches:
# - disable
#
# Global environment variables
#
env:
WXURL: https://github.com/audacity/wxWidgets
WXREF: audacity-fixes-3.1.3
WXWIN: ${{ github.workspace }}/wxwin
# As of 2021/01/01, github is using Xcode 12.2 as the default and
# it has a bug in the install_name_tool. So explicitly use 12.3
# instead.
DEVELOPER_DIR: /Applications/Xcode_12.3.app/Contents/Developer
CONAN_USER_HOME: "${{ github.workspace }}/conan-home/"
CONAN_USER_HOME_SHORT: "${{ github.workspace }}/conan-home/short"
#
# Define our job(s)
#
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Windows_32bit",
os: windows-latest,
generator: "Visual Studio 16 2019",
platform: "Win32"
}
- {
name: "Windows_64bit",
os: windows-latest,
generator: "Visual Studio 16 2019",
platform: "x64"
}
- {
name: "Ubuntu_18.04",
os: ubuntu-18.04,
generator: "Unix Makefiles"
}
- {
name: "macOS",
os: macos-latest,
generator: "Xcode"
}
steps:
# =========================================================================
# SHARED: Checkout source
# =========================================================================
- name: Checkout
uses: actions/checkout@v2
# with:
# ref: master
# =========================================================================
# SHARED: Checkout source
# =========================================================================
- name: Calculate short hash
shell: bash
run: |
set -x
# Get the short hash
shorthash=$(git show -s --format='%h')
# Export the short hash for the upload step
echo "SHORTHASH=${shorthash}" >> ${GITHUB_ENV}
# Export the destination directory name
echo "DEST=${{matrix.config.name}}_${shorthash}" >> ${GITHUB_ENV}
- name: GitHub Action Cache for .conan
id: github-cache-conan
uses: actions/cache@v2
env:
cache-name: cache-conan-modules
with:
path: ${{ env.CONAN_USER_HOME }}
key: host-${{ matrix.config.name }}-${{ hashFiles('cmake-proxies/CMakeLists.txt') }}
restore-keys: |
host-${{ matrix.config.name }}-
# =========================================================================
# WINDOWS: Build (for all versions of Windows)
# =========================================================================
- name: Build for Windows
if: startswith( matrix.config.os, 'windows' )
shell: bash
run: |
set -x
pip install conan
conan --version
# Configure Audacity
#
cmake -S . \
-B build \
-G "${{matrix.config.generator}}" \
-A ${{matrix.config.platform}} \
-D audacity_use_pch=no
# Build Audacity
cmake --build build --config Release --verbose
# "Install" Audacity
mkdir -p "${DEST}"
cp -a build/bin/Release/* "${DEST}"
rm -f "${DEST}"/{*.iobj,*.ipdb}
# Create artifact (zipped as Github actions don't preserve permissions)
cmake -E tar c "${GITHUB_SHA}.zip" --format=zip "${DEST}"
# =========================================================================
# MACOS: Build (for all versions of MacOS)
# =========================================================================
- name: Build for macOS
if: startswith( matrix.config.os, 'macos' )
shell: bash
run: |
set -x
# Setup environment
export PATH="/usr/local/bin:${PATH}"
export DYLD_LIBRARY_PATH="/usr/local/lib"
# Install required packages
brew install gettext
brew link --force gettext
brew install conan
conan --version
# Configure Audacity
cmake -S . \
-B build \
-T buildsystem=1 \
-G "${{matrix.config.generator}}" \
-D audacity_use_pch=no
# Build Audacity
cmake --build build --config Release
# "Install" Audacity
mkdir -p "${DEST}"
cp -a build/bin/Release/ "${DEST}"
# Create artifact (zipped as Github actions don't preserve permissions)
cmake -E tar c "${GITHUB_SHA}.zip" --format=zip "${DEST}"
# =========================================================================
# UBUNTU: Build (for all versions of Ubuntu)
# =========================================================================
- name: Build for Ubuntu
if: startswith( matrix.config.os, 'ubuntu' )
shell: bash
run: |
set -x
# Setup environment
export PATH="/usr/local/bin:${PATH}"
export LD_LIBRARY_PATH="/usr/local/lib"
# Install required packages
sudo apt-get update -y
sudo apt-get install -y libgtk2.0-dev libasound2-dev gettext python3-pip
sudo apt-get remove -y ccache
pip3 install wheel setuptools
pip3 install conan
conan --version
# Configure Audacity
cmake -S . \
-B build \
-G "${{matrix.config.generator}}" \
-D audacity_use_pch=no
# Build Audacity
cmake --build build --config Release
# "Install" Audacity
cmake --install build --config Release --prefix "${DEST}"
# Create the lib directory
mkdir -p ${DEST}/lib
# Create wrapper script
cat >"${DEST}/audacity" <<"EOF"
#!/bin/sh
lib="${0%/*}/lib/audacity"
export LD_LIBRARY_PATH="${lib}:${LD_LIBRARY_PATH}"
export AUDACITY_MODULES_PATH="${lib}/modules"
"${0%/*}/bin/audacity"
EOF
chmod +x "${DEST}/audacity"
# Create artifact (zipped as Github actions don't preserve permissions)
cmake -E tar c "${GITHUB_SHA}.zip" --format=zip "${DEST}"
# =========================================================================
# SHARED: Attach the artifact to the workflow results
# =========================================================================
- name: Upload artifact
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.config.name }}_${{ env.SHORTHASH }}
path: ${{ github.sha }}.zip