Compare commits

..

19 commits
master ... main

Author SHA1 Message Date
9cd927cc8e
feat: release v0.5.5
All checks were successful
/ test (push) Successful in 1m12s
/ codestyle (push) Successful in 1m0s
/ build_wheel (push) Successful in 1m20s
/ build_debian (push) Successful in 2m31s
2023-12-19 04:45:19 +01:00
2c29c725e5
feat: release v0.5.4
All checks were successful
/ test (push) Successful in 1m2s
/ codestyle (push) Successful in 1m0s
/ build_wheel (push) Successful in 1m19s
/ build_debian (push) Successful in 2m32s
2023-12-19 04:31:22 +01:00
4435ec6dcf
feat: migrate from woodpecker to forgejo actions
All checks were successful
/ test (push) Successful in 43s
/ codestyle (push) Successful in 1m10s
2023-12-19 04:25:25 +01:00
c7e3a79244
fix: ci badge, debian control file
Some checks failed
ci/woodpecker/tag/woodpecker Pipeline failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/manual/woodpecker Pipeline was successful
2023-10-25 04:24:18 +02:00
16f223d423
fix: ci, version 0.5.3
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2023-10-25 04:20:42 +02:00
8f21eb95e6
chore: version 0.5.2
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2023-10-25 04:13:17 +02:00
f0b6bc7d66
chore: migrate from gitlab-ci to woodpecker
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-10-25 04:10:48 +02:00
s3lph
03b4beef92 Release v0.5.1 2023-10-05 02:01:40 +02:00
s3lph
f851170231 fix: ci 2023-10-05 01:55:08 +02:00
s3lph
a6eb99f084 fix: ci 2023-10-05 01:49:51 +02:00
s3lph
00cd0ef70b fix: ci 2023-10-05 01:47:01 +02:00
s3lph
ec8cd80063 fix: ci 2023-10-05 01:37:16 +02:00
s3lph
882ba34e47 fix: ci 2023-10-05 01:33:40 +02:00
s3lph
1521aa96ce fix: ci 2023-10-05 00:29:40 +02:00
s3lph
429a48bff4 Changelog v0.5 2023-10-05 00:11:27 +02:00
s3lph
0018e11392 fix: various smaller issues in README 2023-10-05 00:10:10 +02:00
s3lph
5ad9d309b8 fix: depend on multi-user.target rather than network-online.target 2023-10-05 00:00:00 +02:00
s3lph
826a108308 Update examples to v0.4 2021-12-07 03:42:04 +01:00
s3lph
7557183a3a master -> main 2021-12-07 03:34:15 +01:00
27 changed files with 245 additions and 360 deletions

View file

@ -0,0 +1,43 @@
---
on:
push:
tags:
- "v*"
jobs:
build_wheel:
runs-on: docker
steps:
- uses: https://code.forgejo.org/actions/checkout@v4
- name: Build Python wheel
run: |
apt update; apt install -y python3-pip
pip3 install --break-system-packages -e .[test]
python3 setup.py egg_info bdist_wheel
- uses: https://git.kabelsalat.ch/s3lph/forgejo-action-wheel-package-upload@v3
with:
username: ${{ secrets.API_USERNAME }}
password: ${{ secrets.API_PASSWORD }}
build_debian:
runs-on: docker
steps:
- uses: https://code.forgejo.org/actions/checkout@v4
- name: Prepare package
run: |
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
- uses: https://git.kabelsalat.ch/s3lph/forgejo-action-python-debian-package@v4
with:
python_module: spaceapi_server
package_name: spaceapi-server
package_root: package/debian/spaceapi-server
package_output_path: package/debian
- uses: https://git.kabelsalat.ch/s3lph/forgejo-action-debian-package-upload@v2
with:
username: ${{ secrets.API_USERNAME }}
password: ${{ secrets.API_PASSWORD }}
deb: "package/debian/*.deb"

View file

@ -0,0 +1,27 @@
---
on: push
jobs:
test:
runs-on: docker
steps:
- uses: https://code.forgejo.org/actions/checkout@v4
- name: test
run: |
apt update; apt install --yes python3-pip
pip3 install --break-system-packages -e .[test]
python3 -m coverage run --rcfile=setup.cfg -m unittest discover spaceapi_server
python3 -m coverage combine
python3 -m coverage report --rcfile=setup.cfg
codestyle:
runs-on: docker
steps:
- uses: https://code.forgejo.org/actions/checkout@v4
- name: codestyle
run: |
apt update; apt install --yes python3-pip
pip3 install --break-system-packages -e .[test]
pycodestyle spaceapi_server

