91 lines
3.7 KiB
YAML
91 lines
3.7 KiB
YAML
---
|
|
|
|
steps:
|
|
|
|
test:
|
|
image: python:3.11-bookworm
|
|
group: test
|
|
commands:
|
|
- pip3 install -e .[test]
|
|
- sudo -u matemat python3 -m coverage run --rcfile=setup.cfg -m unittest discover matemat
|
|
- sudo -u matemat python3 -m coverage combine
|
|
- sudo -u matemat python3 -m coverage report --rcfile=setup.cfg
|
|
|
|
codestyle:
|
|
image: python:3.11-bookworm
|
|
group: test
|
|
commands:
|
|
- pip3 install -e .[test]
|
|
- sudo -u matemat pycodestyle matemat
|
|
|
|
build_wheel:
|
|
image: python:3.11-bookworm
|
|
group: package
|
|
when:
|
|
- event: tag
|
|
secrets:
|
|
- GITEA_API_REPOSITORY_PYPI
|
|
- GITEA_API_USERNAME
|
|
- GITEA_API_PASSWORD
|
|
commands:
|
|
- pip3 install -e .[test]
|
|
- python3 setup.py egg_info bdist_wheel
|
|
- |
|
|
cat > ~/.pypirc <<EOF
|
|
[distutils]
|
|
index-servers = gitea
|
|
|
|
[gitea]
|
|
repository = $${GITEA_API_REPOSITORY_PYPI}
|
|
username = $${GITEA_API_USERNAME}
|
|
password = $${GITEA_API_PASSWORD}
|
|
EOF
|
|
- python3 -m twine upload --repository gitea dist/*.whl
|
|
|
|
build_debian:
|
|
image: python:3.11-bookworm
|
|
group: package
|
|
when:
|
|
- event: tag
|
|
secrets:
|
|
- GITEA_API_REPOSITORY_DEB
|
|
- GITEA_API_USERNAME
|
|
- GITEA_API_PASSWORD
|
|
commands:
|
|
- apt update; apt install -y lintian rsync sudo curl
|
|
- export MATEMAT_VERSION=$(python -c 'import matemat; print(matemat.__version__)')
|
|
# The Python package name provided by the python3-magic Debian package is "python-magic" rather than "file-magic".
|
|
- sed -re 's/file-magic/python-magic/' -i setup.py
|
|
- |
|
|
(for version in "$(cat CHANGELOG.md | grep '<!-- BEGIN CHANGES' | cut -d ' ' -f 4)"; do
|
|
echo "matemat (${version}-1); urgency=medium\n"
|
|
cat CHANGELOG.md | grep -A 1000 "<"'!'"-- BEGIN CHANGES ${version} -->" | grep -B 1000 "<"'!'"-- END CHANGES ${version} -->" | tail -n +2 | head -n -1 | sed -re 's/^-/ */g'
|
|
echo "\n -- ${PACKAGE_AUTHOR} $(date -R)\n"
|
|
done) > package/debian/matemat/usr/share/doc/matemat/changelog
|
|
- gzip -9n package/debian/matemat/usr/share/doc/matemat/changelog
|
|
- cp -r static/ package/debian/matemat/usr/lib/matemat/static/
|
|
- cp -r templates/ package/debian/matemat/usr/lib/matemat/templates/
|
|
- mkdir -p package/debian/matemat/var/lib/matemat/themes/
|
|
- cp -r themes/ package/debian/matemat/usr/lib/matemat/themes/
|
|
- python3 setup.py egg_info install --root=package/debian/matemat/ --prefix=/usr --optimize=1
|
|
- cd package/debian
|
|
- mkdir -p matemat/usr/lib/python3/dist-packages/
|
|
- rsync -a matemat/usr/lib/python3.11/site-packages/ matemat/usr/lib/python3/dist-packages/
|
|
- rm -rf matemat/usr/lib/python3.11/
|
|
- find matemat/usr/lib/python3/dist-packages -name __pycache__ -exec rm -r {} \; 2>/dev/null || true
|
|
- find matemat/usr/lib/python3/dist-packages -name '*.pyc' -exec rm {} \;
|
|
- mv matemat/usr/bin/matemat matemat/usr/lib/matemat/matemat
|
|
- rm -rf matemat/usr/bin
|
|
- sed -re 's$#!/usr/local/bin/python3.11$#!/usr/bin/python3$' -i matemat/usr/lib/matemat/matemat
|
|
- find matemat -type f -exec chmod 0644 {} \;
|
|
- find matemat -type d -exec chmod 755 {} \;
|
|
- chmod +x matemat/usr/lib/matemat/matemat matemat/DEBIAN/postinst matemat/DEBIAN/prerm matemat/DEBIAN/postrm
|
|
- sed -re "s/__VERSION__/$${MATEMAT_VERSION}-1/g" -i matemat/DEBIAN/control
|
|
- dpkg-deb --build matemat
|
|
- mv matemat.deb "matemat_${MATEMAT_VERSION}-1_all.deb"
|
|
- sudo -u nobody lintian "matemat_${MATEMAT_VERSION}-1_all.deb" || true
|
|
- >-
|
|
curl
|
|
--user "$${GITEA_API_USERNAME}:$${GITEA_API_PASSWORD}"
|
|
--upload-file "matemat_$${EXPORTER_VERSION}-1_all.deb"
|
|
$${GITEA_API_REPOSITORY_DEB}
|