- on: release (published), not on any v* tag: only a deliberate release builds an image; the version is its tag without the v, plus latest. - docker/login-action, setup-buildx and build-push-action, as the runner already serves them for inlaw_outlaw; the version as a build argument and image label. - Comments on why the registry needs a personal token (the job token's empty package scope) and that packages belong to the repository owner. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPQ14L3LikyefCMFBqEbKE
61 lines
2.0 KiB
YAML
61 lines
2.0 KiB
YAML
name: Release
|
|
# A published release builds the agent's image and pushes it to Gitea's
|
|
# registry (Development Plan M1.5, X4): gitea.dongar.net/dongar/nisse-dev
|
|
# tagged with the version (the release tag without its v) and latest. Cut a
|
|
# release in Gitea (Releases → New release, tag vX.Y.Z); a tag pushed for any
|
|
# other reason builds nothing.
|
|
#
|
|
# The registry needs a personal access token with write:package
|
|
# (REGISTRY_TOKEN), never the built-in job token: Gitea's registry resolves
|
|
# an Actions job token to an empty package scope (go-gitea/gitea#23642 and
|
|
# others). Packages belong to the repository's owner. Never on pull_request:
|
|
# registry credentials stay off that trigger.
|
|
on:
|
|
release:
|
|
types: [published]
|
|
|
|
env:
|
|
REGISTRY: gitea.dongar.net
|
|
REGISTRY_USER: dongar # the token's account
|
|
IMAGE: gitea.dongar.net/dongar/nisse-dev
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Derive the image version from the release's tag
|
|
id: vars
|
|
env:
|
|
TAG: ${{ github.event.release.tag_name }}
|
|
run: echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Log in to Gitea's container registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ env.REGISTRY_USER }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build and push the agent
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
target: agent
|
|
push: true
|
|
build-args: |
|
|
VERSION=${{ steps.vars.outputs.version }}
|
|
labels: |
|
|
org.opencontainers.image.version=${{ steps.vars.outputs.version }}
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
tags: |
|
|
${{ env.IMAGE }}:${{ steps.vars.outputs.version }}
|
|
${{ env.IMAGE }}:latest
|