|
|
@@ -16,24 +16,48 @@
|
|
|
|
# release — Supervisor pulls the image tag matching that version
|
|
|
|
# release — Supervisor pulls the image tag matching that version
|
|
|
|
# exactly, so an unbumped version means it silently keeps using the
|
|
|
|
# exactly, so an unbumped version means it silently keeps using the
|
|
|
|
# old image.
|
|
|
|
# old image.
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# Triggers only on pushed tags matching "v*", and only builds if that
|
|
|
|
|
|
|
|
# tag's commit is actually part of main's history (see check-branch job).
|
|
|
|
|
|
|
|
|
|
|
|
name: build-and-push
|
|
|
|
name: build-and-push
|
|
|
|
on:
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
tags:
|
|
|
|
- "v*"
|
|
|
|
- "v*"
|
|
|
|
# paths:
|
|
|
|
|
|
|
|
# - "mqtt-cert-manager/**"
|
|
|
|
|
|
|
|
# branches:
|
|
|
|
|
|
|
|
# - main
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
env:
|
|
|
|
env:
|
|
|
|
REGISTRY_HOST: git.example.com
|
|
|
|
REGISTRY_HOST: gitea.viratak.com
|
|
|
|
REGISTRY_OWNER: YOUR_USER
|
|
|
|
REGISTRY_OWNER: bitopa
|
|
|
|
IMAGE_NAME: mqtt-cert-manager
|
|
|
|
IMAGE_NAME: mqtt-cert-manager
|
|
|
|
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
jobs:
|
|
|
|
|
|
|
|
check-branch:
|
|
|
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
outputs:
|
|
|
|
|
|
|
|
on_main: ${{ steps.check.outputs.on_main }}
|
|
|
|
|
|
|
|
steps:
|
|
|
|
|
|
|
|
- name: Checkout (full history)
|
|
|
|
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
with:
|
|
|
|
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Make sure we have main's history too
|
|
|
|
|
|
|
|
run: git fetch origin main:refs/remotes/origin/main
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Is this tag's commit part of main?
|
|
|
|
|
|
|
|
id: check
|
|
|
|
|
|
|
|
run: |
|
|
|
|
|
|
|
|
if git merge-base --is-ancestor HEAD origin/main; then
|
|
|
|
|
|
|
|
echo "on_main=true" >> "$GITHUB_OUTPUT"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
echo "on_main=false" >> "$GITHUB_OUTPUT"
|
|
|
|
|
|
|
|
echo "Tag $GITHUB_REF_NAME points to a commit that is not on main — skipping build."
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
build:
|
|
|
|
build:
|
|
|
|
|
|
|
|
needs: check-branch
|
|
|
|
|
|
|
|
if: needs.check-branch.outputs.on_main == 'true'
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
matrix:
|
|
|
@@ -56,18 +80,18 @@ jobs:
|
|
|
|
|
|
|
|
|
|
|
|
- name: Read add-on version
|
|
|
|
- name: Read add-on version
|
|
|
|
id: version
|
|
|
|
id: version
|
|
|
|
|
|
|
|
# Plain shell instead of python3+PyYAML: the runner's Python has
|
|
|
|
|
|
|
|
# no yaml module installed, and this value is a simple one-liner
|
|
|
|
|
|
|
|
# anyway (version: "0.1.0"), so there's no need for a real YAML
|
|
|
|
|
|
|
|
# parser or an extra apt/pip install step just for this.
|
|
|
|
run: |
|
|
|
|
run: |
|
|
|
|
VERSION=$(python3 -c "import yaml; print(yaml.safe_load(open('mqtt-cert-manager/config.yaml'))['version'])")
|
|
|
|
VERSION=$(grep '^version:' mqtt-cert-manager/config.yaml | cut -d'"' -f2)
|
|
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
|
|
|
|
|
|
|
|
|
|
- name: Read base image for this arch from build.yaml
|
|
|
|
- name: Read base image for this arch from build.yaml
|
|
|
|
id: base
|
|
|
|
id: base
|
|
|
|
run: |
|
|
|
|
run: |
|
|
|
|
BUILD_FROM=$(python3 -c "
|
|
|
|
BUILD_FROM=$(grep -E "^[[:space:]]*${{ matrix.arch }}:" mqtt-cert-manager/build.yaml | cut -d'"' -f2)
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
d = yaml.safe_load(open('mqtt-cert-manager/build.yaml'))
|
|
|
|
|
|
|
|
print(d['build_from']['${{ matrix.arch }}'])
|
|
|
|
|
|
|
|
")
|
|
|
|
|
|
|
|
echo "build_from=$BUILD_FROM" >> "$GITHUB_OUTPUT"
|
|
|
|
echo "build_from=$BUILD_FROM" >> "$GITHUB_OUTPUT"
|
|
|
|
|
|
|
|
|
|
|
|
- name: Set up QEMU (needed to build non-amd64 targets on an amd64 runner)
|
|
|
|
- name: Set up QEMU (needed to build non-amd64 targets on an amd64 runner)
|
|
|
@@ -93,4 +117,4 @@ jobs:
|
|
|
|
BUILD_FROM=${{ steps.base.outputs.build_from }}
|
|
|
|
BUILD_FROM=${{ steps.base.outputs.build_from }}
|
|
|
|
tags: |
|
|
|
|
tags: |
|
|
|
|
${{ env.REGISTRY_HOST }}/${{ env.REGISTRY_OWNER }}/${{ env.IMAGE_NAME }}-${{ matrix.arch }}:${{ steps.version.outputs.version }}
|
|
|
|
${{ env.REGISTRY_HOST }}/${{ env.REGISTRY_OWNER }}/${{ env.IMAGE_NAME }}-${{ matrix.arch }}:${{ steps.version.outputs.version }}
|
|
|
|
${{ env.REGISTRY_HOST }}/${{ env.REGISTRY_OWNER }}/${{ env.IMAGE_NAME }}-${{ matrix.arch }}:latest
|
|
|
|
${{ env.REGISTRY_HOST }}/${{ env.REGISTRY_OWNER }}/${{ env.IMAGE_NAME }}-${{ matrix.arch }}:latest
|