Files
weekly-activity/.gitea/workflows/ci.yml
T
vhaudiquet cbca729693
CI / check (push) Successful in 5s
CI / release (push) Successful in 28s
Force uv-managed Python in release build
The runner's system CPython 3.12.3 satisfies the '3.12' request, so uv
kept using it and PyInstaller failed: system python is built without
libpython3.x.so. Set UV_PYTHON_PREFERENCE=only-managed and install the
managed interpreter explicitly.
2026-08-25 20:45:27 +02:00

89 lines
2.7 KiB
YAML

name: CI
on:
push:
branches: [main]
tags: ["v*"]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
# Pin uv's managed CPython: the runner's system python lacks
# libpython3.x.so, which PyInstaller needs for --onefile builds.
python-version: "3.12"
- name: Install dependencies
run: uv sync --frozen
- name: Format check
run: uv run ruff format --check src
- name: Lint
run: uv run ruff check src
- name: Type check
run: uv run ty check
release:
needs: check
if: startsWith(gitea.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
env:
# Force uv-managed CPython: the runner's system python satisfies the
# "3.12" request but is built without libpython3.x.so, which
# PyInstaller --onefile requires.
UV_PYTHON: "3.12"
UV_PYTHON_PREFERENCE: only-managed
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- name: Install managed Python
run: uv python install 3.12
- name: Install dependencies
run: uv sync --frozen --group build
- name: Build standalone executable
run: >
uv run pyinstaller
--onefile
--name weekly-activity
--paths src
--clean
--noconfirm
src/weekly_activity/cli.py
- name: Smoke-test executable
run: ./dist/weekly-activity --help
- name: Create release and upload artifact
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
API: ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}
TAG: ${{ gitea.ref_name }}
ASSET: weekly-activity-linux-amd64
run: |
set -eu
AUTH="Authorization: token ${GITEA_TOKEN}"
RELEASE_ID=$(curl -sf -X POST "$API/releases" \
-H "$AUTH" -H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"Automated release of $TAG\"}" \
| python3 -c 'import json, sys; print(json.load(sys.stdin)["id"])' \
) || true
if [ -z "${RELEASE_ID:-}" ]; then
RELEASE_ID=$(curl -sf "$API/releases/tags/$TAG" -H "$AUTH" \
| python3 -c 'import json, sys; print(json.load(sys.stdin)["id"])')
fi
curl -sf -X POST "$API/releases/$RELEASE_ID/assets?name=$ASSET" \
-H "$AUTH" -F "attachment=@dist/weekly-activity" \
| python3 -c 'import json, sys; print("uploaded:", json.load(sys.stdin)["browser_download_url"])'