From e0b7ead458bd54d72635c02dd5727eafc353dde2 Mon Sep 17 00:00:00 2001 From: Saman Sajedi Date: Sun, 11 Oct 2026 14:12:57 +0330 Subject: [PATCH] action - updated auto builder --- .gitea/workflows/build-and-push.yml | 99 ++++++++++++++++++++--------- README.md | 7 ++ mqtt-cert-manager/CHANGELOG.md | 4 ++ mqtt-cert-manager/Dockerfile | 7 +- mqtt-cert-manager/README.md | 7 +- mqtt-cert-manager/build.yaml | 10 --- mqtt-cert-manager/config.yaml | 4 +- visquitto/CHANGELOG.md | 5 ++ visquitto/Dockerfile | 14 +++- visquitto/README.md | 6 +- visquitto/config.yaml | 4 +- visquitto/translations/fa.yaml | 10 +-- 12 files changed, 118 insertions(+), 59 deletions(-) delete mode 100644 mqtt-cert-manager/build.yaml diff --git a/.gitea/workflows/build-and-push.yml b/.gitea/workflows/build-and-push.yml index e75e620..9c40d8a 100644 --- a/.gitea/workflows/build-and-push.yml +++ b/.gitea/workflows/build-and-push.yml @@ -21,15 +21,29 @@ # tag's commit is actually part of main's history (see check-branch job). name: build-and-push + on: push: tags: - - "v*" + - "mqtt-cert-manager/v*" + - "visquitto/v*" + workflow_dispatch: + inputs: + addon: + description: "Which add-on to build" + required: true + type: choice + options: + - mqtt-cert-manager + - visquitto + version: + description: "Version (e.g. 0.4.0) — leave empty to read from config.yaml" + required: false + default: "" env: REGISTRY_HOST: gitea.viratak.com REGISTRY_OWNER: bitopa - IMAGE_NAME: mqtt-cert-manager jobs: check-branch: @@ -42,12 +56,17 @@ jobs: with: fetch-depth: 0 - - name: Make sure we have main's history too + - name: Make sure we have main's history run: git fetch origin main:refs/remotes/origin/main - name: Is this tag's commit part of main? id: check run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "on_main=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + if git merge-base --is-ancestor HEAD origin/main; then echo "on_main=true" >> "$GITHUB_OUTPUT" else @@ -55,17 +74,56 @@ jobs: echo "Tag $GITHUB_REF_NAME points to a commit that is not on main — skipping build." fi - build: + prepare: needs: check-branch if: needs.check-branch.outputs.on_main == 'true' runs-on: ubuntu-latest + outputs: + addon: ${{ steps.meta.outputs.addon }} + version: ${{ steps.meta.outputs.version }} + image: ${{ steps.meta.outputs.image }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Determine add-on and version + id: meta + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + ADDON="${{ inputs.addon }}" + VERSION="${{ inputs.version }}" + else + # tag format: mqtt-cert-manager/v0.3.0 or visquitto/v0.4.0 + ADDON=$(echo "${{ github.ref_name }}" | cut -d/ -f1) + VERSION=$(echo "${{ github.ref_name }}" | cut -d/ -f2 | sed 's/^v//') + fi + + # Fallback: read version from config.yaml if not provided + if [ -z "$VERSION" ]; then + VERSION=$(grep '^version:' "$ADDON/config.yaml" | head -1 | sed -E 's/.*"([^"]+)".*/\1/') + fi + + if [ -z "$ADDON" ] || [ -z "$VERSION" ]; then + echo "Could not determine add-on or version" + exit 1 + fi + + echo "addon=$ADDON" >> "$GITHUB_OUTPUT" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + echo "image=${{ env.REGISTRY_HOST }}/${{ env.REGISTRY_OWNER }}/$ADDON" >> "$GITHUB_OUTPUT" + + echo "Building $ADDON version $VERSION" + + build: + needs: prepare + runs-on: ubuntu-latest strategy: + fail-fast: false matrix: include: - arch: amd64 platform: linux/amd64 - # TEMPORARY: only building amd64 while developing against a - # single Dell thin client — restore these before publishing. + # Uncomment when you are ready for multi-arch: # - arch: aarch64 # platform: linux/arm64 # - arch: armv7 @@ -78,23 +136,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Read add-on 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: | - VERSION=$(grep '^version:' mqtt-cert-manager/config.yaml | cut -d'"' -f2) - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - - - name: Read base image for this arch from build.yaml - id: base - run: | - BUILD_FROM=$(grep -E "^[[:space:]]*${{ matrix.arch }}:" mqtt-cert-manager/build.yaml | cut -d'"' -f2) - 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 uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -108,13 +150,12 @@ jobs: password: ${{ secrets.REGISTRY_TOKEN }} - name: Build and push - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: - context: ./mqtt-cert-manager + context: ./${{ needs.prepare.outputs.addon }} platforms: ${{ matrix.platform }} push: true - build-args: | - BUILD_FROM=${{ steps.base.outputs.build_from }} + # No BUILD_FROM needed anymore — modern Dockerfiles have a direct FROM 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 }}:latest \ No newline at end of file + ${{ needs.prepare.outputs.image }}-${{ matrix.arch }}:${{ needs.prepare.outputs.version }} + ${{ needs.prepare.outputs.image }}-${{ matrix.arch }}:latest \ No newline at end of file diff --git a/README.md b/README.md index 4b2de0a..dedc0aa 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,13 @@ This repository contains the following apps _Application to use as a certificate manager for Home Assistant._ +### [Visquitto](./visquitto) + + +![Supports amd64 Architecture][amd64-shield] + +_Application to use as a Second MQTT broker._ +