Some checks failed
CI / ci (push) Failing after 12s
- 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
68 lines
2.4 KiB
YAML
68 lines
2.4 KiB
YAML
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}')"
|