Add versioning, release workflow and changelog
Build and deploy / build (push) Successful in 1m56s
Build and deploy / deploy (push) Successful in 22s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TomandClaude Opus 5.5 committed 2026-11-14 17:25:11 +01:00
1 parent c22d452720
commit 7c3657d015
11 files changed
+222 -11

No files matched your search

+7 -4
View File
@@ -1,6 +1,7 @@
# Builds the image on every push to main, pushes it to the Gitea registry (tagged
# :latest AND the short commit SHA, for rollback) and deploys the stack on Unraid
# from deploy/unraid/compose.yaml (Tom's personal Unraid setup).
# :main AND the short commit SHA, for rollback) and deploys the stack on Unraid
# from deploy/unraid/compose.yaml (Tom's personal Unraid setup). Releases (:latest,
# :X.Y.Z) come from version tags in release.yml and are never deployed here.
#
# The deploy works because the act_runner runs ON Unraid and hands its Docker
# socket to the job: every `docker` command here talks to the Unraid daemon, so
@@ -58,13 +59,15 @@ jobs:
id: sha
run: echo "short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
- name: Build and push (:latest and :<sha>)
- name: Build and push (:main and :<sha>)
uses: docker/build-push-action@v6
with:
context: .
push: true
build-args: |
VERSION=0.0.0-dev+${{ steps.sha.outputs.short }}
tags: |
${{ env.IMAGE }}:latest
${{ env.IMAGE }}:main
${{ env.IMAGE }}:${{ steps.sha.outputs.short }}
deploy:
+110
View File
@@ -0,0 +1,110 @@
# Builds a release when a version tag (vX.Y.Z) is pushed: the image is tagged
# :X.Y.Z, :X.Y, :X and :latest in the Gitea registry, and a Gitea release is
# created with the matching section of CHANGELOG.md as notes. Nothing is
# deployed; Tom's Unraid follows :main through deploy.yml.
#
# A pre-release tag such as v0.2.0-rc.1 only gets its own :0.2.0-rc.1 tag and a
# release marked as pre-release; :latest and the short tags stay on the last
# stable version.
#
# Required repository secrets: REGISTRY_USER, REGISTRY_TOKEN (see deploy.yml).
# The release itself uses the job's built-in token.
name: Release
on:
push:
tags: ["v*"]
env:
IMAGE: gitea.anticarnist.de/tom/flypaper
jobs:
image:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
prerelease: ${{ steps.version.outputs.prerelease }}
steps:
- name: Check out the source
uses: actions/checkout@v4
- name: Read the version from the tag
id: version
run: |
version="${GITHUB_REF_NAME#v}"
if ! echo "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then
echo "Tag $GITHUB_REF_NAME is not vX.Y.Z" >&2
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
{
echo "tags<<EOF"
echo "$IMAGE:$version"
case "$version" in
*-*) ;;
*)
echo "$IMAGE:${version%.*}"
echo "$IMAGE:${version%%.*}"
echo "$IMAGE:latest"
;;
esac
echo "EOF"
} >> "$GITHUB_OUTPUT"
case "$version" in
*-*) echo "prerelease=true" >> "$GITHUB_OUTPUT" ;;
*) echo "prerelease=false" >> "$GITHUB_OUTPUT" ;;
esac
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Gitea registry
uses: docker/login-action@v3
with:
registry: gitea.anticarnist.de
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push the release tags
uses: docker/build-push-action@v6
with:
context: .
push: true
build-args: |
VERSION=${{ steps.version.outputs.version }}
tags: ${{ steps.version.outputs.tags }}
release:
needs: image
runs-on: ubuntu-latest
steps:
- name: Check out the source
uses: actions/checkout@v4
# The notes are the CHANGELOG.md section of this version, from its heading
# up to the next one. If the API call fails, the images are still pushed;
# the release can then be created by hand (deploy/unraid/README.md).
- name: Create the Gitea release
env:
VERSION: ${{ needs.image.outputs.version }}
PRERELEASE: ${{ needs.image.outputs.prerelease }}
TOKEN: ${{ github.token }}
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases
run: |
notes=$(awk -v version="$VERSION" '
/^## \[/ { if (found) exit; if (index($0, "[" version "]")) { found = 1; next } }
/^\[[^]]+\]: / { if (found) exit }
found { print }
' CHANGELOG.md)
[ -n "$notes" ] || notes="See CHANGELOG.md."
jq -n \
--arg tag "$GITHUB_REF_NAME" \
--arg name "Flypaper $VERSION" \
--arg body "$notes" \
--argjson prerelease "$PRERELEASE" \
'{tag_name: $tag, name: $name, body: $body, prerelease: $prerelease}' > release.json
curl -fsS -X POST "$API" \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/json" \
--data @release.json