View file

@ -1,164 +0,0 @@
---
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/example.py package/debian/spaceapi-server/etc/spaceapi-server/plugins/example.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
build_archlinux:
stage: build
image: archlinux:latest # Use an archlinux image instead of the customized debian image.
script:
- find package/archlinux -name .gitkeep -delete
# Install dependencies
- pacman -Sy --noconfirm namcap python python-setuptools python-pip python-wheel python-yaml python-bottle base-devel
- export SPACEAPI_SERVER_VERSION=$(python -c 'import spaceapi_server; print(spaceapi_server.__version__)')
# Copy example plugin
- install -m0644 examples/plugins/example.py package/archlinux/spaceapi-server/etc/spaceapi-server/plugins/example.py
# Create changelog
- |
for version in "$(cat CHANGELOG.md | grep '<!-- BEGIN CHANGES' | cut -d ' ' -f 4)"; do
echo "$(date +%Y-%m-%d) s3lph <account-gitlab-ideynizv@kernelpanic.lol>" >> package/archlinux/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/^-/\t*/g' >> package/archlinux/spaceapi-server.changelog
echo >> package/archlinux/spaceapi-server.changelog
done
# Copy license
- install -m0644 LICENSE package/archlinux/spaceapi-server/usr/share/licenses/spaceapi-server/LICENSE
# Install spaceapi-server into pkgdir
- python setup.py egg_info -d -b +master install --root=package/archlinux/spaceapi-server/ --prefix=/usr --optimize=1
- cd package/archlinux
# Remove spaceapi-server script
- rm -rf spaceapi-server/usr/bin
# Build the package
- sed -re "s/__VERSION__/${SPACEAPI_SERVER_VERSION}/g" -i PKGBUILD
- sudo -u nobody makepkg -c
# Run namcap
- sudo -u nobody namcap *.pkg.tar.*
# Generate checksum
- sha256sum *.pkg.tar.* > SHA256SUMS
artifacts:
paths:
- "package/archlinux/*.pkg.tar.*"
- package/archlinux/SHA256SUMS
only:
- tags
build_docker:
stage: build
script:
- docker build -t "registry.gitlab.com/s3lph/spaceapi-server:$CI_COMMIT_SHA" -f package/docker/Dockerfile .
- docker tag "registry.gitlab.com/s3lph/spaceapi-server:$CI_COMMIT_SHA" "registry.gitlab.com/s3lph/spaceapi-server:$CI_COMMIT_REF_NAME"
- if [[ -n "$CI_COMMIT_TAG" ]]; then docker tag "registry.gitlab.com/s3lph/spaceapi-server:$CI_COMMIT_SHA" "registry.gitlab.com/s3lph/spaceapi-server:$CI_COMMIT_TAG"; fi
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_TOKEN registry.gitlab.com
- docker push "registry.gitlab.com/s3lph/spaceapi-server:$CI_COMMIT_SHA"
- docker push "registry.gitlab.com/s3lph/spaceapi-server:$CI_COMMIT_REF_NAME"
- if [[ -n "$CI_COMMIT_TAG" ]]; then docker push "registry.gitlab.com/s3lph/spaceapi-server:$CI_COMMIT_TAG"; fi
only:
- tags
release:
stage: release
script:
- python3 package/release.py
only:
- tags

View file

