- ci.yml: lint (ruff), test (pytest), build (uv build) auf jedem push/PR - release.yml: docker image build + push auf v*-tag, gitea release mit changelog
This commit is contained in:
33
.gitea/workflows/ci.yml
Normal file
33
.gitea/workflows/ci.yml
Normal file
@@ -0,0 +1,33 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
tags-ignore:
|
||||
- '**'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: python:3.12-slim
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install uv
|
||||
run: pip install --no-cache-dir uv
|
||||
|
||||
- name: Install dependencies
|
||||
run: uv sync --frozen
|
||||
|
||||
- name: Lint
|
||||
run: uvx ruff check app tests
|
||||
|
||||
- name: Test
|
||||
run: uv run pytest
|
||||
|
||||
- name: Build distribution
|
||||
run: uv build
|
||||
67
.gitea/workflows/release.yml
Normal file
67
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,67 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: dind
|
||||
steps:
|
||||
- name: Install tooling
|
||||
run: apk add --no-cache git curl jq docker-cli docker-cli-buildx
|
||||
|
||||
- name: Clone repository at tag
|
||||
run: |
|
||||
git clone "https://${{ secrets.GITEA_TOKEN }}@gitea.jeanlucmakiola.de/${{ gitea.repository }}.git" repo
|
||||
cd repo
|
||||
git checkout "${{ gitea.ref_name }}"
|
||||
|
||||
- name: Compute previous tag and changelog
|
||||
working-directory: repo
|
||||
run: |
|
||||
VERSION="${{ gitea.ref_name }}"
|
||||
PREV_TAG=$(git tag -l 'v*' --sort=-v:refname | grep -v "^${VERSION}$" | head -n1 || true)
|
||||
if [ -z "$PREV_TAG" ]; then
|
||||
CHANGELOG=$(git log --pretty=format:"- %s" "${VERSION}")
|
||||
else
|
||||
CHANGELOG=$(git log --pretty=format:"- %s" "${PREV_TAG}..${VERSION}")
|
||||
fi
|
||||
{
|
||||
echo "VERSION=$VERSION"
|
||||
echo "PREV_TAG=$PREV_TAG"
|
||||
echo "CHANGELOG<<CHANGELOG_EOF"
|
||||
echo "$CHANGELOG"
|
||||
echo "CHANGELOG_EOF"
|
||||
} >> "$GITHUB_ENV"
|
||||
|
||||
- name: Log in to Gitea registry
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_TOKEN }}" \
|
||||
| docker login gitea.jeanlucmakiola.de -u "${{ gitea.repository_owner }}" --password-stdin
|
||||
|
||||
- name: Build and push Docker image
|
||||
working-directory: repo
|
||||
run: |
|
||||
IMAGE="gitea.jeanlucmakiola.de/${{ gitea.repository }}"
|
||||
docker buildx create --use --name builder >/dev/null 2>&1 || docker buildx use builder
|
||||
docker buildx build \
|
||||
--cache-from "type=registry,ref=${IMAGE}:buildcache" \
|
||||
--cache-to "type=registry,ref=${IMAGE}:buildcache,mode=max" \
|
||||
-f docker/Dockerfile \
|
||||
-t "${IMAGE}:${VERSION}" \
|
||||
-t "${IMAGE}:latest" \
|
||||
--push .
|
||||
|
||||
- name: Create Gitea release
|
||||
run: |
|
||||
API_URL="${GITHUB_SERVER_URL}/api/v1/repos/${{ gitea.repository }}/releases"
|
||||
curl -fsS -X POST "$API_URL" \
|
||||
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$(jq -n \
|
||||
--arg tag "$VERSION" \
|
||||
--arg name "$VERSION" \
|
||||
--arg body "$CHANGELOG" \
|
||||
'{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}')"
|
||||
Reference in New Issue
Block a user