Skip to content

Commit f773c1f

Browse files
committed
ci: clean Docker tags
1 parent 469070c commit f773c1f

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

.github/workflows/docker.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
} >> "${GITHUB_OUTPUT}"
9696
env:
9797
SHA: ${{ github.sha }}
98-
VERSION: ${{ (github.ref_type == 'tag' && github.ref_name) || steps.check.outputs.ref || github.sha }}
98+
VERSION: ${{ (github.ref_type == 'tag' && github.ref_name) || steps.check.outputs.ref || 'dev' }}
9999
PHP_VERSION: ${{ steps.check.outputs.php_version }}
100100
build:
101101
runs-on: ubuntu-latest
@@ -170,7 +170,7 @@ jobs:
170170
${{ fromJson(needs.prepare.outputs.push) && format('*.output=type=image,name={0},push-by-digest=true,name-canonical=true,push=true', env.IMAGE_NAME) || '' }}
171171
env:
172172
SHA: ${{ github.sha }}
173-
VERSION: ${{ github.ref_type == 'tag' && github.ref_name || needs.prepare.outputs.ref || github.sha }}
173+
VERSION: ${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref || 'dev' }}
174174
PHP_VERSION: ${{ needs.prepare.outputs.php_version }}
175175
-
176176
# Workaround for https://github.com/actions/runner/pull/2477#issuecomment-1501003600
@@ -235,9 +235,6 @@ jobs:
235235
-
236236
name: Set up Docker Buildx
237237
uses: docker/setup-buildx-action@v3
238-
with:
239-
# Temporary fix for https://github.com/docker/buildx/issues/2229
240-
version: "https://github.com/docker/buildx.git#master"
241238
-
242239
name: Login to DockerHub
243240
uses: docker/login-action@v3

.github/workflows/static.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
} >> "${GITHUB_OUTPUT}"
6868
env:
6969
SHA: ${{ github.sha }}
70-
VERSION: ${{ steps.check.outputs.ref || github.sha }}
70+
VERSION: ${{ steps.check.outputs.ref || 'dev' }}
7171
build-linux:
7272
strategy:
7373
fail-fast: false
@@ -136,7 +136,7 @@ jobs:
136136
${{ (fromJson(needs.prepare.outputs.push) && !matrix.debug && !matrix.mimalloc) && format('*.output=type=image,name={0},push-by-digest=true,name-canonical=true,push=true', env.IMAGE_NAME) || '' }}
137137
env:
138138
SHA: ${{ github.sha }}
139-
VERSION: ${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref || github.sha }}
139+
VERSION: ${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref || 'dev' }}
140140
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141141
-
142142
# Workaround for https://github.com/actions/runner/pull/2477#issuecomment-1501003600

docker-bake.hcl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ variable DEFAULT_PHP_VERSION {
3131
function "tag" {
3232
params = [version, os, php-version, tgt]
3333
result = [
34-
version != "" ? format("%s:%s%s-php%s-%s", IMAGE_NAME, version, tgt == "builder" ? "-builder" : "", php-version, os) : "",
35-
php-version == DEFAULT_PHP_VERSION && os == "bookworm" && version != "" ? format("%s:%s%s", IMAGE_NAME, version, tgt == "builder" ? "-builder" : "") : "",
36-
php-version == DEFAULT_PHP_VERSION && version != "" ? format("%s:%s%s-%s", IMAGE_NAME, version, tgt == "builder" ? "-builder" : "", os) : "",
37-
php-version == DEFAULT_PHP_VERSION && version == "latest" ? format("%s:%s%s", IMAGE_NAME, os, tgt == "builder" ? "-builder" : "") : "",
38-
os == "bookworm" && version != "" ? format("%s:%s%s-php%s", IMAGE_NAME, version, tgt == "builder" ? "-builder" : "", php-version) : "",
34+
version == "" ? "" : "${IMAGE_NAME}:${trimprefix("${version}${tgt == "builder" ? "-builder" : ""}-php${php-version}-${os}", "latest-")}",
35+
php-version == DEFAULT_PHP_VERSION && os == "bookworm" && version != "" ? "${IMAGE_NAME}:${trimprefix("${version}${tgt == "builder" ? "-builder" : ""}", "latest-")}" : "",
36+
php-version == DEFAULT_PHP_VERSION && version != "" ? "${IMAGE_NAME}:${trimprefix("${version}${tgt == "builder" ? "-builder" : ""}-${os}", "latest-")}" : "",
37+
os == "bookworm" && version != "" ? "${IMAGE_NAME}:${trimprefix("${version}${tgt == "builder" ? "-builder" : ""}-php${php-version}", "latest-")}" : "",
3938
]
4039
}
4140

@@ -60,7 +59,7 @@ function "_semver" {
6059

6160
function "__semver" {
6261
params = [v]
63-
result = v == {} ? [clean_tag(VERSION)] : v.prerelease == null ? ["latest", v.major, "${v.major}.${v.minor}", "${v.major}.${v.minor}.${v.patch}"] : ["${v.major}.${v.minor}.${v.patch}-${v.prerelease}"]
62+
result = v == {} ? [clean_tag(VERSION)] : v.prerelease == null ? [v.major, "${v.major}.${v.minor}", "${v.major}.${v.minor}.${v.patch}"] : ["${v.major}.${v.minor}.${v.patch}-${v.prerelease}"]
6463
}
6564

6665
function "php_version" {
@@ -103,8 +102,8 @@ target "default" {
103102
tags = distinct(flatten(
104103
[for pv in php_version(php-version) : flatten([
105104
LATEST ? tag("latest", os, pv, tgt) : [],
106-
tag(SHA == "" || SHA == VERSION ? "" : "sha-${substr(SHA, 0, 7)}", os, pv, tgt),
107-
[for v in semver(VERSION) : tag(v, os, pv, tgt)]
105+
tag(SHA == "" || VERSION != "dev" ? "" : "sha-${substr(SHA, 0, 7)}", os, pv, tgt),
106+
VERSION == "dev" ? [] : [for v in semver(VERSION) : tag(v, os, pv, tgt)]
108107
])
109108
]))
110109
labels = {
@@ -129,8 +128,8 @@ target "static-builder" {
129128
]
130129
tags = distinct(flatten([
131130
LATEST ? "${IMAGE_NAME}:static-builder" : "",
132-
SHA == "" || SHA == VERSION ? "" : "${IMAGE_NAME}:static-builder-sha-${substr(SHA, 0, 7)}",
133-
[for v in semver(VERSION) : v == "latest" ? "${IMAGE_NAME}:static-builder": "${IMAGE_NAME}:static-builder-${v}"]
131+
SHA == "" || VERSION != "dev" ? "" : "${IMAGE_NAME}:static-builder-sha-${substr(SHA, 0, 7)}",
132+
VERSION == "dev" ? [] : [for v in semver(VERSION) : "${IMAGE_NAME}:static-builder-${v}"]
134133
]))
135134
labels = {
136135
"org.opencontainers.image.created" = "${timestamp()}"

0 commit comments

Comments
 (0)