@ -1,5 +1,72 @@
# SpaceAPI Server Changelog
<!-- BEGIN RELEASE v0.5.5 -->
## Version 0.5.5
Bugfix & Maintenance release
### Changes
<!-- BEGIN CHANGES 0.5.5 -->
- Add SpaceAPI Schema v14 in example
- Fix template filename in example config.yaml
<!-- END CHANGES 0.5.5 -->
<!-- END RELEASE v0.5.5 -->
<!-- BEGIN RELEASE v0.5.4 -->
## Version 0.5.4
Maintenance build
### Changes
<!-- BEGIN CHANGES 0.5.4 -->
- Migration from Woodpecker to Forgejo Actions
<!-- END CHANGES 0.5.4 -->
<!-- END RELEASE v0.5.4 -->
<!-- BEGIN RELEASE v0.5.2 -->
## Version 0.5.2
Maintenance build
### Changes
<!-- BEGIN CHANGES 0.5.2 -->
- Migration from Gitlab to Gitea+Woodpecker
<!-- END CHANGES 0.5.2 -->
<!-- END RELEASE v0.5.2 -->
<!-- BEGIN RELEASE v0.5.1 -->
## Version 0.5.1
Maintenance build
### Changes
<!-- BEGIN CHANGES 0.5.1 -->
- Fix: CI & Release process
<!-- END CHANGES 0.5.1 -->
<!-- END RELEASE v0.5.1 -->
<!-- BEGIN RELEASE v0.5 -->
## Version 0.5
Update Readme, fix systemd unit
### Changes
<!-- BEGIN CHANGES 0.5 -->
- Fix: Systemd unit now depends on multi-user.target
- Fix smaller issues in Readme and update for SpaceAPI v14
<!-- END CHANGES 0.5 -->
<!-- END RELEASE v0.5 -->
<!-- BEGIN RELEASE v0.4 -->
## Version 0.4

View file

