Add CI with checks and automated release builds
Gitea Actions workflow (.gitea/workflows/ci.yml): - check job: ruff format --check, ruff check, ty check on pushes to main - release job on v* tags: build a standalone Linux executable with PyInstaller (--onefile), smoke-test it, create a Gitea release via the API and upload the binary as an asset Also add a pyinstaller build dependency group and bump to 0.3.0.
This commit is contained in:
@@ -0,0 +1,75 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
- 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
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: astral-sh/setup-uv@v5
|
||||||
|
|
||||||
|
- 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"])'
|
||||||
@@ -2,5 +2,7 @@
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
dist/
|
dist/
|
||||||
|
build/
|
||||||
|
*.spec
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
.ruff_cache/
|
.ruff_cache/
|
||||||
|
|||||||
@@ -82,6 +82,21 @@ uv run ruff check src # lint
|
|||||||
uv run ty check # type check
|
uv run ty check # type check
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## CI / releases
|
||||||
|
|
||||||
|
Gitea Actions (`.gitea/workflows/ci.yml`) runs two jobs:
|
||||||
|
|
||||||
|
- **check** — format, lint, and type check on every push to `main`
|
||||||
|
- **release** — on `v*` tags: builds a standalone Linux executable with
|
||||||
|
PyInstaller, smoke-tests it, creates a Gitea release, and uploads the
|
||||||
|
binary as an asset
|
||||||
|
|
||||||
|
Cut a release with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git tag vX.Y.Z && git push origin vX.Y.Z
|
||||||
|
```
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
- **launchpadlib** — Launchpad REST API client
|
- **launchpadlib** — Launchpad REST API client
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "weekly-activity"
|
name = "weekly-activity"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
description = "Weekly activity report (merge proposals, pull requests, bugs, issues) for Launchpad and GitHub."
|
description = "Weekly activity report (merge proposals, pull requests, bugs, issues) for Launchpad and GitHub."
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
@@ -19,6 +19,7 @@ build-backend = "hatchling.build"
|
|||||||
|
|
||||||
[dependency-groups]
|
[dependency-groups]
|
||||||
dev = ["ruff>=0.6", "ty>=0.0.1"]
|
dev = ["ruff>=0.6", "ty>=0.0.1"]
|
||||||
|
build = ["pyinstaller>=6"]
|
||||||
|
|
||||||
[tool.hatch.build.targets.wheel]
|
[tool.hatch.build.targets.wheel]
|
||||||
packages = ["src/weekly_activity"]
|
packages = ["src/weekly_activity"]
|
||||||
|
|||||||
Reference in New Issue
Block a user