git tag -a needs user.name and user.email, which the runner container does not have, so the tag job failed after every image had already been published.
150 lines
5.0 KiB
YAML
150 lines
5.0 KiB
YAML
name: release
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
schedule:
|
|
- cron: "0 3 1 * *"
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: "Release to cut, e.g. v1.1.0. Empty means the next patch."
|
|
required: false
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: release
|
|
cancel-in-progress: false
|
|
|
|
env:
|
|
REGISTRY: git.fristy.net
|
|
IMAGE: git.fristy.net/actions/runner-images
|
|
|
|
# Each run on main cuts a patch release and tags the commit afterwards. A tag
|
|
# push does not trigger this workflow, so the tag cannot loop back.
|
|
jobs:
|
|
meta:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
created: ${{ steps.meta.outputs.created }}
|
|
version: ${{ steps.meta.outputs.version }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Get meta
|
|
id: meta
|
|
run: |
|
|
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT"
|
|
latest="$(git tag --list 'v*' --sort=-v:refname | head -n1)"
|
|
if [ -z "${latest}" ]; then
|
|
next="v1.0.0"
|
|
else
|
|
next="v$(awk -F. '{print $1"."$2"."$3+1}' <<< "${latest#v}")"
|
|
fi
|
|
override='${{ github.event.inputs.version }}'
|
|
[ "${override}" = "null" ] && override=''
|
|
version="${override:-${next}}"
|
|
[[ "${version}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || {
|
|
echo "invalid version '${version}', expected v<major>.<minor>.<patch>" >&2
|
|
exit 1
|
|
}
|
|
echo "version=${version}" >> "$GITHUB_OUTPUT"
|
|
|
|
publish:
|
|
needs: meta
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 180
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- base: "24.04"
|
|
tags: ubuntu-24.04
|
|
- base: "26.04"
|
|
tags: ubuntu-26.04
|
|
- base: "26.10"
|
|
tags: ubuntu-26.10,ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v4
|
|
|
|
- name: Log in to the registry
|
|
run: |
|
|
token="${{ secrets.REGISTRY_TOKEN }}"
|
|
[ -n "$token" ] || { echo "REGISTRY_TOKEN secret is missing" >&2; exit 1; }
|
|
echo "$token" | docker login "$REGISTRY" -u "${{ secrets.REGISTRY_USERNAME || github.actor }}" --password-stdin
|
|
|
|
- name: Build ${{ matrix.base }}
|
|
uses: docker/build-push-action@v7
|
|
with:
|
|
context: .
|
|
file: dockerfiles/ubuntu.dockerfile
|
|
platforms: linux/amd64
|
|
pull: true
|
|
push: false
|
|
load: true
|
|
tags: ${{ env.IMAGE }}:ubuntu-${{ matrix.base }}
|
|
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache-${{ matrix.base }}
|
|
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache-${{ matrix.base }},mode=max
|
|
build-args: |
|
|
BASE_IMAGE_TAG=${{ matrix.base }}
|
|
IMAGE_CREATED=${{ needs.meta.outputs.created }}
|
|
IMAGE_VERSION=${{ needs.meta.outputs.version }}
|
|
IMAGE_REVISION=${{ github.sha }}
|
|
|
|
- name: Smoke test ${{ matrix.base }}
|
|
run: docker run --rm -i "${IMAGE}:ubuntu-${{ matrix.base }}" bash -s -- ${{ matrix.base }} < tests/default.sh
|
|
|
|
- name: Scan ${{ matrix.base }} for CRITICAL vulnerabilities
|
|
run: |
|
|
docker run --rm "${IMAGE}:ubuntu-${{ matrix.base }}" trivy rootfs / \
|
|
--quiet --scanners vuln --severity CRITICAL --ignore-unfixed --exit-code 1 --no-progress
|
|
|
|
- name: Report HIGH vulnerabilities for ${{ matrix.base }}
|
|
if: always()
|
|
run: |
|
|
docker run --rm "${IMAGE}:ubuntu-${{ matrix.base }}" trivy rootfs / \
|
|
--quiet --scanners vuln --severity HIGH --ignore-unfixed --exit-code 1 --no-progress \
|
|
--format table || echo "HIGH findings present; recorded above, not blocking the release"
|
|
|
|
- name: Push ${{ matrix.base }}
|
|
run: |
|
|
set -euo pipefail
|
|
version="${{ needs.meta.outputs.version }}"
|
|
printf '%s\n' "${{ matrix.tags }}" | tr ',' '\n' | while read -r tag; do
|
|
[ -n "${tag}" ] || continue
|
|
docker tag "${IMAGE}:ubuntu-${{ matrix.base }}" "${IMAGE}:${tag}"
|
|
docker push "${IMAGE}:${tag}"
|
|
done
|
|
docker tag "${IMAGE}:ubuntu-${{ matrix.base }}" "${IMAGE}:${version}-ubuntu-${{ matrix.base }}"
|
|
docker push "${IMAGE}:${version}-ubuntu-${{ matrix.base }}"
|
|
|
|
tag:
|
|
needs: [meta, publish]
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Tag the release
|
|
run: |
|
|
version="${{ needs.meta.outputs.version }}"
|
|
if git rev-parse -q --verify "refs/tags/${version}" > /dev/null; then
|
|
echo "${version} is already tagged"
|
|
exit 0
|
|
fi
|
|
git -c user.name="fristyagent" -c user.email="ai-agent@fristy.dev" tag -a "${version}" -m "${version}" "${GITHUB_SHA}"
|
|
git push origin "refs/tags/${version}"
|