@ -1,8 +1,5 @@
# SpaceAPI Server
[![pipeline status](https://gitlab.com/s3lph/spaceapi-server/badges/master/pipeline.svg)][master]
[![coverage report](https://gitlab.com/s3lph/spaceapi-server/badges/master/coverage.svg)][master]
A lightweight server for [SpaceAPI][spaceapi] endpoints. Includes
support for pluggable templating, so dynamic content, like sensor
values, can be added.
@ -42,6 +39,7 @@ look up and return your dynamic content.
```yaml
---
api: "0.13"
api_compatibility: ["14"]
space: My Hackerspace
# This is a plugin invocation
# with no arguments
@ -60,6 +58,8 @@ sensors:
```json
{
"api": "0.13",
"api_compatibility": ["14"],
"space": "My Hackerspace",
"state": {
"open": true,
"lastchange": 1575160777,
@ -90,14 +90,12 @@ sensors:
### 0. Download
Head over to the [Releases][releases], download and install the
package that suits your needs. Alternatively, clone the repo and get
started. There also is a Container Image available through the
[Gitlab registry][registry] tagged as
`registry.gitlab.com/s3lph/spaceapi-server`.
Head over to the [Packages][packages] tab, download and install the
package that suits your needs or set up the Debian repository.
Alternatively, clone the repo and get started.
The remainder of this document assumes that you installed the
server as an OS distribution package.
server as a Debian package.
### 1. Overview
@ -149,7 +147,7 @@ The content is served "almost-as-is" (apart from the conversion from
YAML to JSON).
To learn about how a SpaceAPI response should look like, have a look
at [SpaceAPI: Getting Started][spaceapi-getting-started].
at the [SpaceAPI Website][spaceapi].
### 4. Add Dynamic Content
@ -290,9 +288,10 @@ from spaceapi_server import plugins
def lookup_sensor(query, default=None):
# Do something with the query
result = ...
# If the loo
# If the lookup failed, return a default value
if not result:
return default or []
return result
```
```yaml
@ -303,12 +302,11 @@ state: !lookup_sensor
```
[master]: https://gitlab.com/s3lph/spaceapi-server/commits/master
[releases]: https://gitlab.com/s3lph/spaceapi-server/-/releases
[main]: https://gitlab.com/s3lph/spaceapi-server/commits/main
[packages]: https://git.kabelsalat.ch/s3lph/spaceapi-server/packages
[spaceapi]: https://spaceapi.io/
[pypi-bottle]: https://pypi.org/project/bottle/
[pypi-yaml]: https://pypi.org/project/PyYAML/
[mit]: https://gitlab.com/s3lph/spaceapi-server/blob/master/LICENSE
[spaceapi-getting-started]: https://spaceapi.io/getting-started/
[mit]: https://gitlab.com/s3lph/spaceapi-server/blob/main/LICENSE
[jinja]: https://jinja.palletsprojects.com/
[registry]: https://gitlab.com/s3lph/spaceapi-server/container_registry

View file

@ -1,13 +0,0 @@
{
"address": "::1",
"port": 8000,
"template": "examples/template.json",
"plugins_dir": "examples/plugins",
"plugins": {
"example": {
"test_value": "the Spanish Inquisition"
}
}
}

16
examples/config.yaml Normal file
View file

@ -0,0 +1,16 @@
---
# The address to listen on.
address: "::1"
# The TCP port to listen on.
port: 8000
# The Bottle backend server to use.
server: wsgiref
# Path to the SpaceAPI response template file.
template: template.yaml
# Path to the directory containing your plugins.
plugins_dir: plugins
plugins:
# Config for the "filestate" plugin
filestate:
# Use this statefile instead of the default
filename: /var/www/html/space_state

View file

@ -1,36 +0,0 @@
from spaceapi_server import plugins
@plugins.template_function
def example_function(name: str):
"""
This function is registered as a Jinja2 function. It can be used like this:
{{ example_function('the Spanish Inquisition') }}
"""
return f'Nobody expects {name}'
@plugins.template_filter
def example_filter(name: str):
"""
This function is registered as a Jinja2 filter. It can be used like this:
{{ 'the Spanish Inquisition' | example_filter }}
"""
return f'Nobody expects {name}'
@plugins.template_function
def example_config_function():
"""
This function demonstrates the use of configuration.
{( example_config_function() }}
"""
# Config lookup example. A plugin's config should be below
# `.plugins[plugin_name]` (JSONPath)
# Get the .plugins.example dict
conf = plugins.get_plugin_config('example')
# Get the .test_value property from the plugin config, falling
# back to a default value
return conf.get('test_value', 'the Spanish Inquisition')

View file

@ -0,0 +1,23 @@
import os
from spaceapi_server import config, plugins
@plugins.template_function
# The plugin can be invoked by using the !space_state YAML tag
def space_state():
# Get the plugin config dict
conf = config.get_plugin_config('filestate')
# Get the filename, default to /var/space_state
filename = conf.get('filename', '/var/space_state')
try:
# Get the file's properties
stat = os.stat(filename)
except FileNotFoundError:
# File doesn't exist, aka. space is closed
return {
'open': False
}
# File exists, aka. space is open. Also report the mtime as "last changed" timestamp
return {
'open': True,
'lastchange': int(stat.st_mtime)
}

View file

@ -1,20 +0,0 @@
{
"api": "0.13 {#- Go look at https://spaceapi.io/docs -#}",
"space": "Our New Hackerspace",
"logo": "https://example.org/logo.png",
"url": "https://example.org/",
"location": {
"lat": 0.0,
"lon": 0.0
},
"contact": {
"email": "example@example.org"
},
"issue_report_channels": [
"email"
],
"state": "{#- You can write your own plugins for retrieving dynamic information -#} {{ our_space_state() }}",
"sensors": {
"people_now_present": "{{ our_sensor_backend('people_count') }}"
}
}

12
examples/template.yaml Normal file
View file

@ -0,0 +1,12 @@
---
api: "0.13"
space: My Hackerspace
# This is a plugin invocation
# with no arguments
state: !space_state {}
sensors:
# This is a plugin invocation with
# arguments. They are passed to the
# plugin function as kwargs.
network_connections: !network_connections
networks: [ "2.4 GHz", "5 GHz" ]

View file

@ -1,6 +0,0 @@
FROM python:3.9-buster as python
RUN apt update \
&& apt install -y --no-install-recommends lintian rsync sudo docker.io \
&& pip3 install pycodestyle coverage \
&& rm -rf /var/cache/apt

View file

@ -1,27 +0,0 @@
# Maintainer: s3lph <account-gitlab-ideynizv@kernelpanic.lol>
pkgname=spaceapi-server
pkgver=__VERSION__
pkgrel=1
pkgdesc="Lightweight SpaceAPI endpoint server"
arch=('any')
url="https://gitlab.com/s3lph/spaceapi-server"
license=('MIT')
groups=()
depends=('python'
'python-yaml'
'python-bottle')
makedepends=('python-setuptools')
checkdepends=()
optdepends=()
provides=()
conflicts=()
replaces=()
backup=('etc/spaceapi-server/config.yaml'
'etc/spaceapi-server/template.yaml'
'etc/spaceapi-server/plugins')
install=$pkgname.install
changelog=$pkgname.changelog
package() {
cp -r ../spaceapi-server/* ../pkg/spaceapi-server/
}

View file

@ -1,31 +0,0 @@
post_install() {
if ! getent group spaceapi-server >/dev/null; then
groupadd --system spaceapi-server
fi
if ! getent passwd spaceapi-server >/dev/null; then
useradd --system --create-home --gid spaceapi-server --home-dir /var/lib/spaceapi-server \
--shell /usr/sbin/nologin spaceapi-server
fi
chown root:spaceapi-server /etc/spaceapi-server
chmod 0750 /etc/spaceapi-server
systemctl daemon-reload || true
}
pre_remove() {
systemctl stop spaceapi-server.service
userdel spaceapi-server
}
post_remove() {
systemctl daemon-reload
}

View file

@ -1,6 +0,0 @@
---
address: "::"
port: 8080
template: /etc/spaceapi-server/template.json
plugins_dir: /etc/spaceapi-server/plugins
plugins: {}

View file

@ -1,14 +0,0 @@
---
api: "0.13"
space: Example
logo: https://example.org/logo.png
url: https://example.org
location:
lat: 0.0
lon: 0.0
state:
open: null
contact:
email: example@example.org
issue_report_channels:
- email

View file

@ -1,10 +0,0 @@
[Unit]
Description=Lightweight SpaceAPI Endpoint Server
[Service]
ExecStart=/usr/bin/python -m spaceapi_server /etc/spaceapi-server/config.yaml
ExecReload=/usr/bin/kill -HUP $MAINPID
User=spaceapi-server
[Install]
WantedBy=network-online.target

View file

@ -1,3 +1,3 @@
/etc/spaceapi-server/config.yaml
/etc/spaceapi-server/template.yaml
/etc/spaceapi-server/plugins/example.py
/etc/spaceapi-server/plugins/filestate.py

View file

@ -0,0 +1,10 @@
Package: spaceapi-server
Version: __VERSION__
Maintainer: s3lph <s3lph@kabelsalat.ch>
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.

View file

@ -1,6 +1,6 @@
---
address: "::"
port: 8080
template: /etc/spaceapi-server/template.json
template: /etc/spaceapi-server/template.yaml
plugins_dir: /etc/spaceapi-server/plugins
plugins: {}

View file

@ -1,5 +1,7 @@
---
api: "0.13"
api_compatibility:
- "14"
space: Example
logo: https://example.org/logo.png
url: https://example.org

View file

@ -7,4 +7,4 @@ ExecReload=/usr/bin/kill -HUP $MAINPID
User=spaceapi-server
[Install]
WantedBy=network-online.target
WantedBy=multi-user.target

View file

@ -87,14 +87,6 @@ def fetch_debian_url(base_url: str, job_ids: Dict[str, str]) -> Optional[Tuple[s
return debian_url, debian_sha_url
def fetch_arch_url(base_url: str, job_ids: Dict[str, str]) -> Optional[Tuple[str, str]]:
mybase: str = f'{base_url}/jobs/{job_ids["build_archlinux"]}/artifacts/raw'
arch_sha_url: str = f'{mybase}/package/archlinux/SHA256SUMS'
arch_filename: str = fetch_single_shafile(arch_sha_url)
arch_url: str = f'{mybase}/package/archlinux/{arch_filename}'
return arch_url, arch_sha_url
def main():
api_token: Optional[str] = os.getenv('GITLAB_API_TOKEN')
release_tag: Optional[str] = os.getenv('CI_COMMIT_TAG')
@ -128,24 +120,39 @@ def main():
wheel_url, wheel_sha_url = fetch_wheel_url(base_url, job_ids)
debian_url, debian_sha_url = fetch_debian_url(base_url, job_ids)
arch_url, arch_sha_url = fetch_arch_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}))
- [Arch Linux Package]({arch_url}) ([sha256]({arch_sha_url}))'''
- [Debian Package]({debian_url}) ([sha256]({debian_sha_url}))'''
post_body: str = json.dumps({'description': augmented_changelog})
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}/repository/tags/{release_tag}/release'
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': USER_AGENT
'User-Agent': 'curl/7.70.0'
}
request = urllib.request.Request(

View file

@ -21,6 +21,13 @@ setup(
'bottle',
'PyYAML',
],
extras_require={
'test': [
'coverage',
'pycodestyle',
'twine'
]
},
entry_points={
'console_scripts': [
'spaceapi-server = spaceapi_server:start'

View file

@ -1,2 +1,2 @@
__version__ = '0.4'
__version__ = '0.5.5'