mirror of
https://github.com/Katakate/k7.git
synced 2026-11-18 18:04:20 +00:00
Observability, usage metering, tenants and quotas, and roles with OIDC login. A Helm chart installs K7 on a cluster you already run, API keys carry a role, and k7-agent no longer needs host privileges.
204 lines
7.5 KiB
YAML
204 lines
7.5 KiB
YAML
# Tag release: build and push k7-api and k7-node-installer to GHCR, scan them
|
|
# with Trivy, sign them with cosign keyless (GitHub OIDC), attach a Syft SPDX
|
|
# SBOM attestation and SLSA build provenance, then build the .deb and wheel
|
|
# with images.lock.yaml baked in, render the node-installer manifests with
|
|
# the locked digest, and attach them (sha256sums + cosign bundles) to a
|
|
# DRAFT release.
|
|
# Runs on Katakate/k7 only; a fork opts in with the repo variable
|
|
# K7_RELEASE_FORK=true (dry runs against a throwaway tag).
|
|
name: release
|
|
|
|
on:
|
|
push:
|
|
tags: ["v*"]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
UV_VERSION: "0.12.23"
|
|
UV_PYTHON: "3.10.11"
|
|
UV_LOCKED: "1"
|
|
COSIGN_VERSION: "v3.0.6"
|
|
SYFT_VERSION: "v1.54.1"
|
|
TRIVY_VERSION: "v0.70.0"
|
|
|
|
jobs:
|
|
image:
|
|
if: github.repository == 'Katakate/k7' || vars.K7_RELEASE_FORK == 'true'
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 45
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
id-token: write
|
|
attestations: write
|
|
# One leg per images.lock.yaml key (tests/unit/test_supply_chain.py).
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- name: k7-api
|
|
dockerfile: src/k7/api/Dockerfile.api
|
|
- name: k7-node-installer
|
|
dockerfile: src/k7/deploy/node_installer/Dockerfile
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Tag must match the package version
|
|
id: version
|
|
run: |
|
|
version="$(grep -Po '__version__\s*=\s*"\K[^"]+' src/k7/__init__.py)"
|
|
tag="${GITHUB_REF_NAME#v}"
|
|
[[ "$tag" == "$version" || "$tag" == "$version"-* ]] || {
|
|
echo "::error::tag $GITHUB_REF_NAME does not match __version__ $version"; exit 1; }
|
|
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
|
echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${{ matrix.name }}" >> "$GITHUB_ENV"
|
|
|
|
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
|
|
|
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push ${{ matrix.name }}
|
|
id: build
|
|
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
|
|
with:
|
|
context: .
|
|
file: ${{ matrix.dockerfile }}
|
|
platforms: linux/amd64
|
|
push: true
|
|
provenance: false
|
|
sbom: false
|
|
tags: ${{ env.IMAGE }}:${{ steps.version.outputs.tag }}
|
|
|
|
- name: Record the pushed digest ref
|
|
id: ref
|
|
run: |
|
|
ref="${IMAGE}@${{ steps.build.outputs.digest }}"
|
|
echo "ref=$ref" >> "$GITHUB_OUTPUT"
|
|
printf '%s\n' "$ref" > "${{ matrix.name }}.image.txt"
|
|
|
|
# CRITICAL with a fix available blocks the release. Waivers go in
|
|
# .trivyignore with a reason and a review date.
|
|
- uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
|
|
env:
|
|
TRIVY_USERNAME: ${{ github.actor }}
|
|
TRIVY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
image-ref: ${{ steps.ref.outputs.ref }}
|
|
version: ${{ env.TRIVY_VERSION }}
|
|
severity: CRITICAL
|
|
ignore-unfixed: true
|
|
trivyignores: .trivyignore
|
|
exit-code: "1"
|
|
|
|
- uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
|
|
with:
|
|
cosign-release: ${{ env.COSIGN_VERSION }}
|
|
|
|
- name: Sign the image digest (keyless)
|
|
run: cosign sign --yes "${{ steps.ref.outputs.ref }}"
|
|
|
|
- uses: anchore/sbom-action@66cbf4bc1f1c0d2edc94016e65bc221b6bb0ad6c # v0.24.3
|
|
with:
|
|
image: ${{ steps.ref.outputs.ref }}
|
|
registry-username: ${{ github.actor }}
|
|
registry-password: ${{ secrets.GITHUB_TOKEN }}
|
|
syft-version: ${{ env.SYFT_VERSION }}
|
|
format: spdx-json
|
|
output-file: ${{ matrix.name }}.spdx.json
|
|
upload-artifact: false
|
|
upload-release-assets: false
|
|
|
|
- name: Attest the SBOM to the image
|
|
run: cosign attest --yes --type spdxjson --predicate "${{ matrix.name }}.spdx.json" "${{ steps.ref.outputs.ref }}"
|
|
|
|
- uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
|
|
with:
|
|
subject-name: ${{ env.IMAGE }}
|
|
subject-digest: ${{ steps.build.outputs.digest }}
|
|
push-to-registry: true
|
|
|
|
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: image-${{ matrix.name }}
|
|
path: |
|
|
${{ matrix.name }}.spdx.json
|
|
${{ matrix.name }}.image.txt
|
|
if-no-files-found: error
|
|
|
|
packages:
|
|
needs: image
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 60
|
|
permissions:
|
|
contents: write
|
|
id-token: write
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
|
with:
|
|
version: ${{ env.UV_VERSION }}
|
|
|
|
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
with:
|
|
pattern: image-*
|
|
merge-multiple: true
|
|
path: dist
|
|
|
|
# Only packaged artifacts carry the digests; the git tag does not.
|
|
- name: Write images.lock.yaml and render the node-installer manifests
|
|
run: |
|
|
for f in dist/*.image.txt; do
|
|
printf '%s: %s\n' "$(basename "$f" .image.txt)" "$(cat "$f")"
|
|
done > src/k7/deploy/images.lock.yaml
|
|
cat src/k7/deploy/images.lock.yaml
|
|
uv run python - <<'PY'
|
|
import pathlib
|
|
import k7.deploy.images as i
|
|
lock = i.parse_lock(pathlib.Path("src/k7/deploy/images.lock.yaml").read_text())
|
|
if set(lock) != set(i.PLACEHOLDERS.values()):
|
|
raise SystemExit(f"images.lock.yaml keys {sorted(lock)} != {sorted(i.PLACEHOLDERS.values())}")
|
|
src = pathlib.Path("src/k7/deploy/manifests/k7-node-installer")
|
|
print(i.render_node_installer_bundles(src, pathlib.Path("dist"), lock))
|
|
PY
|
|
|
|
- name: Build wheel and .deb
|
|
run: |
|
|
uv build --wheel --out-dir dist
|
|
src/k7/cli/build.sh
|
|
ls -l dist/*.whl dist/*.deb
|
|
|
|
- uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
|
|
with:
|
|
cosign-release: ${{ env.COSIGN_VERSION }}
|
|
|
|
- name: Checksums and cosign bundles
|
|
working-directory: dist
|
|
run: |
|
|
sha256sum ./*.whl ./*.deb ./*.spdx.json ./k7-node-*.yaml > sha256sums.txt
|
|
for f in ./*.whl ./*.deb ./k7-node-*.yaml sha256sums.txt; do
|
|
cosign sign-blob --yes --bundle "$f.sigstore.json" "$f"
|
|
done
|
|
|
|
- name: Draft GitHub release with the assets
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
working-directory: dist
|
|
run: |
|
|
prerelease=""
|
|
[[ "$GITHUB_REF_NAME" == *-* ]] && prerelease="--prerelease"
|
|
gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1 || \
|
|
gh release create "$GITHUB_REF_NAME" --verify-tag --draft $prerelease \
|
|
--title "$GITHUB_REF_NAME" --notes-file ../src/k7/deploy/images.lock.yaml
|
|
gh release upload "$GITHUB_REF_NAME" --clobber \
|
|
./*.whl ./*.deb ./*.sigstore.json sha256sums.txt ./*.spdx.json ./*.image.txt ./k7-node-*.yaml
|