1
0
Fork 0
forked from s3lph/matemat
matemat/.gitlab-ci.yml

127 lines
3.4 KiB
YAML

---
image: s3lph/matemat-ci:20181103-01
stages:
- test
- build
- deploy
before_script:
- export MATEMAT_VERSION=$(python -c 'import matemat; print(matemat.__version__)')
test:
stage: test
script:
- pip3 install -e .
- sudo -u matemat python3.6 -m coverage run --rcfile=setup.cfg -m unittest discover matemat
- sudo -u matemat python3.6 -m coverage combine
- sudo -u matemat python3.6 -m coverage report --rcfile=setup.cfg
codestyle:
stage: test
script:
- pip3 install -e .
- sudo -u matemat pycodestyle matemat
build_docker:
stage: build
script:
- docker build -t "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_SHA" package/docker
- docker tag "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_SHA" "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_REF_NAME"
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_TOKEN registry.gitlab.com
- docker push "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_SHA"
- docker push "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_REF_NAME"
only:
- staging
- master
- tags
build_wheel:
stage: build
script:
- python3.6 setup.py egg_info bdist_wheel
- cd dist
- sha256sum *.whl > SHA256SUMS
artifacts:
paths:
- "dist/*.whl"
- dist/SHA256SUMS
only:
- 27-deployment
- tags
build_debian:
stage: build
script:
- cp -r static/ package/debian/matemat/usr/lib/matemat/static/
- cp -r templates/ package/debian/matemat/usr/lib/matemat/templates/
- python3.6 setup.py egg_info -d -b +master install --root=package/debian/matemat/ --prefix=/usr --optimize=1
- export PYTHON_BIN=$(which python3)
- cd package/debian
- chmod 0755 -R matemat/DEBIAN
- mv matemat/usr/lib/python3.6/{site,dist}-packages
- mv matemat/usr/bin/matemat matemat/usr/lib/matemat/matemat
- rm -rf matemat/usr/bin
- find . -type f -exec sed -re "s#${PYTHON_BIN}#/usr/bin/python3.6#g" -i {} \;
- dpkg-deb --build matemat
- mv matemat.deb "matemat_${MATEMAT_VERSION}-1_all.deb"
- sha256sum *.deb > SHA256SUMS
artifacts:
paths:
- "package/debian/*.deb"
- package/debian/SHA256SUMS
only:
- 27-deployment
- tags
build_archlinux:
stage: build
image: base/devel:latest # Use an archlinux image instead of the customized debian image.
script:
- pacman -Sy --noconfirm python python-setuptools python-pip python-wheel python-jinja python-pillow python-magic file
- export MATEMAT_VERSION=$(python -c 'import matemat; print(matemat.__version__)')
- cp -r static/ package/archlinux/matemat/usr/lib/matemat/static/
- cp -r templates/ package/archlinux/matemat/usr/lib/matemat/templates/
- python3 setup.py egg_info -d -b +master install --root=package/archlinux/matemat/ --prefix=/usr --optimize=1
- cd package/archlinux
- mv matemat/usr/bin/matemat matemat/usr/lib/matemat/matemat
- rm -rf matemat/usr/bin
- sed -re "s/__VERSION__/${MATEMAT_VERSION}/g" -i PKGBUILD
- sudo -u nobody makepkg -c
- sha256sum *.pkg.tar.xz > SHA256SUMS
artifacts:
paths:
- "package/archlinux/*.pkg.tar.xz"
- package/archlinux/SHA256SUMS
only:
- 27-deployment
- tags
staging:
stage: deploy
script:
- eval $(ssh-agent -s)
- ssh-add - <<<"$STAGING_SSH_PRIVATE_KEY"
- echo "$CI_COMMIT_SHA" | ssh -p 20022 -oStrictHostKeyChecking=no matemat@kernelpanic.lol
environment:
name: staging
url: https://matemat.kernelpanic.lol/
only:
- staging
release:
stage: deploy
script:
- python package/release.py
only:
- tags