Build and Package CmusicAI for macOS #63
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Package CmusicAI for macOS | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y ca-certificates curl g++ git pkg-config autoconf librsvg2-bin libtiff-tools libtool automake bsdmainutils cmake imagemagick libcap-dev libz-dev libbz2-dev python python-dev python-setuptools fonts-tuffy \ | |
clang qtbase5-dev qttools5-dev-tools qtdeclarative5-dev libboost-all-dev libminiupnpc-dev protobuf-compiler libprotobuf-dev inkscape | |
- name: Install SDKs and Toolchain | |
run: | | |
mkdir -p depends/SDKs | |
cd depends/SDKs | |
curl -O https://bitcoincore.org/depends-sources/sdks/Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz | |
tar -zxf Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz | |
- name: Install Berkeley DB | |
run: | | |
chmod +x contrib/install_db4.sh | |
./contrib/install_db4.sh $(pwd) | |
- name: Generate background.tiff files | |
run: | | |
sed 's/PACKAGE_NAME/CmusicAI Core/' < "contrib/macdeploy/background.svg" > background.temp.svg | |
rsvg-convert -f png -d 36 -p 36 background.temp.svg -o dpi36.background.png | |
convert dpi36.background.png dpi36.background.tiff | |
rsvg-convert -f png -d 72 -p 72 background.temp.svg -o dpi72.background.png | |
convert dpi72.background.png dpi72.background.tiff | |
- name: Export Paths | |
run: | | |
export PATH=${GITHUB_WORKSPACE}/depends/x86_64-apple-darwin14/native/bin:$PATH | |
- name: Prepare Build Environment | |
run: | | |
cd ${GITHUB_WORKSPACE} | |
if [ ! -f ./configure ]; then | |
echo "Generating configure script" | |
./autogen.sh | |
fi | |
- name: Configure Build | |
run: | | |
set -x | |
cd ${GITHUB_WORKSPACE} | |
export BDB_PREFIX=${GITHUB_WORKSPACE}/db4 | |
export BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" | |
export BDB_CFLAGS="-I${BDB_PREFIX}/include" | |
export BOOST_ROOT=/usr/include/boost | |
export BOOST_LIB_PATH=/usr/lib/x86_64-linux-gnu | |
CONFIG_SITE=${GITHUB_WORKSPACE}/depends/x86_64-apple-darwin14/share/config.site \ | |
./configure --prefix=/ --disable-ccache --disable-maintainer-mode --disable-dependency-tracking --enable-reduce-exports --disable-bench --with-gui=qt5 --with-boost=${BOOST_ROOT} --with-boost-libdir=${BOOST_LIB_PATH} GENISOIMAGE=${GITHUB_WORKSPACE}/depends/x86_64-apple-darwin14/native/bin/genisoimage BDB_LIBS="${BDB_LIBS}" BDB_CFLAGS="${BDB_CFLAGS}" | |
- name: Build CmusicAI | |
run: | | |
make -j$(nproc) | |
- name: Build macOS Tools | |
run: | | |
cd ${GITHUB_WORKSPACE}/depends | |
make HOST=x86_64-apple-darwin14 V=1 | |
- name: Ensure Permissions | |
run: | | |
chmod -R 755 ${GITHUB_WORKSPACE} | |
- name: Archive build artifacts | |
run: | | |
mkdir -p build_artifacts | |
cp -r ${GITHUB_WORKSPACE}/src build_artifacts/ | |
cp -r ${GITHUB_WORKSPACE}/depends build_artifacts/ | |
cp -r ${GITHUB_WORKSPACE}/contrib build_artifacts/ | |
cp -r ${GITHUB_WORKSPACE}/build-aux build_artifacts/ | |
zip -r build_artifacts.zip build_artifacts/ | |
- name: Upload Build Artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: cmusicai-build | |
path: build_artifacts.zip | |
package: | |
needs: build | |
runs-on: macos-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Download Build Artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: cmusicai-build | |
path: . | |
- name: Unzip Build Artifacts | |
run: | | |
unzip build_artifacts.zip -d ${GITHUB_WORKSPACE} | |
- name: Ensure Permissions | |
run: | | |
chmod -R 755 ${GITHUB_WORKSPACE} | |
- name: Install and Package | |
run: | | |
# Ensure required tools have the right permissions | |
if [ -f "${GITHUB_WORKSPACE}/build_artifacts/depends/x86_64-apple-darwin14/native/bin/dmg" ]; then | |
chmod +x ${GITHUB_WORKSPACE}/build_artifacts/depends/x86_64-apple-darwin14/native/bin/dmg | |
fi | |
if [ -f "${GITHUB_WORKSPACE}/build_artifacts/depends/x86_64-apple-darwin14/native/bin/genisoimage" ]; then | |
chmod +x ${GITHUB_WORKSPACE}/build_artifacts/depends/x86_64-apple-darwin14/native/bin/genisoimage | |
fi | |
if [ -f "${GITHUB_WORKSPACE}/build_artifacts/depends/x86_64-apple-darwin14/native/bin/x86_64-apple-darwin14-codesign_allocate" ]; then | |
chmod +x ${GITHUB_WORKSPACE}/build_artifacts/depends/x86_64-apple-darwin14/native/bin/x86_64-apple-darwin14-codesign_allocate | |
fi | |
if [ -f "${GITHUB_WORKSPACE}/build_artifacts/depends/x86_64-apple-darwin14/native/bin/x86_64-apple-darwin14-pagestuff" ]; then | |
chmod +x ${GITHUB_WORKSPACE}/build_artifacts/depends/x86_64-apple-darwin14/native/bin/x86_64-apple-darwin14-pagestuff | |
fi | |
make install-strip DESTDIR=${GITHUB_WORKSPACE}/release | |
make osx_volname | |
- name: Debugging Information | |
run: | | |
echo "Contents of native/bin:" | |
ls -l ${GITHUB_WORKSPACE}/build_artifacts/depends/x86_64-apple-darwin14/native/bin | |
echo "Checking otool path:" | |
which otool || echo "otool not found" | |
cd unsigned-app-cmusicai | |
find . | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${GITHUB_WORKSPACE}/release/cmusicai-${{ github.sha }}-osx-unsigned.tar.gz | |
cd ${GITHUB_WORKSPACE} | |
make deploy | |
${GITHUB_WORKSPACE}/build_artifacts/depends/x86_64-apple-darwin14/native/bin/dmg dmg "CmusicAI-Core.dmg" ${GITHUB_WORKSPACE}/release/cmusicai-${{ github.sha }}-osx-unsigned.dmg | |
cd ${GITHUB_WORKSPACE}/release | |
for i in cmusicai-${{ github.sha }}-macos.tar.gz cmusicai-${{ github.sha }}-osx-unsigned.tar.gz cmusicai-${{ github.sha }}-osx-unsigned.dmg; do | |
if [ -e ${i} ]; then | |
md5sum ${i} >> ${i}.md5sum | |
sha256sum ${i} >> ${i}.sha256sum | |
fi | |
done | |
- name: Upload macOS Build Artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: cmusicai-macos | |
path: release/*.tar.gz | |
- name: Upload config.log | |
if: failure() | |
uses: actions/upload-artifact@v2 | |
with: | |
name: config-log | |
path: /Users/runner/work/Cmusic/Cmusic/depends/work/build/x86_64-apple-darwin14/native_cctools/*/cctools/config.log | |
- name: Create macOS app bundle | |
run: | | |
mkdir -p CmusicAI-Qt.app/Contents/MacOS | |
cp src/qt/cmusicai-qt CmusicAI-Qt.app/Contents/MacOS/CmusicAI-Qt | |
chmod +x /usr/bin/otool | |
chmod +x /usr/bin/install_name_tool | |
chmod +x /usr/bin/strip | |
export OTOOL=/usr/bin/otool | |
export INSTALLNAMETOOL=/usr/bin/install_name_tool | |
export STRIP=/usr/bin/strip | |
make deploy | |
- name: Upload DMG Artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: CmusicAI-Core.dmg | |
path: ${GITHUB_WORKSPACE}/release/CmusicAI-Core.dmg |