code formatting #749
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 Mergin Plugin Packages | |
on: | |
push: | |
workflow_dispatch: | |
inputs: | |
PYTHON_API_CLIENT_VER: | |
description: 'python-api-client version: either a tag, release, or a branch' | |
required: true | |
default: 'master' | |
type: string | |
GEODIFF_VER: | |
description: 'Geodiff version released on PyPI repository' | |
default: '2.0.4' | |
type: string | |
env: | |
# Assign the version provided by 'workflow_dispatch' if available; otherwise, use the default. | |
PYTHON_API_CLIENT_VER: ${{ inputs.PYTHON_API_CLIENT_VER != '' && inputs.PYTHON_API_CLIENT_VER || '0.9.3' }} | |
GEODIFF_VER: ${{ inputs.GEODIFF_VER != '' && inputs.GEODIFF_VER || '2.0.4' }} | |
PYTHON_VER: "38" | |
PLUGIN_NAME: Mergin | |
jobs: | |
build_linux_binary: | |
name: Extract geodiff binary linux | |
runs-on: ubuntu-latest | |
env: | |
PY_PLATFORM: "manylinux2014_x86_64" | |
steps: | |
- uses: actions/setup-python@v4 | |
name: Install Python | |
- name: Download pygeodiff binaries | |
run: | | |
pip3 download --only-binary=:all: \ | |
--no-deps --platform ${PY_PLATFORM} \ | |
--python-version ${PYTHON_VER} \ | |
--implementation cp \ | |
--abi cp${PYTHON_VER} pygeodiff==${GEODIFF_VER} | |
unzip -o pygeodiff-$GEODIFF_VER-cp${PYTHON_VER}-cp${PYTHON_VER}-manylinux_2_17_x86_64.${PY_PLATFORM}.whl -d tmp || true | |
mkdir pygeodiff-binaries | |
cp tmp/pygeodiff/libpygeodiff-${GEODIFF_VER}-python.so ./pygeodiff-binaries/ | |
- name: Patching pygeodiff binaries | |
run: | | |
# get exact name of the linked library (e.g. libsqlite3-d9e27dab.so.0.8.6) | |
SQLITE_LINE=$(ldd ./pygeodiff-binaries/libpygeodiff-${GEODIFF_VER}-python.so | grep libsqlite3) | |
SQLITE_LIB=$(echo ${SQLITE_LINE} | sed -E "s/.*(libsqlite3-[a-z0-9]+.so[\\.0-9]+).*/\\1/") | |
patchelf --replace-needed ${SQLITE_LIB} libsqlite3.so.0 ./pygeodiff-binaries/libpygeodiff-${GEODIFF_VER}-python.so | |
patchelf --remove-rpath ./pygeodiff-binaries/libpygeodiff-${GEODIFF_VER}-python.so | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: ./pygeodiff-binaries/*.so | |
build_windows_binaries: | |
name: Extract geodiff binary windows | |
runs-on: windows-latest | |
steps: | |
- uses: actions/setup-python@v4 | |
name: Install Python | |
- name: Install deps | |
run: | | |
choco install unzip | |
- name: Download pygeodiff 32 binaries | |
run: | | |
pip3 download --only-binary=:all: --no-deps --platform "win32" --python-version $env:PYTHON_VER pygeodiff==$env:GEODIFF_VER | |
unzip -o pygeodiff-$env:GEODIFF_VER-cp$env:PYTHON_VER-cp$env:PYTHON_VER-win32.whl -d tmp32 | |
mkdir pygeodiff-binaries | |
copy tmp32\pygeodiff\*.pyd pygeodiff-binaries\ | |
- name: Download pygeodiff 64 binaries | |
run: | | |
pip3 download --only-binary=:all: --no-deps --platform "win_amd64" --python-version $env:PYTHON_VER pygeodiff==$env:GEODIFF_VER | |
unzip -o pygeodiff-$env:GEODIFF_VER-cp$env:PYTHON_VER-cp$env:PYTHON_VER-win_amd64.whl -d tmp64 | |
copy tmp64\pygeodiff\*.pyd pygeodiff-binaries\ | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: ./pygeodiff-binaries/*.pyd | |
build_macos_binary: | |
name: Extract geodiff binary macos | |
runs-on: macos-latest | |
env: | |
PY_PLATFORM: "macosx_10_9_x86_64" | |
steps: | |
- uses: actions/setup-python@v4 | |
name: Install Python | |
- name: Install deps | |
run: | | |
brew install unzip | |
- name: Download pygeodiff binaries | |
run: | | |
pip3 download --only-binary=:all: --no-deps --platform ${PY_PLATFORM} --python-version ${PYTHON_VER} --implementation cp --abi cp${PYTHON_VER} pygeodiff==$GEODIFF_VER | |
unzip -o pygeodiff-$GEODIFF_VER-cp${PYTHON_VER}-cp${PYTHON_VER}-${PY_PLATFORM}.whl -d tmp | |
mkdir pygeodiff-binaries | |
cp tmp/pygeodiff/*.dylib ./pygeodiff-binaries/ | |
- name: Patching pygeodiff binaries | |
run: | | |
install_name_tool -change @loader_path/.dylibs/libsqlite3.0.dylib @rpath/libsqlite3.dylib ./pygeodiff-binaries/libpygeodiff-$GEODIFF_VER-python.dylib | |
OTOOL_L=$(otool -L ./pygeodiff-binaries/libpygeodiff-$GEODIFF_VER-python.dylib) | |
if echo "${OTOOL_L}" | grep -q loader_path | |
then | |
echo "libpygeodiff-$GEODIFF_VER-python.dylib was not patched correctly, maybe sqlite version changed??" | |
exit 1 | |
fi | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: ./pygeodiff-binaries/*.dylib | |
create_mergin_plugin_package: | |
needs: [build_windows_binaries, build_linux_binary, build_macos_binary] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
repository: MerginMaps/python-api-client | |
ref: ${{ env.PYTHON_API_CLIENT_VER }} | |
path: python-api-client | |
- name: prepare py-client dependencies | |
run: | | |
cd python-api-client | |
python3 setup.py sdist bdist_wheel | |
mkdir -p mergin/deps | |
# without __init__.py the deps dir may get recognized as "namespace package" in python | |
# and it can break qgis plugin unloading mechanism - see #126 | |
touch mergin/deps/__init__.py | |
pip3 wheel -r mergin_client.egg-info/requires.txt -w mergin/deps | |
# special care for pygeodiff | |
unzip mergin/deps/pygeodiff-*.whl -d mergin/deps | |
# remove unncesessary files | |
rm -rf mergin/deps/*.dist-info | |
rm -rf mergin/deps/*.data | |
rm -rf mergin/deps/pygeodiff.libs | |
rm -rf mergin/deps/pygeodiff-*.whl | |
- name: check geodiff version in sync with python-api-client | |
run: | | |
GEODIFF_VER_FROM_CLIENT="$(geodiff="$(cat python-api-client/mergin_client.egg-info/requires.txt | grep pygeodiff)";echo ${geodiff#pygeodiff==})" | |
if [ "$GEODIFF_VER" != "$GEODIFF_VER_FROM_CLIENT" ]; then | |
echo "geodiff version defined in python-api-client requires.txt $GEODIFF_VER_FROM_CLIENT does not equal $GEODIFF_VER from the workpackage file" | |
exit 1; # or just warning?? | |
fi | |
- uses: actions/download-artifact@v3 | |
with: | |
name: artifact | |
path: pygeodiff-binaries | |
- name: include pygeodiff deps | |
run: | | |
cp pygeodiff-binaries/* python-api-client/mergin/deps/pygeodiff | |
- uses: actions/checkout@v3 | |
with: | |
path: qgis-mergin-plugin | |
- name: create package | |
run: | | |
cp -r python-api-client/mergin qgis-mergin-plugin/Mergin | |
rsync -av --exclude='test' --exclude='/__pycache__/' --exclude='*/__pycache__/' qgis-mergin-plugin/Mergin output | |
# from 1 June 2024, plugins are required to include LICENSE file | |
cp qgis-mergin-plugin/LICENSE.txt output/Mergin/LICENSE | |
(cd output && zip -r9 ../mergin.zip Mergin/) | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: Mergin | |
path: output/ | |
- name: upload asset on tagged release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: mergin.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |