From b7496ed2ebaa5cf67187041e09ee1cf6a65be6fc Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Fri, 14 Jun 2024 17:39:59 +0300 Subject: [PATCH] Include distro digests in manifests artifact Signed-off-by: Stefan Prodan --- .github/workflows/push-manifests.yml | 5 ++-- .github/workflows/release.yml | 2 +- .gitignore | 1 + Makefile | 5 +--- hack/build-dist-manifests.sh | 40 ++++++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 8 deletions(-) create mode 100755 hack/build-dist-manifests.sh diff --git a/.github/workflows/push-manifests.yml b/.github/workflows/push-manifests.yml index 1c98819..aa862b7 100644 --- a/.github/workflows/push-manifests.yml +++ b/.github/workflows/push-manifests.yml @@ -29,8 +29,7 @@ jobs: - name: Prepare id: prep run: | - VERSION="${{ github.event.inputs.tag }}-${GITHUB_SHA::8}" - echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT + VERSION="${{ github.event.inputs.tag }}-$(date +%s)" echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT - name: Login to GitHub Container Registry uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 @@ -49,7 +48,7 @@ jobs: img_digest=$(flux push artifact \ oci://ghcr.io/controlplaneio-fluxcd/${{ env.CONTROLLER }}-manifests:${{ steps.prep.outputs.VERSION }} \ - --path=dist \ + --path=disto \ --source=${{ github.repositoryUrl }} \ --revision="${{ github.ref_name }}@sha1:${{ github.sha }}" \ --annotations='org.opencontainers.image.description=Flux Operator' \ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 117c6f3..a806e9a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -90,7 +90,7 @@ jobs: img_digest=$(flux push artifact \ oci://ghcr.io/controlplaneio-fluxcd/${{ env.CONTROLLER }}-manifests:${{ steps.prep.outputs.VERSION }} \ - --path=dist \ + --path=disto \ --source=${{ github.repositoryUrl }} \ --revision="${{ github.ref_name }}@sha1:${{ github.sha }}" \ --annotations='org.opencontainers.image.description=Flux Operator' \ diff --git a/.gitignore b/.gitignore index 755d380..79fe858 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ # Go workspace file go.work bin/ +disto/ diff --git a/Makefile b/Makefile index f052525..2f9a691 100644 --- a/Makefile +++ b/Makefile @@ -117,10 +117,7 @@ build-installer: manifests generate kustomize ## Generate a consolidated YAML wi .PHONY: build-manifests build-manifests: ## Generate release manifests. - mkdir -p dist/flux-operator - kustomize build config/default > dist/flux-operator/install.yaml - mkdir -p dist/flux - cp -r config/data/flux/* dist/flux/ + hack/build-dist-manifests.sh ##@ Deployment diff --git a/hack/build-dist-manifests.sh b/hack/build-dist-manifests.sh new file mode 100755 index 0000000..e1fbe2f --- /dev/null +++ b/hack/build-dist-manifests.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# Copyright 2024 Stefan Prodan. +# SPDX-License-Identifier: AGPL-3.0 + +set -euo pipefail + +REPOSITORY_ROOT=$(git rev-parse --show-toplevel) +DEST_DIR="${REPOSITORY_ROOT}/disto" + +info() { + echo '[INFO] ' "$@" +} + +fatal() { + echo '[ERROR] ' "$@" >&2 + exit 1 +} + +rm -rf ${DEST_DIR} +mkdir -p ${DEST_DIR}/flux-operator +kustomize build config/default > ${DEST_DIR}/flux-operator/install.yaml +info "operator manifests generated to disto/flux-operator" + +mkdir -p ${DEST_DIR}/flux +cp -r config/data/flux/* ${DEST_DIR}/flux/ +info "flux manifests copied to disto/flux" + +info "downloading distro repository" +curl -sLO https://github.com/controlplaneio-fluxcd/distribution/archive/refs/heads/main.tar.gz +tar xzf main.tar.gz -C "${DEST_DIR}" + +mkdir -p "${DEST_DIR}/flux-images" +cp -r ${DEST_DIR}/distribution-main/images/* ${DEST_DIR}/flux-images/ +rm -rf ${DEST_DIR}/distribution-main +rm -rf main.tar.gz +info "flux image manifests copied to disto/flux-images" + +info "all manifests generated to disto/" +tree -d ${DEST_DIR}