spaceapi-server/.gitlab-ci.yml
2023-10-05 00:29:40 +02:00

112 lines
3.8 KiB
YAML

---
image: s3lph/spaceapi-server-ci:20210530-01
stages:
- test
- build
- release
before_script:
- export SPACEAPI_SERVER_VERSION=$(python -c 'import spaceapi_server; print(spaceapi_server.__version__)')
test:
stage: test
script:
- pip3 install -e .
- python3 -m coverage run --rcfile=setup.cfg -m unittest discover spaceapi_server
- python3 -m coverage combine
- python3 -m coverage report --rcfile=setup.cfg
codestyle:
stage: test
script:
- pip3 install -e .
- pycodestyle spaceapi_server
build_wheel:
stage: build
script:
- python3 setup.py egg_info bdist_wheel
- cd dist
- sha256sum *.whl > SHA256SUMS
artifacts:
paths:
- "dist/*.whl"
- dist/SHA256SUMS
only:
- tags
build_debian:
stage: build
script:
- find package/debian -name .gitkeep -delete
# Copy example plugin
- install -m0644 examples/plugins/filestate.py package/debian/spaceapi-server/etc/spaceapi-server/plugins/filestate.py
# Create control
- |
cat > package/debian/spaceapi-server/DEBIAN/control <<EOF
Package: spaceapi-server
Version: ${SPACEAPI_SERVER_VERSION}
Maintainer: s3lph <account-gitlab-ideynizv@kernelpanic.lol>
Section: web
Priority: optional
Architecture: all
Depends: python3 (>= 3.9), python3-yaml, python3-bottle
Description: Lightweight SpaceAPI endpoint server
Lightweight server for SpaceAPI endpoints. Includes support for pluggable
templating, so dynamic content, like sensor values, can be added.
EOF
- chmod 0644 package/debian/spaceapi-server/DEBIAN/control
# Create changelog
- |
for version in "$(cat CHANGELOG.md | grep '<!-- BEGIN CHANGES' | cut -d ' ' -f 4)"; do
echo "spaceapi-server (${version}-1); urgency=medium\n" >> package/debian/spaceapi-server/usr/share/doc/spaceapi-server/changelog
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' >> package/debian/spaceapi-server/usr/share/doc/spaceapi-server/changelog
echo "\n -- s3lph <account-gitlab-ideynizv@kernelpanic.lol> $(date -R)\n" >> package/debian/spaceapi-server/usr/share/doc/spaceapi-server/changelog
done
- gzip -9n package/debian/spaceapi-server/usr/share/doc/spaceapi-server/changelog
# Copy license
- install -m0644 LICENSE package/debian/spaceapi-server/usr/share/doc/spaceapi-server/copyright
# Install spaceapi-server into package root
- python3 setup.py egg_info install --root=package/debian/spaceapi-server/ --prefix=/usr --optimize=1
- cd package/debian/spaceapi-server
- mkdir -p usr/lib/python3/dist-packages/
- cp -r usr/lib/python3.9/site-packages/spaceapi_server* usr/lib/python3/dist-packages/
- rm -rf usr/lib/python3.9/
# Remove compiled Python files
- find usr/lib/python3/dist-packages -name __pycache__ -exec rm -r {} \; 2>/dev/null || true
- find usr/lib/python3/dist-packages -name '*.pyc' -exec rm {} \;
# Remove spaceapi-server script
- rm usr/bin/spaceapi-server
# Fix file permissions
- find . -type f -exec chmod 0644 {} \;
- find . -type d -exec chmod 755 {} \;
- chmod 0755 DEBIAN/postinst DEBIAN/prerm DEBIAN/postrm
# Build the package
- cd ..
- dpkg-deb --build spaceapi-server
- mv spaceapi-server.deb "spaceapi-server_${SPACEAPI_SERVER_VERSION}-1_all.deb"
# Run lintian
- sudo -u nobody lintian --fail-on-warnings "spaceapi-server_${SPACEAPI_SERVER_VERSION}-1_all.deb"
# Generate checksum
- sha256sum *.deb > SHA256SUMS
artifacts:
paths:
- "package/debian/*.deb"
- package/debian/SHA256SUMS
only:
- tags
release:
stage: release
script:
- python3 package/release.py
only:
- tags