Skip to content

Build and Package CmusicAI for macOS #87

Build and Package CmusicAI for macOS

Build and Package CmusicAI for macOS #87

name: Build and Package CmusicAI for macOS
on:
workflow_dispatch:
jobs:
build_and_package:
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 python3 python3-dev python3-setuptools fonts-tuffy \
clang qtbase5-dev qttools5-dev-tools qtdeclarative5-dev libboost-all-dev libminiupnpc-dev protobuf-compiler libprotobuf-dev inkscape patchelf
- 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: |
echo "export PATH=${GITHUB_WORKSPACE}/depends/x86_64-apple-darwin14/native/bin:$PATH" >> $GITHUB_ENV
- name: Prepare Build Environment
run: |
cd ${GITHUB_WORKSPACE}
if [ ! -f ./configure ]; then
./autogen.sh
fi
- name: Ensure Configure Script
run: |
if [ ! -f ./configure ]; then
echo "Error: configure script not found."
exit 1
fi
- name: Debug Environment Variables
run: |
echo "Checking environment variables..."
env
- name: Build macOS cross-compilation tools
run: |
cd depends
make HOST=x86_64-apple-darwin14 -j2
env:
SDK_PATH: ${GITHUB_WORKSPACE}/depends/SDKs/MacOSX10.14.sdk
CC: ${GITHUB_WORKSPACE}/depends/x86_64-apple-darwin14/native/bin/x86_64-apple-darwin14-clang
CXX: ${GITHUB_WORKSPACE}/depends/x86_64-apple-darwin14/native/bin/x86_64-apple-darwin14-clang++
- name: Check cross-compilation tools availability
run: |
echo $PATH
ls -la ${GITHUB_WORKSPACE}/depends/x86_64-apple-darwin14/native/bin
which x86_64-apple-darwin14-g++
which x86_64-apple-darwin14-clang++
- name: Configure Build
run: |
export PATH="${GITHUB_WORKSPACE}/depends/x86_64-apple-darwin14/native/bin:$PATH"
export CC="${GITHUB_WORKSPACE}/depends/x86_64-apple-darwin14/native/bin/x86_64-apple-darwin14-clang"
export CXX="${GITHUB_WORKSPACE}/depends/x86_64-apple-darwin14/native/bin/x86_64-apple-darwin14-clang++"
export LDFLAGS="-L/usr/local/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -latomic"
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 --disable-gui-tests --host=x86_64-apple-darwin14 --with-libs=-latomic
- name: Build CmusicAI
run: |
make -j4
- name: Ensure Permissions
run: |
chmod -R 755 ${GITHUB_WORKSPACE}
- name: Install and Package
run: |
echo "Starting the package installation and macOS bundle creation process."
echo "Ensuring the availability of all necessary binaries..."
if [ -d "${GITHUB_WORKSPACE}/depends/x86_64-apple-darwin14/native/bin/" ]; then
ls -l ${GITHUB_WORKSPACE}/depends/x86_64-apple-darwin14/native/bin/
else
echo "Directory does not exist."
fi
echo "Running osx_volname..."
make osx_volname
echo "osx_volume done."
echo "Creating deployment directory..."
make deploydir
echo "deploydir done."
mkdir -p unsigned-app-cmusicai
echo "unsigned-app-cmusicai directory created."
cp osx_volname unsigned-app-cmusicai/
cp ${GITHUB_WORKSPACE}/contrib/macdeploy/detached-sig-apply.sh unsigned-app-cmusicai/
cp ${GITHUB_WORKSPACE}/contrib/macdeploy/detached-sig-create.sh unsigned-app-cmusicai/
cp ${GITHUB_WORKSPACE}/depends/x86_64-apple-darwin14/native/bin/* unsigned-app-cmusicai/
echo "Files copied to unsigned-app-cmusicai directory. Moving dist..."
mv dist unsigned-app-cmusicai
echo "dist moved."
echo "Creating OSX directory for installation..."
mkdir -p ~/OSX
echo "OSX directory created."
echo "Exporting PATH to include native bin directory..."
export PATH=$PWD/depends/x86_64-apple-darwin14/native/bin:$PATH
echo "PATH exported. Current PATH: $PATH"
echo "Installing with strip to OSX directory..."
make install-strip DESTDIR=~/OSX/$DISTNAME
echo "Installation to OSX directory completed."
# Debugging statements
echo "Contents of native/bin:"
ls -l ${GITHUB_WORKSPACE}/depends/x86_64-apple-darwin14/native/bin
echo "Compressing and preparing package for deployment..."
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}
echo "Deploying dmg..."
${GITHUB_WORKSPACE}/depends/x86_64-apple-darwin14/native/bin/dmg dmg "CmusicAI-Core.dmg" ${GITHUB_WORKSPACE}/release/cmusicai-${{ github.sha }}-osx-unsigned.dmg
echo "dmg deployed."
echo "Calculating checksums..."
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
echo "Checksums calculated. Package installation and generation complete."
- name: Upload Package Artifacts
uses: actions/upload-artifact@v2
with:
name: cmusicai-package
path: |
release/cmusicai-${{ github.sha }}-macos.tar.gz
release/cmusicai-${{ github.sha }}-macos.tar.gz.md5sum
release/cmusicai-${{ github.sha }}-macos.tar.gz.sha256sum
release/cmusicai-${{ github.sha }}-osx-unsigned.tar.gz
release/cmusicai-${{ github.sha }}-osx-unsigned.tar.gz.md5sum
release/cmusicai-${{ github.sha }}-osx-unsigned.tar.gz.sha256sum
release/cmusicai-${{ github.sha }}-osx-unsigned.dmg
release/cmusicai-${{ github.sha }}-osx-unsigned.dmg.md5sum
release/cmusicai-${{ github.sha }}-osx-unsigned.dmg.sha256sum
- 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
- name: Upload config.log
if: failure()
uses: actions/upload-artifact@v2
with:
name: config-log
path: ${GITHUB_WORKSPACE}/depends/work/build/x86_64-apple-darwin14/native_cctools/*/cctools/config.log