Skip to content

Commit 66e0587

Browse files
committed
hack: do not cache some stages on release
Signed-off-by: CrazyMax <[email protected]>
1 parent 821f130 commit 66e0587

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ jobs:
390390
run: |
391391
./hack/images "${{ needs.release-base.outputs.tag }}" "$REPO_SLUG_TARGET" "${{ needs.release-base.outputs.push }}"
392392
env:
393+
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
393394
TARGET: ${{ matrix.target-stage }}
394395
CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_CROSS }} type=gha,scope=image${{ matrix.target-stage }}
395396
CACHE_TO: type=gha,scope=image${{ matrix.target-stage }}
@@ -419,6 +420,7 @@ jobs:
419420
run: |
420421
./hack/release-tar "${{ needs.release-base.outputs.tag }}" release-out
421422
env:
423+
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
422424
PLATFORMS: ${{ env.PLATFORMS }},darwin/amd64,darwin/arm64,windows/amd64,windows/arm64
423425
CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_BINARIES }} type=gha,scope=${{ env.CACHE_GHA_SCOPE_CROSS }}
424426
-
@@ -514,6 +516,7 @@ jobs:
514516
run: |
515517
./frontend/dockerfile/cmd/dockerfile-frontend/hack/release "${{ needs.frontend-base.outputs.typ }}" "${{ matrix.tag }}" "$DF_REPO_SLUG_TARGET" "${{ needs.frontend-base.outputs.push }}"
516518
env:
519+
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
517520
PLATFORMS: ${{ env.PLATFORMS }},linux/386,linux/mips,linux/mipsle,linux/mips64,linux/mips64le
518521
CACHE_FROM: type=gha,scope=${{ env.CACHE_SCOPE }}
519522
CACHE_TO: type=gha,scope=${{ env.CACHE_SCOPE }}

frontend/dockerfile/cmd/dockerfile-frontend/hack/release

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
. $(dirname $0)/../../../../../hack/util
44
set -eu
55

6+
: "${RELEASE=false}"
67
: "${PLATFORMS=}"
78
: "${DAILY_TARGETS=}"
89

@@ -70,6 +71,11 @@ if [ "$PUSH" = "push" ]; then
7071
pushFlag="push=true"
7172
fi
7273

74+
nocacheFilterFlag=""
75+
if [[ "$RELEASE" = "true" ]] && [[ "$GITHUB_ACTIONS" = "true" ]]; then
76+
nocacheFilterFlag="--no-cache-filter=base"
77+
fi
78+
7379
case $TYP in
7480
"master")
7581
tagf=./frontend/dockerfile/release/$TAG/tags
@@ -84,7 +90,7 @@ case $TYP in
8490
pushTag=${pushTag}-$TAG
8591
fi
8692

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

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

128134
tmp=$(mktemp -d -t buildid.XXXXXXXXXX)
129135
dt=$(date +%Y%m%d)
130-
buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags \
136+
buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $nocacheFilterFlag \
131137
--target "buildid" \
132138
--build-arg "CHANNEL=$TAG" \
133139
--build-arg "BUILDTAGS=$buildTags" \
@@ -141,7 +147,7 @@ case $TYP in
141147
buildid=$(cat $tmp/buildid)
142148
echo "buildid: $buildid"
143149

144-
buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $(buildAttestFlags) \
150+
buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $nocacheFilterFlag $(buildAttestFlags) \
145151
--build-arg "CHANNEL=$TAG" \
146152
--build-arg "BUILDTAGS=$buildTags" \
147153
--output "type=image,name=$REPO:$dt-$TAG,buildinfo-attrs=true,$pushFlag" \

hack/images

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ PUSH=$3
77
. $(dirname $0)/util
88
set -eu -o pipefail
99

10+
: ${RELEASE=false}
1011
: ${PLATFORMS=}
1112
: ${TARGET=}
1213

@@ -91,5 +92,10 @@ for tagName in $tagNames; do
9192
tagFlags="$tagFlags--tag=$tagName "
9293
done
9394

94-
buildxCmd build $platformFlag $targetFlag $importCacheFlags $exportCacheFlags $tagFlags $outputFlag $attestFlags \
95+
nocacheFilterFlag=""
96+
if [[ "$RELEASE" = "true" ]] && [[ "$GITHUB_ACTIONS" = "true" ]]; then
97+
nocacheFilterFlag="--no-cache-filter=git,buildkit-export,gobuild-base"
98+
fi
99+
100+
buildxCmd build $platformFlag $targetFlag $importCacheFlags $exportCacheFlags $tagFlags $outputFlag $nocacheFilterFlag $attestFlags \
95101
$currentcontext

hack/release-tar

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ OUT=$2
66
. $(dirname $0)/util
77
set -eu -o pipefail
88

9+
: ${RELEASE=false}
910
: ${PLATFORMS=}
1011

1112
usage() {
@@ -22,9 +23,14 @@ if [ -n "$PLATFORMS" ]; then
2223
platformFlag="--platform=$PLATFORMS"
2324
fi
2425

26+
nocacheFilterFlag=""
27+
if [[ "$RELEASE" = "true" ]] && [[ "$GITHUB_ACTIONS" = "true" ]]; then
28+
nocacheFilterFlag="--no-cache-filter=git,gobuild-base"
29+
fi
30+
2531
output=$(mktemp -d -t buildkit-output.XXXXXXXXXX)
2632

27-
buildxCmd build $platformFlag $cacheFromFlags $(buildAttestFlags) \
33+
buildxCmd build $platformFlag $cacheFromFlags $nocacheFilterFlag $(buildAttestFlags) \
2834
--build-arg "BUILDKIT_MULTI_PLATFORM=true" \
2935
--target release \
3036
--output "type=local,dest=$output" \

0 commit comments

Comments
 (0)