Skip to content

Commit

Permalink
Fix release of framework image (#2063)
Browse files Browse the repository at this point in the history
* Fix release of framework image

Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>

* have a git option

Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>

---------

Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
  • Loading branch information
mauromorales committed Dec 7, 2023
1 parent dbbf7d4 commit 2a6813e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ jobs:
strategy:
fail-fast: false
matrix:
include:
- security_profile: "generic"
- security_profile: "fips"
security_profile: [generic, fips]
framework_version: [master]
install:
uses: ./.github/workflows/reusable-install-test.yaml
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
insecure = true
http = true
EOF
earthly +multi-build-framework-image --SECURITY_PROFILE=${{ matrix.security_profile }}
earthly +multi-build-framework-image --SECURITY_PROFILE=${{ matrix.security_profile }} --FRAMEWORK_VERSION="git"
- name: Push to quay
env:
COSIGN_YES: true
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/reusable-build-framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
security_profile:
required: true
type: string
framework_version:
required: false
type: string

jobs:
build:
Expand Down Expand Up @@ -47,7 +50,7 @@ jobs:
http = true
EOF
# Push with earthly so it pushes the multi-arch properly
earthly --push +multi-build-framework-image --SECURITY_PROFILE=${{ inputs.security_profile }} --VERSION=master
earthly --push +multi-build-framework-image --SECURITY_PROFILE=${{ inputs.security_profile }} --FRAMEWORK_VERSION=${{ inputs.framework_version }}
# Fetch the RepoDigests for the mutli-arch image
docker pull "$ARTIFACT"
cosign sign $(docker image inspect --format='{{index .RepoDigests 0}}' "$ARTIFACT")
24 changes: 15 additions & 9 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ multi-build-framework-image:
build-framework-image:
FROM alpine
ARG SECURITY_PROFILE
ARG FRAMEWORK_VERSION

IF [ "$SECURITY_PROFILE" = "fips" ]
ARG _SECURITY_PROFILE=fips
Expand All @@ -321,13 +322,15 @@ build-framework-image:

ARG VERSION=$(cat ./GIT_VERSION)

IF [[ "$VERSION" =~ "v\d+\.\d+\.\d+$" ]]
ARG FRAMEWORK_VERSION=$VERSION
IF [ "$FRAMEWORK_VERSION" = "" ]
ARG _FRAMEWORK_VERSION=master
ELSE IF [ "$FRAMEWORK_VERSION" = "git" ]
ARG _FRAMEWORK_VERSION=$VERSION
ELSE
ARG FRAMEWORK_VERSION=master
ARG _FRAMEWORK_VERSION=$FRAMEWORK_VERSION
END

ARG _IMG="$IMAGE_REPOSITORY_ORG/framework:${FRAMEWORK_VERSION}_${_SECURITY_PROFILE}"
ARG _IMG="$IMAGE_REPOSITORY_ORG/framework:${_FRAMEWORK_VERSION}_${_SECURITY_PROFILE}"
RUN echo $_IMG > FRAMEWORK_IMAGE

SAVE ARTIFACT FRAMEWORK_IMAGE AS LOCAL build/FRAMEWORK_IMAGE
Expand All @@ -336,7 +339,7 @@ build-framework-image:

COPY (+framework/framework --SECURITY_PROFILE=$_SECURITY_PROFILE) /

SAVE IMAGE --push $IMAGE_REPOSITORY_ORG/framework:${FRAMEWORK_VERSION}_${_SECURITY_PROFILE}
SAVE IMAGE --push $IMAGE_REPOSITORY_ORG/framework:${_FRAMEWORK_VERSION}_${_SECURITY_PROFILE}

kairos-dockerfile:
ARG --required FAMILY
Expand All @@ -357,16 +360,19 @@ base-image:
ARG --required MODEL
ARG --required BASE_IMAGE # BASE_IMAGE is the image to apply the strategy (aka FLAVOR) on. E.g. ubuntu:20.04
ARG K3S_VERSION
ARG FRAMEWORK_VERSION
# TODO for the framework image. Do we call the last stable version available or master?
ARG K3S_VERSION
DO +GIT_VERSION

ARG KAIROS_VERSION=$(cat ./GIT_VERSION)

IF [[ "$KAIROS_VERSION" =~ "v\d+\.\d+\.\d+$" ]]
ARG FRAMEWORK_VERSION=$KAIROS_VERSION
IF [ "$FRAMEWORK_VERSION" = "" ]
ARG _FRAMEWORK_VERSION=master
ELSE IF [ "$FRAMEWORK_VERSION" = "git" ]
ARG _FRAMEWORK_VERSION=$VERSION
ELSE
ARG FRAMEWORK_VERSION=master
ARG _FRAMEWORK_VERSION=$FRAMEWORK_VERSION
END
RUN cat +kairos-dockerfile/Dockerfile

Expand All @@ -378,7 +384,7 @@ base-image:
--build-arg VARIANT=$VARIANT \
--build-arg VERSION=$KAIROS_VERSION \
--build-arg K3S_VERSION=$K3S_VERSION \
--build-arg FRAMEWORK_VERSION=$FRAMEWORK_VERSION \
--build-arg FRAMEWORK_VERSION=$_FRAMEWORK_VERSION \
-f +kairos-dockerfile/Dockerfile \
./images

Expand Down

0 comments on commit 2a6813e

Please sign in to comment.