Skip to content

Commit

Permalink
hack: do not cache some stages on release
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Feb 2, 2023
1 parent 079e422 commit 53fc6aa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ jobs:
env:
PLATFORMS: ${{ env.PLATFORMS }},darwin/amd64,darwin/arm64,windows/amd64,windows/arm64
CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_BINARIES }} type=gha,scope=${{ env.CACHE_GHA_SCOPE_CROSS }}
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
-
name: Upload artifacts
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -501,6 +502,7 @@ jobs:
PLATFORMS: ${{ env.PLATFORMS }},linux/386,linux/mips,linux/mipsle,linux/mips64,linux/mips64le
CACHE_FROM: type=gha,scope=frontend-${{ needs.frontend-base.outputs.typ }}
CACHE_TO: type=gha,scope=frontend-${{ needs.frontend-base.outputs.typ }}
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
-
name: Build ${{ needs.frontend-base.outputs.typ }}/labs
if: needs.frontend-base.outputs.typ == 'master'
Expand All @@ -509,3 +511,4 @@ jobs:
env:
PLATFORMS: ${{ env.PLATFORMS }},linux/386,linux/mips,linux/mipsle,linux/mips64,linux/mips64le
CACHE_FROM: type=gha,scope=frontend-${{ needs.frontend-base.outputs.typ }}
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
14 changes: 10 additions & 4 deletions frontend/dockerfile/cmd/dockerfile-frontend/hack/release
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
. $(dirname $0)/../../../../../hack/util
set -e

: ${RELEASE=false}
: ${PLATFORMS=}
: ${DAILY_TARGETS=}

Expand Down Expand Up @@ -70,6 +71,11 @@ if [ "$PUSH" = "push" ]; then
pushFlag="push=true"
fi

nocacheFilterFlag=""
if [[ "$RELEASE" = "true" ]] && [[ "$GITHUB_ACTIONS" = "true" ]]; then
nocacheFilterFlag="--no-cache-filter=base"
fi

case $TYP in
"master")
tagf=./frontend/dockerfile/release/$TAG/tags
Expand All @@ -84,7 +90,7 @@ case $TYP in
pushTag=${pushTag}-$TAG
fi

buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $(buildAttestFlags) \
buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $nocacheFilterFlag $(buildAttestFlags) \
--build-arg "CHANNEL=$TAG" \
--build-arg "BUILDTAGS=$buildTags" \
--output "type=image,name=$REPO:$pushTag,buildinfo-attrs=true,$pushFlag" \
Expand All @@ -101,7 +107,7 @@ case $TYP in
fi
buildTags=$(cat $tagf)

buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $(buildAttestFlags) \
buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $nocacheFilterFlag $(buildAttestFlags) \
--build-arg "CHANNEL=$TAG" \
--build-arg "BUILDTAGS=$buildTags" \
--output "type=image,\"name=$publishedNames\",buildinfo-attrs=true,$pushFlag" \
Expand All @@ -127,7 +133,7 @@ case $TYP in

tmp=$(mktemp -d -t buildid.XXXXXXXXXX)
dt=$(date +%Y%m%d)
buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags \
buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $nocacheFilterFlag \
--target "buildid" \
--build-arg "CHANNEL=$TAG" \
--build-arg "BUILDTAGS=$buildTags" \
Expand All @@ -141,7 +147,7 @@ case $TYP in
buildid=$(cat $tmp/buildid)
echo "buildid: $buildid"

buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $(buildAttestFlags) \
buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $nocacheFilterFlag $(buildAttestFlags) \
--build-arg "CHANNEL=$TAG" \
--build-arg "BUILDTAGS=$buildTags" \
--output "type=image,name=$REPO:$dt-$TAG,buildinfo-attrs=true,$pushFlag" \
Expand Down
8 changes: 7 additions & 1 deletion hack/images
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PUSH=$3
. $(dirname $0)/util
set -eu -o pipefail

: ${RELEASE=false}
: ${PLATFORMS=}
: ${TARGET=}

Expand Down Expand Up @@ -91,5 +92,10 @@ for tagName in $tagNames; do
tagFlags="$tagFlags--tag=$tagName "
done

buildxCmd build $platformFlag $targetFlag $importCacheFlags $exportCacheFlags $tagFlags $outputFlag $attestFlags \
nocacheFilterFlag=""
if [[ "$RELEASE" = "true" ]] && [[ "$GITHUB_ACTIONS" = "true" ]]; then
nocacheFilterFlag="--no-cache-filter=git,buildkit-export,gobuild-base"
fi

buildxCmd build $platformFlag $targetFlag $importCacheFlags $exportCacheFlags $tagFlags $outputFlag $nocacheFilterFlag $attestFlags \
$currentcontext

0 comments on commit 53fc6aa

Please sign in to comment.