-
Notifications
You must be signed in to change notification settings - Fork 21
213 lines (187 loc) · 8.53 KB
/
Copy pathpackages.yml
File metadata and controls
213 lines (187 loc) · 8.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: Build Package
on:
push:
workflow_dispatch:
inputs:
REQUESTED_PYTHON_API_CLIENT_VER:
description: 'Python API Client version (tag, release, branch)'
required: true
default: 'master'
type: string
REQUESTED_GEODIFF_VER:
description: 'Geodiff version'
default: '2.2.0'
type: string
env:
PYTHON_API_CLIENT_VER: ${{ inputs.REQUESTED_PYTHON_API_CLIENT_VER || '0.12.2' }}
GEODIFF_VER: ${{ inputs.REQUESTED_GEODIFF_VER || '2.2.0' }}
PYTHON_VER: "38"
jobs:
build_linux_binary:
name: Extract geodiff binary linux
runs-on: ubuntu-latest
env:
PY_PLATFORM: "manylinux_2_28_x86_64"
steps:
- uses: actions/setup-python@v4
name: Install Python
- name: Download pygeodiff binaries
run: |
pip3 download --only-binary=:all: \
--python-version ${PYTHON_VER} \
--no-deps --platform ${PY_PLATFORM} \
--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 || 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@v4
with:
name: artifact-pygeodiff-linux
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 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
mkdir pygeodiff-binaries
copy tmp64\pygeodiff\*.pyd pygeodiff-binaries\
- uses: actions/upload-artifact@v4
with:
name: artifact-pygeodiff-windows
path: ./pygeodiff-binaries/*.pyd
build_macos_binaries:
name: Extract geodiff binary macos
runs-on: macos-latest
steps:
- uses: actions/setup-python@v4
name: Install Python
- name: Install deps
run: |
brew install unzip
- name: Download pygeodiff binaries (Intel)
env:
PY_PLATFORM: "macosx_10_9_x86_64"
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 tmp32
mkdir pygeodiff-binaries
cp tmp32/pygeodiff/*.dylib ./pygeodiff-binaries/
- name: Patching pygeodiff binaries (Intel)
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
- name: Download pygeodiff binaries (arm64)
env:
PY_PLATFORM: "macosx_14_0_arm64"
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 tmp64
cp tmp64/pygeodiff/libpygeodiff-$GEODIFF_VER-python-arm64.dylib ./pygeodiff-binaries/libpygeodiff-$GEODIFF_VER-python-arm64.dylib # expects that the folder is created before in the intel job
- name: Patching pygeodiff binaries (arm64)
run: |
install_name_tool -change @loader_path/.dylibs/libsqlite3.0.dylib @rpath/libsqlite3.dylib ./pygeodiff-binaries/libpygeodiff-$GEODIFF_VER-python-arm64.dylib
codesign --force --sign - ./pygeodiff-binaries/libpygeodiff-$GEODIFF_VER-python-arm64.dylib
OTOOL_L=$(otool -L ./pygeodiff-binaries/libpygeodiff-$GEODIFF_VER-python-arm64.dylib)
if echo "${OTOOL_L}" | grep -q loader_path
then
echo "libpygeodiff-$GEODIFF_VER-python-arm64.dylib was not patched correctly, maybe sqlite version changed??"
exit 1
fi
- uses: actions/upload-artifact@v4
with:
name: artifact-pygeodiff-macos
path: ./pygeodiff-binaries/*.dylib
create_plugin_package:
needs: [build_windows_binaries, build_linux_binary, build_macos_binaries]
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
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: artifact
pattern: artifact-pygeodiff-*
delete-merged: true
- uses: actions/download-artifact@v4
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: Calculate build number
env:
OFFFSET: 10 # offset for build number - due to previous builds ~ new builds must always have a higher number
run: |
BUILD_NUM=$GITHUB_RUN_NUMBER$((GITHUB_RUN_ATTEMPT + OFFFSET))
echo "BUILD_NUM=${BUILD_NUM}" >> $GITHUB_ENV
echo "Build number: ${BUILD_NUM}"
- 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@v4
with:
name: MM Plugin d-${{ env.BUILD_NUM }}
path: output/
- name: upload asset on tagged release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: MM Plugin r-${{ env.BUILD_NUM }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}