7f8500199d
Trigger the image build on v* tags and, on a version tag, publish the semver (X.Y.Z) alongside :latest and the commit SHA. Previously only :latest and :<sha> were pushed and the build never fired on the release tag, so there was no stable version to pin against. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NGzHtDvJur9U7ysgRKRUTN
72 lines
1.8 KiB
YAML
72 lines
1.8 KiB
YAML
name: build-image
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ["v*"]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
env:
|
|
API_KEY: test
|
|
ATHLETE_ID: i1
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
- name: Install (editable, with dev extras)
|
|
run: pip install --quiet -e ".[dev]"
|
|
- name: Test + coverage gate (>=90%)
|
|
run: pytest
|
|
|
|
build:
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
env:
|
|
IMAGE: git.farh.net/farhoodlabs/intervalsicu-mcp
|
|
DOCKER_BUILDKIT: "1"
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Environment
|
|
run: |
|
|
docker version || true
|
|
df -h / || true
|
|
|
|
- name: Login to registry
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.farh.net -u cpfarhood --password-stdin
|
|
|
|
- name: Build and push image
|
|
run: |
|
|
# Always tag the immutable commit SHA. On a version tag (refs/tags/vX.Y.Z)
|
|
# also publish the semver (X.Y.Z) so images can be pinned, and move :latest.
|
|
# On a main-branch push, publish :latest.
|
|
REFS="${IMAGE}:${GITHUB_SHA}"
|
|
case "${GITHUB_REF}" in
|
|
refs/tags/v*)
|
|
VERSION="${GITHUB_REF#refs/tags/v}"
|
|
REFS="${REFS} ${IMAGE}:${VERSION} ${IMAGE}:latest"
|
|
;;
|
|
*)
|
|
REFS="${REFS} ${IMAGE}:latest"
|
|
;;
|
|
esac
|
|
|
|
BUILD_ARGS=""
|
|
for r in ${REFS}; do BUILD_ARGS="${BUILD_ARGS} -t ${r}"; done
|
|
docker build --progress=plain ${BUILD_ARGS} .
|
|
|
|
for r in ${REFS}; do docker push "${r}"; done
|
|
echo "pushed: ${REFS}"
|