Skip to content

Instantly share code, notes, and snippets.

@lantrix
Last active December 27, 2020 08:08
Show Gist options
  • Save lantrix/35d135f36b710045642a988f1f99eb8c to your computer and use it in GitHub Desktop.
Save lantrix/35d135f36b710045642a988f1f99eb8c to your computer and use it in GitHub Desktop.
Package https://github.com/metabrainz/picard locally based off their Mac Github Actions.
#!/usr/bin/env bash
set -e
# Build Picard package - copied from github actions
# https://raw.githubusercontent.com/metabrainz/picard/4138db54301a0d5e0727c758f78b4306ae1e57bb/.github/workflows/package.yml
export DISCID_VERSION='0.6.2'
export FPCALC_VERSION='1.5.0'
export PYTHON_VERSION='3.7.6'
export PYTHON_MAJOR_VERSION='3.7'
export MACOSX_DEPLOYMENT_TARGET='10.13'
cd ~/picard/
# START REPLACE ./scripts/package/macos-setup.sh with other stuff
if [[ ! -f "$HOME/.pyenv/versions/${PYTHON_VERSION}/Python.framework/Versions/${PYTHON_MAJOR_VERSION}/lib/libpython${PYTHON_MAJOR_VERSION}.dylib" ]]; then
echo "Rebuild build CPython with Framework support on OSX with pyenv"
env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install $PYTHON_VERSION
fi
# Using global instead of local due to distutils wanting to revert to non-venv packages otherwise
pyenv global $PYTHON_VERSION
python3 -m ensurepip
if [ ! -d ~/environments/picard_build ]; then
mkdir -p ~/environments
python -m venv ~/environments/picard_build
fi
# Install gettext
if brew ls --versions gettext > /dev/null; then
echo "Gettext installed"
else
brew install gettext
fi
brew link gettext --force
# Install libdiscid
if [ ! -f "$HOME/libdiscid/lib/libdiscid.0.dylib" ]; then
wget "ftp://ftp.musicbrainz.org/pub/musicbrainz/libdiscid/libdiscid-$DISCID_VERSION.tar.gz"
tar -xf "libdiscid-$DISCID_VERSION.tar.gz"
cd "libdiscid-$DISCID_VERSION"
./configure --prefix="$HOME/libdiscid"
make install
cd ..
fi
cp "$HOME/libdiscid/lib/libdiscid.0.dylib" .
# Install fpcalc
if [ ! -f chromaprint-fpcalc-$FPCALC_VERSION-macos-x86_64.tar.gz ]; then
wget "https://github.com/acoustid/chromaprint/releases/download/v$FPCALC_VERSION/chromaprint-fpcalc-$FPCALC_VERSION-macos-x86_64.tar.gz"
fi
if [ -d chromaprint-fpcalc-$FPCALC_VERSION-macos-x86_64/fpcalc ]; then
rm -rf chromaprint-fpcalc-$FPCALC_VERSION-macos-x86_64/fpcalc
fi
tar -xf "chromaprint-fpcalc-$FPCALC_VERSION-macos-x86_64.tar.gz"
cp "chromaprint-fpcalc-$FPCALC_VERSION-macos-x86_64/fpcalc" .
# END macos-setup.sh
# PYTHON ENV
source ~/environments/picard_build/bin/activate
# BUILD
RELEASE_TAG=$(git describe --match "release-*" --abbrev=0 --always HEAD)
BUILD_NUMBER=$(git rev-list --count $RELEASE_TAG..HEAD)
export name="BUILD_NUMBER::$BUILD_NUMBER"
if [ -d artifacts ]; then
rm -rf artifacts
fi
mkdir artifacts
python3 setup.py patch_version --platform=$BUILD_NUMBER.$(git rev-parse --short HEAD)
python3 -m pip install --upgrade pip setuptools wheel
pip3 install -r requirements-build.txt
pip3 install -r requirements-macos.txt
python3 setup.py test
./scripts/package/macos-package-app.sh
mv dist/*.dmg artifacts/
deactivate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment