forked from s3lph/matemat
137 lines
4.4 KiB
YAML
137 lines
4.4 KiB
YAML
---
|
|
image: s3lph/matemat-ci:20200203-01
|
|
|
|
stages:
|
|
- test
|
|
- build
|
|
- deploy
|
|
- upload
|
|
|
|
|
|
|
|
before_script:
|
|
- export MATEMAT_VERSION=$(python -c 'import matemat; print(matemat.__version__)')
|
|
|
|
|
|
|
|
test:
|
|
stage: test
|
|
script:
|
|
- pip3 install -e .
|
|
- sudo -u matemat python3.7 -m coverage run --rcfile=setup.cfg -m unittest discover matemat
|
|
- sudo -u matemat python3.7 -m coverage combine
|
|
- sudo -u matemat python3.7 -m coverage report --rcfile=setup.cfg
|
|
|
|
codestyle:
|
|
stage: test
|
|
script:
|
|
- pip3 install -e .
|
|
- sudo -u matemat pycodestyle matemat
|
|
|
|
|
|
|
|
build_docker_tag:
|
|
stage: build
|
|
image:
|
|
name: gcr.io/kaniko-project/executor:debug
|
|
entrypoint: [""]
|
|
script:
|
|
- mkdir -p /kaniko/.docker
|
|
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
|
|
- >-
|
|
/kaniko/executor
|
|
--context .
|
|
--dockerfile package/docker/Dockerfile
|
|
--destination "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_SHA"
|
|
--destination "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_REF_NAME"
|
|
--destination "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_TAG"
|
|
only:
|
|
- tags
|
|
|
|
build_docker_staging:
|
|
stage: build
|
|
image:
|
|
name: gcr.io/kaniko-project/executor:debug
|
|
entrypoint: [""]
|
|
script:
|
|
- mkdir -p /kaniko/.docker
|
|
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
|
|
- >-
|
|
/kaniko/executor
|
|
--context .
|
|
--dockerfile package/docker/Dockerfile
|
|
--destination "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_SHA"
|
|
--destination "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_REF_NAME"
|
|
only:
|
|
- staging
|
|
|
|
build_wheel:
|
|
stage: build
|
|
script:
|
|
- python3.7 setup.py egg_info bdist_wheel
|
|
- cd dist
|
|
- sha256sum *.whl > SHA256SUMS
|
|
artifacts:
|
|
paths:
|
|
- "dist/*.whl"
|
|
- dist/SHA256SUMS
|
|
only:
|
|
- tags
|
|
|
|
build_debian:
|
|
stage: build
|
|
script:
|
|
# 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
|
|
- echo -n > package/debian/matemat/usr/share/doc/matemat/changelog
|
|
- |
|
|
for version in "$(cat CHANGELOG.md | grep '<!-- BEGIN CHANGES' | cut -d ' ' -f 4)"; do
|
|
echo "matemat (${version}-1); urgency=medium\n" >> package/debian/matemat/usr/share/doc/matemat/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/matemat/usr/share/doc/matemat/changelog
|
|
echo "\n -- ${PACKAGE_AUTHOR} $(date -R)\n" >> package/debian/matemat/usr/share/doc/matemat/changelog
|
|
done
|
|
- 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/
|
|
- cp -r themes/ package/debian/matemat/usr/lib/matemat/themes/
|
|
- python3.7 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.7/site-packages/ matemat/usr/lib/python3/dist-packages/
|
|
- rm -rf matemat/usr/lib/python3.7/
|
|
- 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.7$#!/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
|
|
- dpkg-deb --build matemat
|
|
- mv matemat.deb "matemat_${MATEMAT_VERSION}-1_all.deb"
|
|
- sudo -u nobody lintian "matemat_${MATEMAT_VERSION}-1_all.deb"
|
|
- sha256sum *.deb > SHA256SUMS
|
|
artifacts:
|
|
paths:
|
|
- "package/debian/*.deb"
|
|
- package/debian/SHA256SUMS
|
|
only:
|
|
- tags
|
|
|
|
|
|
release:
|
|
stage: deploy
|
|
script:
|
|
- python package/release.py
|
|
only:
|
|
- tags
|
|
|
|
|
|
repo:
|
|
stage: upload
|
|
trigger: s3lph/custom-packages
|
|
variables:
|
|
MULTIPROJECT_TRIGGER_JOBNAME: matemat
|
|
only:
|
|
- tags
|