| 1 |
#!/bin/sh |
| 2 |
# SPDX-FileCopyrightText: Christian Amsüss |
| 3 |
# SPDX-License-Identifier: MIT |
| 4 |
|
| 5 |
set -xeuo pipefail |
| 6 |
|
| 7 |
mkdir -p public |
| 8 |
|
| 9 |
# always the case in CI … but not locally, and not when we do quick CI runs |
| 10 |
# where tests are skipped |
| 11 |
if [ -e .coverage ] |
| 12 |
then |
| 13 |
export COVERAGE_FILE=.coverage/cov |
| 14 |
python3 -m coverage combine |
| 15 |
python3 -m coverage report |
| 16 |
python3 -m coverage html -d public/coverage/ |
| 17 |
fi |
| 18 |
|
| 19 |
./.woodpecker/badges.sh |
| 20 |
|
| 21 |
WHEEL=$(cd dist && echo *.whl) |
| 22 |
DESCRIBE=$(git describe --always) |
| 23 |
# Link for the wheel goes to the `raw.` URI because that allows CORS, |
| 24 |
# making it useful as a pyodide source. |
| 25 |
cat > public/index.html <<EOF |
| 26 |
<!DOCTYPE html> |
| 27 |
<html> |
| 28 |
<head> |
| 29 |
<title>aiocoap build artifacts</title> |
| 30 |
</head> |
| 31 |
<body> |
| 32 |
<h1>aiocoap build artifacts</h1> |
| 33 |
<ul> |
| 34 |
<li><a href="coverage/">Coverage report</a> |
| 35 |
<li><a href="doc/">Documentation</a> |
| 36 |
<li><a href="https://raw.codeberg.page/aiocoap/aiocoap/@pages/dist/${WHEEL}">Current wheel</a> |
| 37 |
</ul> |
| 38 |
<!-- |
| 39 |
<p>This URL (but without the trailing slash) also serves as a Python index API entry point (simple HTML index). |
| 40 |
|
| 41 |
Or "could serve", because in pyodide practice it works neither with the |
| 42 |
aiocoap.codeberg.page version (for lack of CORS), nor with the |
| 43 |
raw.codeberg.page version (for lack of non-text/plain content types, |
| 44 |
and micropip relies on content types) |
| 45 |
--> |
| 46 |
<footer>Current version described as ${DESCRIBE} |
| 47 |
</body> |
| 48 |
</html> |
| 49 |
EOF |
| 50 |
cat public/index.html |
| 51 |
|
| 52 |
# Our files accumulate, so let's keep the older versions we do have visible also in the index. |
| 53 |
# At least in CI, we'll have to get that list before we can access it. |
| 54 |
git fetch origin pages --depth=1 --filter=blob:none |
| 55 |
|
| 56 |
# Debug helpers for when something goes awry in the index building |
| 57 |
ls -la public/dist |
| 58 |
git ls-tree --name-only origin/pages:dist/ |
| 59 |
|
| 60 |
# We're mainly hosting aiocoap wheels here, but have some lakers-python builds |
| 61 |
# in the pages tree as well to aid use from pyodide before pyodide-recipes have |
| 62 |
# been disseminated all through the ecosystem. |
| 63 |
# |
| 64 |
# Note that for actual use by pyodide, the resulting pages are currently |
| 65 |
# mirrored onto coap.amsuess.com to get CORS and media types right … and all |
| 66 |
# that is a workaround for <https://codeberg.org/forgejo/forgejo/issues/9361> |
| 67 |
# -- once that's through, we can just push packages, remove these from pages |
| 68 |
# (possibly truncating its history to get it slim again) and switch over to |
| 69 |
# Codeberg packages completely. |
| 70 |
for PACKAGE in aiocoap lakers-python |
| 71 |
do |
| 72 |
# Our public directory will also serve as PyPI index in application/vnd.pypi.simple.v1+html format. |
| 73 |
# The base URI is the pages URI without a trailing slash. |
| 74 |
|
| 75 |
PACKAGEFILE=$(echo $PACKAGE | tr - _) |
| 76 |
mkdir -p public/$PACKAGE/ |
| 77 |
cat > public/$PACKAGE/index.html <<EOF |
| 78 |
<!DOCTYPE html> |
| 79 |
<html> |
| 80 |
<head> |
| 81 |
<meta name="pypi:repository-version" content="1.0"> |
| 82 |
<meta name="pypi:project-status" content="active"> |
| 83 |
<title>Package files for ${PACKAGE}</title> |
| 84 |
</head> |
| 85 |
<body> |
| 86 |
<h1>Package files for ${PACKAGE}</h1> |
| 87 |
<ul> |
| 88 |
EOF |
| 89 |
for WHEEL in $( ( git ls-tree --name-only origin/pages:dist/ ; cd public/dist/ && ls ) |grep "^${PACKAGEFILE}" | sort -u ) |
| 90 |
do |
| 91 |
cat >> public/$PACKAGE/index.html <<EOF |
| 92 |
<li><a href="../dist/${WHEEL}">${WHEEL}</a> |
| 93 |
EOF |
| 94 |
done |
| 95 |
cat >> public/$PACKAGE/index.html <<EOF |
| 96 |
</ul> |
| 97 |
<footer>Current version described as ${DESCRIBE} |
| 98 |
</body> |
| 99 |
</html> |
| 100 |
EOF |
| 101 |
cat public/$PACKAGE/index.html |
| 102 |
done |