chore: migrate from gitlab-ci to woodpecker
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
01deb63098
commit
86f0eecc34
15 changed files with 118 additions and 388 deletions
137
.gitlab-ci.yml
137
.gitlab-ci.yml
|
@ -1,137 +0,0 @@
|
||||||
---
|
|
||||||
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/themes/
|
|
||||||
- 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
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +0,0 @@
|
||||||
[submodule "doc"]
|
|
||||||
path = doc
|
|
||||||
url = gitlab.com:s3lph/matemat.wiki.git
|
|
91
.woodpecker.yml
Normal file
91
.woodpecker.yml
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
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}
|
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -1,5 +1,18 @@
|
||||||
# Matemat Changelog
|
# Matemat Changelog
|
||||||
|
|
||||||
|
<!-- BEGIN RELEASE v0.3.6 -->
|
||||||
|
## Version 0.3.6
|
||||||
|
|
||||||
|
Migration from Gitlab to Forgejo
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
|
||||||
|
<!-- BEGIN CHANGES 0.3.6-->
|
||||||
|
- Migration from Gitlab to Forgejo
|
||||||
|
<!-- END CHANGES 0.3.6 -->
|
||||||
|
|
||||||
|
<!-- END RELEASE v0.3.6 -->
|
||||||
|
|
||||||
<!-- BEGIN RELEASE v0.3.5 -->
|
<!-- BEGIN RELEASE v0.3.5 -->
|
||||||
## Version 0.3.5
|
## Version 0.3.5
|
||||||
|
|
||||||
|
|
12
README.md
12
README.md
|
@ -1,7 +1,6 @@
|
||||||
# Matemat
|
# Matemat
|
||||||
|
|
||||||
[![pipeline status](https://gitlab.com/s3lph/matemat/badges/master/pipeline.svg)][master]
|
[![status-badge](https://woodpecker.kabelsalat.ch/api/badges/80/status.svg)](https://woodpecker.kabelsalat.ch/repos/80)
|
||||||
[![coverage report](https://gitlab.com/s3lph/matemat/badges/master/coverage.svg)][master]
|
|
||||||
|
|
||||||
A web service for automated stock-keeping of a soda machine written in Python.
|
A web service for automated stock-keeping of a soda machine written in Python.
|
||||||
It provides a touch-input-friendly user interface (as most input happens through the
|
It provides a touch-input-friendly user interface (as most input happens through the
|
||||||
|
@ -10,10 +9,6 @@ soda machine's touch screen).
|
||||||
This project intends to provide a well-tested and maintainable alternative to
|
This project intends to provide a well-tested and maintainable alternative to
|
||||||
[ckruse/matemat][oldapp] (last commit 2013-07-09).
|
[ckruse/matemat][oldapp] (last commit 2013-07-09).
|
||||||
|
|
||||||
## Further Documentation
|
|
||||||
|
|
||||||
[Wiki][wiki]
|
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
- Python 3 (>=3.6)
|
- Python 3 (>=3.6)
|
||||||
|
@ -37,10 +32,7 @@ python -m matemat
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
[MIT License][mit-license]
|
MIT License
|
||||||
|
|
||||||
|
|
||||||
[oldapp]: https://github.com/ckruse/matemat
|
[oldapp]: https://github.com/ckruse/matemat
|
||||||
[mit-license]: https://gitlab.com/s3lph/matemat/blob/master/LICENSE
|
|
||||||
[master]: https://gitlab.com/s3lph/matemat/commits/master
|
|
||||||
[wiki]: https://gitlab.com/s3lph/matemat/wikis/home
|
|
1
doc
1
doc
|
@ -1 +0,0 @@
|
||||||
Subproject commit 399bd80af7d08c81677bad56c9b71b6365eecf69
|
|
|
@ -1,15 +0,0 @@
|
||||||
[Matemat]
|
|
||||||
|
|
||||||
Address=::
|
|
||||||
Port=80
|
|
||||||
|
|
||||||
StaticPath=/static
|
|
||||||
TemplatePath=/templates
|
|
||||||
ThemePath=/themes
|
|
||||||
Theme=base
|
|
||||||
|
|
||||||
LogTarget=stdout
|
|
||||||
|
|
||||||
[Pagelets]
|
|
||||||
UploadDir=/static/upload
|
|
||||||
DatabaseFile=/var/matemat/db/test.db
|
|
|
@ -1,2 +1,2 @@
|
||||||
|
|
||||||
__version__ = '0.3.5'
|
__version__ = '0.3.6'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Package: matemat
|
Package: matemat
|
||||||
Version: 0.3.5
|
Version: __VERSION__
|
||||||
Maintainer: s3lph <1375407-s3lph@users.noreply.gitlab.com>
|
Maintainer: s3lph <s3lph@kabelsalat.ch>
|
||||||
Section: web
|
Section: web
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Architecture: all
|
Architecture: all
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
|
|
||||||
FROM python:3.9-alpine
|
|
||||||
|
|
||||||
ADD . /
|
|
||||||
RUN mkdir -p /var/matemat/db /var/matemat/upload \
|
|
||||||
&& chown 1000:0 -R /var/matemat/db /var/matemat/upload \
|
|
||||||
&& chmod g=u -R /var/matemat/db /var/matemat/upload \
|
|
||||||
&& apk --update add libmagic zlib jpeg zlib-dev jpeg-dev build-base \
|
|
||||||
&& pip3 install -e . \
|
|
||||||
&& apk del zlib-dev jpeg-dev build-base \
|
|
||||||
&& rm -rf /var/cache/apk /root/.cache/pip \
|
|
||||||
&& rm -rf /package
|
|
||||||
|
|
||||||
USER 1000
|
|
||||||
|
|
||||||
EXPOSE 80/tcp
|
|
||||||
CMD [ "/run.sh" ]
|
|
|
@ -1,180 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
from typing import Any, Dict, List, Optional, Tuple
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import json
|
|
||||||
import urllib.request
|
|
||||||
import http.client
|
|
||||||
from urllib.error import HTTPError
|
|
||||||
|
|
||||||
|
|
||||||
def parse_changelog(tag: str) -> Optional[str]:
|
|
||||||
release_changelog: str = ''
|
|
||||||
with open('CHANGELOG.md', 'r') as f:
|
|
||||||
in_target: bool = False
|
|
||||||
done: bool = False
|
|
||||||
for line in f.readlines():
|
|
||||||
if in_target:
|
|
||||||
if f'<!-- END RELEASE {tag} -->' in line:
|
|
||||||
done = True
|
|
||||||
break
|
|
||||||
release_changelog += line
|
|
||||||
elif f'<!-- BEGIN RELEASE {tag} -->' in line:
|
|
||||||
in_target = True
|
|
||||||
continue
|
|
||||||
if not done:
|
|
||||||
return None
|
|
||||||
return release_changelog
|
|
||||||
|
|
||||||
|
|
||||||
def fetch_job_ids(project_id: int, pipeline_id: int, api_token: str) -> Dict[str, str]:
|
|
||||||
url: str = f'https://gitlab.com/api/v4/projects/{project_id}/pipelines/{pipeline_id}/jobs'
|
|
||||||
headers: Dict[str, str] = {
|
|
||||||
'Private-Token': api_token,
|
|
||||||
'User-Agent': 'curl/7.70.0'
|
|
||||||
}
|
|
||||||
req = urllib.request.Request(url, headers=headers)
|
|
||||||
try:
|
|
||||||
resp: http.client.HTTPResponse = urllib.request.urlopen(req)
|
|
||||||
except HTTPError as e:
|
|
||||||
print(e.read().decode())
|
|
||||||
sys.exit(1)
|
|
||||||
resp_data: bytes = resp.read()
|
|
||||||
joblist: List[Dict[str, Any]] = json.loads(resp_data.decode())
|
|
||||||
|
|
||||||
jobidmap: Dict[str, str] = {}
|
|
||||||
for job in joblist:
|
|
||||||
name: str = job['name']
|
|
||||||
job_id: str = job['id']
|
|
||||||
jobidmap[name] = job_id
|
|
||||||
return jobidmap
|
|
||||||
|
|
||||||
|
|
||||||
def fetch_single_shafile(url: str) -> str:
|
|
||||||
headers: Dict[str, str] = {
|
|
||||||
'User-Agent': 'curl/7.70.0'
|
|
||||||
}
|
|
||||||
req = urllib.request.Request(url, headers=headers)
|
|
||||||
try:
|
|
||||||
resp: http.client.HTTPResponse = urllib.request.urlopen(req)
|
|
||||||
except HTTPError as e:
|
|
||||||
print(e.read().decode())
|
|
||||||
sys.exit(1)
|
|
||||||
resp_data: bytes = resp.readline()
|
|
||||||
shafile: str = resp_data.decode()
|
|
||||||
filename: str = shafile.strip().split(' ')[-1].strip()
|
|
||||||
return filename
|
|
||||||
|
|
||||||
|
|
||||||
def fetch_wheel_url(base_url: str, job_ids: Dict[str, str]) -> Optional[Tuple[str, str]]:
|
|
||||||
mybase: str = f'{base_url}/jobs/{job_ids["build_wheel"]}/artifacts/raw'
|
|
||||||
wheel_sha_url: str = f'{mybase}/dist/SHA256SUMS'
|
|
||||||
wheel_filename: str = fetch_single_shafile(wheel_sha_url)
|
|
||||||
wheel_url: str = f'{mybase}/dist/{wheel_filename}'
|
|
||||||
return wheel_url, wheel_sha_url
|
|
||||||
|
|
||||||
|
|
||||||
def fetch_debian_url(base_url: str, job_ids: Dict[str, str]) -> Optional[Tuple[str, str]]:
|
|
||||||
mybase: str = f'{base_url}/jobs/{job_ids["build_debian"]}/artifacts/raw'
|
|
||||||
debian_sha_url: str = f'{mybase}/package/debian/SHA256SUMS'
|
|
||||||
debian_filename: str = fetch_single_shafile(debian_sha_url)
|
|
||||||
debian_url: str = f'{mybase}/package/debian/{debian_filename}'
|
|
||||||
return debian_url, debian_sha_url
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
api_token: Optional[str] = os.getenv('GITLAB_API_TOKEN')
|
|
||||||
release_tag: Optional[str] = os.getenv('CI_COMMIT_TAG')
|
|
||||||
project_name: Optional[str] = os.getenv('CI_PROJECT_PATH')
|
|
||||||
project_id: Optional[str] = os.getenv('CI_PROJECT_ID')
|
|
||||||
pipeline_id: Optional[str] = os.getenv('CI_PIPELINE_ID')
|
|
||||||
if api_token is None:
|
|
||||||
print('GITLAB_API_TOKEN is not set.', file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
if release_tag is None:
|
|
||||||
print('CI_COMMIT_TAG is not set.', file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
if project_name is None:
|
|
||||||
print('CI_PROJECT_PATH is not set.', file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
if project_id is None:
|
|
||||||
print('CI_PROJECT_ID is not set.', file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
if pipeline_id is None:
|
|
||||||
print('CI_PIPELINE_ID is not set.', file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
changelog: Optional[str] = parse_changelog(release_tag)
|
|
||||||
if changelog is None:
|
|
||||||
print('Changelog could not be parsed.', file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
job_ids: Dict[str, str] = fetch_job_ids(project_id, pipeline_id, api_token)
|
|
||||||
|
|
||||||
base_url: str = f'https://gitlab.com/{project_name}/-'
|
|
||||||
|
|
||||||
wheel_url, wheel_sha_url = fetch_wheel_url(base_url, job_ids)
|
|
||||||
debian_url, debian_sha_url = fetch_debian_url(base_url, job_ids)
|
|
||||||
|
|
||||||
augmented_changelog = f'''{changelog.strip()}
|
|
||||||
|
|
||||||
### Download
|
|
||||||
|
|
||||||
- [Python Wheel]({wheel_url}) ([sha256]({wheel_sha_url}))
|
|
||||||
- [Debian Package]({debian_url}) ([sha256]({debian_sha_url}))
|
|
||||||
- Docker image: registry.gitlab.com/{project_name}:{release_tag}'''
|
|
||||||
|
|
||||||
post_body: str = json.dumps({
|
|
||||||
'tag_name': release_tag,
|
|
||||||
'description': augmented_changelog,
|
|
||||||
'assets': {
|
|
||||||
'links': [
|
|
||||||
{
|
|
||||||
'name': 'Python Wheel',
|
|
||||||
'url': wheel_url,
|
|
||||||
'link_type': 'package'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Debian Package',
|
|
||||||
'url': debian_url,
|
|
||||||
'link_type': 'package'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
gitlab_release_api_url: str = \
|
|
||||||
f'https://gitlab.com/api/v4/projects/{project_id}/releases'
|
|
||||||
headers: Dict[str, str] = {
|
|
||||||
'Private-Token': api_token,
|
|
||||||
'Content-Type': 'application/json; charset=utf-8',
|
|
||||||
'User-Agent': 'curl/7.70.0'
|
|
||||||
}
|
|
||||||
|
|
||||||
request = urllib.request.Request(
|
|
||||||
gitlab_release_api_url,
|
|
||||||
post_body.encode('utf-8'),
|
|
||||||
headers=headers,
|
|
||||||
method='POST'
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
response: http.client.HTTPResponse = urllib.request.urlopen(request)
|
|
||||||
except HTTPError as e:
|
|
||||||
print(e.read().decode())
|
|
||||||
sys.exit(1)
|
|
||||||
response_bytes: bytes = response.read()
|
|
||||||
response_str: str = response_bytes.decode()
|
|
||||||
response_data: Dict[str, Any] = json.loads(response_str)
|
|
||||||
|
|
||||||
if response_data['tag_name'] != release_tag:
|
|
||||||
print('Something went wrong...', file=sys.stderr)
|
|
||||||
print(response_str, file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
print(response_data['description'])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
5
run.sh
5
run.sh
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
export LD_PRELOAD=/usr/lib/libmagic.so.1
|
|
||||||
|
|
||||||
/usr/local/bin/python3 -m matemat /etc/matemat.conf /matemat.docker.conf
|
|
9
setup.py
9
setup.py
|
@ -5,7 +5,7 @@ from matemat import __version__
|
||||||
setup(
|
setup(
|
||||||
name='matemat',
|
name='matemat',
|
||||||
version=__version__,
|
version=__version__,
|
||||||
url='https://gitlab.com/s3lph/matemat',
|
url='https://git.kabelsalat.ch/s3lph/matemat',
|
||||||
license='MIT',
|
license='MIT',
|
||||||
author='s3lph',
|
author='s3lph',
|
||||||
author_email='',
|
author_email='',
|
||||||
|
@ -25,6 +25,13 @@ soda machine's touch screen).
|
||||||
'Pillow',
|
'Pillow',
|
||||||
'netaddr'
|
'netaddr'
|
||||||
],
|
],
|
||||||
|
extras_require={
|
||||||
|
'test': [
|
||||||
|
'coverage',
|
||||||
|
'pycodestyle',
|
||||||
|
'twine'
|
||||||
|
]
|
||||||
|
},
|
||||||
test_loader='unittest:TestLoader',
|
test_loader='unittest:TestLoader',
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
|
|
|
@ -50,9 +50,7 @@
|
||||||
<li> {{ setupname|safe }}
|
<li> {{ setupname|safe }}
|
||||||
<li> Matemat {{ __version__ }}
|
<li> Matemat {{ __version__ }}
|
||||||
<li> MIT License
|
<li> MIT License
|
||||||
{# This used to be a link to the GitLab repo. However, users of the testing environment always clicked
|
<li> git.kabelsalat.ch/s3lph/matemat
|
||||||
that link and couldn't come back, because the UI was running in touch-only kiosk mode. #}
|
|
||||||
<li> gitlab.com/s3lph/matemat
|
|
||||||
</ul>
|
</ul>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
|
|
||||||
FROM python:3.7-buster
|
|
||||||
|
|
||||||
RUN useradd -d /home/matemat -m matemat \
|
|
||||||
&& mkdir -p /var/matemat/db /var/matemat/upload \
|
|
||||||
&& chown matemat:0 -R /var/matemat/db /var/matemat/upload \
|
|
||||||
&& chmod g=u -R /var/matemat/db /var/matemat/upload \
|
|
||||||
&& apt-get update -qy \
|
|
||||||
&& apt-get install -y --no-install-recommends file sudo openssh-client git docker.io build-essential lintian rsync \
|
|
||||||
&& python3.7 -m pip install coverage wheel pycodestyle mypy \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
WORKDIR /home/matemat
|
|
Loading…
Reference in a new issue