CI: build release images only from vX.Y.Z tags
Tests still run on every push. The docker job is gated on ref_type=tag, validates the tag is a strict vX.Y.Z semver, and publishes :<tag> plus :latest. No branch images (sha-* / main latest) anymore.
This commit is contained in:
+10
-16
@@ -22,28 +22,20 @@ jobs:
|
|||||||
echo "golangci-lint not available in runner image, skipping"
|
echo "golangci-lint not available in runner image, skipping"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Release images are built only from version tags (vX.Y.Z).
|
||||||
docker:
|
docker:
|
||||||
|
if: gitea.ref_type == 'tag'
|
||||||
needs: test
|
needs: test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Compute image tags and version
|
- name: Check tag is semantic version
|
||||||
id: meta
|
|
||||||
run: |
|
run: |
|
||||||
SHORT=$(echo "${{ gitea.sha }}" | cut -c1-7)
|
if ! echo "${{ gitea.ref_name }}" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
|
||||||
REPO=git.rambossek.at/${{ gitea.repository }}
|
echo "tag '${{ gitea.ref_name }}' is not a vX.Y.Z semantic version" >&2
|
||||||
TAGS="$REPO:sha-$SHORT"
|
exit 1
|
||||||
VERSION="sha-$SHORT"
|
|
||||||
if [ "${{ gitea.ref_type }}" = "branch" ] && [ "${{ gitea.ref_name }}" = "main" ]; then
|
|
||||||
TAGS="$TAGS,$REPO:latest"
|
|
||||||
fi
|
fi
|
||||||
if [ "${{ gitea.ref_type }}" = "tag" ]; then
|
|
||||||
TAGS="$TAGS,$REPO:${{ gitea.ref_name }}"
|
|
||||||
VERSION="${{ gitea.ref_name }}"
|
|
||||||
fi
|
|
||||||
echo "tags=$TAGS" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- uses: docker/setup-buildx-action@v3
|
- uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
@@ -58,5 +50,7 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
build-args: |
|
build-args: |
|
||||||
VERSION=${{ steps.meta.outputs.version }}
|
VERSION=${{ gitea.ref_name }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: |
|
||||||
|
git.rambossek.at/${{ gitea.repository }}:${{ gitea.ref_name }}
|
||||||
|
git.rambossek.at/${{ gitea.repository }}:latest
|
||||||
|
|||||||
@@ -67,10 +67,11 @@ docker run --rm -p 11434:11434 -p 8188:8188 \
|
|||||||
gpu-turnstile
|
gpu-turnstile
|
||||||
```
|
```
|
||||||
|
|
||||||
Releases are built by Gitea Actions (`.gitea/workflows/ci.yml`): pushes run
|
Releases are built by Gitea Actions (`.gitea/workflows/ci.yml`): every push
|
||||||
`go vet` and `go test -race` and publish
|
runs `go vet` and `go test -race`, and pushing a semantic-version tag
|
||||||
`git.rambossek.at/<owner>/gpu-turnstile:sha-<short>`; `main` additionally gets
|
`vX.Y.Z` builds and publishes
|
||||||
`:latest`, and a git tag `vX.Y.Z` produces the versioned image.
|
`git.rambossek.at/<owner>/gpu-turnstile:vX.Y.Z` (and updates `:latest`).
|
||||||
|
No images are built from branches.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
|||||||
@@ -181,14 +181,14 @@ are new.
|
|||||||
`scratch`), non-root user, `EXPOSE 8188 11434`,
|
`scratch`), non-root user, `EXPOSE 8188 11434`,
|
||||||
`ENTRYPOINT ["/gpu-turnstile"]`.
|
`ENTRYPOINT ["/gpu-turnstile"]`.
|
||||||
- `.gitea/workflows/ci.yml` (Gitea Actions):
|
- `.gitea/workflows/ci.yml` (Gitea Actions):
|
||||||
1. on push and tag: `go vet`, `go test -race ./...`, `golangci-lint` if
|
1. on every push: `go vet`, `go test -race ./...`, `golangci-lint` if
|
||||||
available in the runner image
|
available in the runner image
|
||||||
2. build image with buildx, tags `:sha-<short>` and `:latest` on main,
|
2. on a version tag only (`vX.Y.Z`, enforced): build the image with buildx
|
||||||
`:<tag>` on tags
|
and push it to the Gitea registry
|
||||||
3. push to the Gitea registry `git.rambossek.at/<owner>/gpu-turnstile`
|
`git.rambossek.at/<owner>/gpu-turnstile` tagged `:<tag>` and `:latest`,
|
||||||
using the workflow token (`${{ secrets.GITEA_TOKEN }}` / `gitea.actor`)
|
using the workflow token (`${{ secrets.GITEA_TOKEN }}` / `gitea.actor`)
|
||||||
- Release: a git tag `vX.Y.Z` produces the versioned image; the Open WebUI
|
- Release: a git tag `vX.Y.Z` produces the versioned image; the Open WebUI
|
||||||
compose pins that tag.
|
compose pins that tag. No images are built from branches.
|
||||||
|
|
||||||
## Deployment (target)
|
## Deployment (target)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user