Add Github CI build

If at any point this needs to be disabled, go into
"Settings -> Actions" for the Github Audacity project and
select the "Disable Actions for this repository" radio button.

Or, edit build.yml and follow the instructions at the top to
disable the action.
This commit is contained in:
Leland Lucius 2020-01-06 01:22:31 -06:00
parent 2803bc30a6
commit cbdefbc876
1 changed files with 316 additions and 0 deletions

316
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,316 @@
name: Build Audacity
on:
push:
# Remove the "#" from the next 2 lines if you need to disable this action
#branches:
# - disable
jobs:
build:
# =========================================================================
# Run asynchronous builds
# =========================================================================
strategy:
fail-fast: false
matrix:
os: [windows-2019, ubuntu-16.04, ubuntu-18.04, macos-latest]
#os: [macos-latest]
runs-on: ${{ matrix.os }}
env:
USE_AUDACITY_WX: true
steps:
# =========================================================================
# SHARED: Checkout source
# =========================================================================
- name: Checkout
uses: actions/checkout@v2
with:
ref: master
# =========================================================================
# SHARED: Retrieve the commit hash and generate revision header
# =========================================================================
- name: Generate Header
shell: bash
run: |
set -x
# Generate the revision header
git show -s --format="#define REV_LONG \"%H\"%n#define REV_TIME \"%cd\"%n" >src/RevisionIdent.h
# Export the long and short hashs to further steps
echo "::set-env name=LONGHASH::$(git show -s --format='%H')"
echo "::set-env name=SHORTHASH::$(git show -s --format='%h')"
# =========================================================================
# SHARED: Retrieve the wxWidgets source and export the commit hash
# =========================================================================
- name: wxWidgets Hash
shell: bash
run: |
set -x
# Get latest wxWidgets source
git clone --depth 1 -n https://github.com/audacity/wxWidgets
cd wxWidgets
# Export the commit hash to further steps
echo "::set-env name=WXHASH::$(git show -s --format='%H')"
# =========================================================================
# SHARED: Create and/or retrieve wxWidgets cached build
# =========================================================================
- name: Cache wxWidgets
uses: actions/cache@v1
with:
key: wxWidgets_${{ matrix.os }}_${{ env.WXHASH }}.8
path: wxroot
# =========================================================================
# WINDOWS: Setup Nuget (for all versions of Ubuntu)
# =========================================================================
- name: Setup Nuget
uses: nuget/setup-nuget@v1
if: startswith( matrix.os, 'windows' )
# =========================================================================
# WINDOWS: Build (for all versions of Ubuntu)
# =========================================================================
- name: Build Windows
if: startswith( matrix.os, 'windows' )
shell: cmd
run: |
:: Set up Visual Studio environment
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
ECHO ON
:: Setup environment
choco install zip
:: Identify wxWidgets installation directory
SET WXWIN=%GITHUB_WORKSPACE%\wxroot
:: Build wxWidgets if needed
IF NOT EXIST %WXWIN% (
MKDIR %WXWIN%
CD wxWidgets
git checkout
git submodule update --init
:: Build it
CD build\msw
nmake -f makefile.vc BUILD=release SHARED=1
IF NOT %ERRORLEVEL% == 0 EXIT %ERRORLEVEL%
CD ..\..
:: "Install" wxWidgets
XCOPY include %WXWIN%\include /E /I /Q /Y
XCOPY lib %WXWIN%\lib /E /I /Q /Y
XCOPY locale %WXWIN%\locale /E /I /Q /Y
XCOPY src %WXWIN%\src /E /I /Q /Y
CD ..
)
:: Build Audacity
CD win
:: Restore packages (for gettext)
nuget restore audacity.sln
:: Build solution
msbuild audacity.sln /m /p:Configuration=Release /p:Platform=Win32
IF NOT %ERRORLEVEL% == 0 EXIT %ERRORLEVEL%
:: "Install" Audacity
MKDIR "%LONGHASH%"
XCOPY Release "%LONGHASH%" /E /I /Q /Y
XCOPY %WXWIN%\lib\vc_dll\*u_net_*.dll "%LONGHASH%" /E /I /Q /Y
XCOPY %WXWIN%\lib\vc_dll\*u_vc_*.dll "%LONGHASH%" /E /I /Q /Y
XCOPY %WXWIN%\lib\vc_dll\*u_xml_*.dll "%LONGHASH%" /E /I /Q /Y
XCOPY %WXWIN%\lib\vc_dll\*u_adv_*.dll "%LONGHASH%" /E /I /Q /Y
XCOPY %WXWIN%\lib\vc_dll\*u_core_*.dll "%LONGHASH%" /E /I /Q /Y
XCOPY %WXWIN%\lib\vc_dll\*u_html_*.dll "%LONGHASH%" /E /I /Q /Y
XCOPY %WXWIN%\lib\vc_dll\*u_qa_*.dll "%LONGHASH%" /E /I /Q /Y
CD "%LONGHASH%"
DEL /Q /S *.iobj *.exp *.ilk *.lib *.ipdb *.pdb include
#CD ..
:: Create artifact
zip -r9 "..\..\%LONGHASH%.zip" *
# =========================================================================
# UBUNTU: Build (for all versions of Ubuntu)
# =========================================================================
- name: Build Ubuntu
if: startswith( matrix.os, 'ubuntu' )
shell: bash
run: |
set -x
set
# Setup environment
sudo apt-get install -y libgtk2.0-dev libasound2-dev autoconf automake zip
# Identify wxWidgets installation directory
WXROOT="${GITHUB_WORKSPACE}/wxroot"
# Build wxWidgets if needed
if [ ! -e "${WXROOT}" ]
then
mkdir "${WXROOT}"
cd wxWidgets
git checkout
git submodule update --init
./configure --with-gtk
make -j $(nproc) install DESTDIR="${WXROOT}"
cd ..
fi
# "Install" wxWidgets
sudo cp -a "${WXROOT}"/* /
# Configure Audacity
mkdir bld
cd bld
../configure --with-lib-preference='local system'
# Build lib-src first
#
# This allows using multiple make jobs (-j). If not done this way
# the build may fail (bug in our make process)
cd lib-src
make -j $(nproc)
cd ..
# And then the rest
make -j $(nproc)
# Identify installation directory
DESTDIR="$(pwd)/linux"
mkdir -p "${DESTDIR}"
# Create wrapper script
#
# (This is only needed if using our wxWidgets libs)
cat >"${DESTDIR}/audacity" <<"EOF"
#!/bin/sh
export LD_LIBRARY_PATH="${0%/*}:${LD_LIBRARY_PATH}"
"${0%/*}/audacity.bin"
EOF
chmod +x "${DESTDIR}/audacity"
# Copy over dist files
cp -a audacity "${DESTDIR}/audacity.bin"
cp -aL nyquist plug-ins "${DESTDIR}"
mkdir "${DESTDIR}/help" "${DESTDIR}/locale/"
cp -aL $(find locale/ -type d) "${DESTDIR}/locale/"
# Copy wxWidgets libraries
cp -a "${WXROOT}"/usr/local/lib/*.so* "${DESTDIR}"
# Create artifact (zipped as Github actions don't preserve permissions)
cd "${DESTDIR}"
zip -r9 "${GITHUB_WORKSPACE}/${LONGHASH}.zip" *
# =========================================================================
# MACOS: Build (for all versions of MacOS)
# =========================================================================
- name: Build Mac
if: startswith( matrix.os, 'macos' )
shell: bash
run: |
set -x
# The minimum OS X version supported by Audacity is 10.7.
minver=10.7
# Make the "msgfmt" command available
brew install gettext
brew link --force gettext
# Make sure MacOS supplied commands are used
export PATH="/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin"
# Identify wxWidgets installation directory
WXROOT="${GITHUB_WORKSPACE}/wxroot"
# Build wxWidgets if needed
if [ ! -e "${WXROOT}" ]
then
mkdir "${WXROOT}"
cd wxWidgets
git checkout
git submodule update --init
# Make sure our flags are included
export CXX="g++ -std=c++1z -stdlib=libc++"
export LD="g++ -std=c++1z -stdlib=libc++"
# Build x86_64, release, shared configuration
./configure --prefix=/usr/local/x86_64 \
--enable-debug=no \
--enable-macosx-arch="x86_64" \
--enable-shared=yes \
--enable-unicode=yes \
--enable-universal_binary=no \
--enable-webkit=no \
--enable-webviewwebkit=no \
--with-expat=builtin \
--with-flavour="release" \
--with-libjpeg=builtin \
--with-libpng=builtin \
--with-libtiff=builtin \
--with-macosx-version-min="${minver}" \
--with-regex=builtin \
--with-zlib=builtin \
--without-liblzma
${run} make -j $(sysctl -n hw.ncpu) install DESTDIR="${WXROOT}"
unset CXX LD
cd ..
fi
# "Install" wxWidgets
sudo cp -a "${WXROOT}/usr/local" /usr/
# Build Audacity
cd mac
# Temporary workaround until they can be incorporated into
# the Xcode project itself
sed -i '' -e "s/TARGET=10.9/TARGET=${minver}/g" \
-e "s/macosx10.9/macosx/g" Audacity.xcodeproj/project.pbxproj
xcodebuild -configuration Release64 install
cd ..
# "Install" Audacity
mkdir -p macos
cp -a /tmp/Audacity.dst/Audacity.app macos
# Create artifact (zipped as Github actions don't preserve permissions)
cd "/tmp/Audacity.dst"
zip -r9 "${GITHUB_WORKSPACE}/${LONGHASH}.zip" *
# =========================================================================
# SHARED: Attach the artifact to the workflow results
# =========================================================================
- name: Upload artifact
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.os }}_${{ env.SHORTHASH }}
path: ${{ env.LONGHASH }}.zip