From 5f49931f7cc96c43a7a4c5882fae693ed955fb4b Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Wed, 26 Nov 2025 22:10:55 +0100 Subject: [PATCH 1/2] ci: create reusable workflow to list packages Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- .github/workflows/.pkgs.yml | 31 +++++++++++++++++++++++++++++++ .github/workflows/nightly.yml | 26 ++++---------------------- 2 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/.pkgs.yml diff --git a/.github/workflows/.pkgs.yml b/.github/workflows/.pkgs.yml new file mode 100644 index 00000000..63f9ca2f --- /dev/null +++ b/.github/workflows/.pkgs.yml @@ -0,0 +1,31 @@ +# reusable workflow +name: .pkgs + +on: + workflow_call: + outputs: + list: + description: List of packages as JSON array + value: ${{ jobs.run.outputs.pkgs }} + +jobs: + run: + runs-on: ubuntu-24.04 + outputs: + pkgs: ${{ steps.set.outputs.pkgs }} + steps: + - + name: Checkout + uses: actions/checkout@v6 + - + name: Set pkgs output + id: set + uses: actions/github-script@v8 + with: + script: | + const fs = require('fs'); + const path = require('path'); + const disabledPkgs = (process.env.DISABLED_PACKAGES || '').split(',').map(s => s.trim()).filter(Boolean); + const pkgs = fs.readdirSync('./pkg', { withFileTypes: true }).filter(d => d.isDirectory()).map(d => d.name).filter(name => !disabledPkgs.includes(name)); + core.info(JSON.stringify(pkgs, null, 2)); + core.setOutput('pkgs', JSON.stringify(pkgs)); diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c2c3d8db..56f6a765 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -11,35 +11,17 @@ on: - cron: '0 1 * * 0' jobs: - prepare: - runs-on: ubuntu-24.04 - outputs: - pkgs: ${{ steps.matrix.outputs.pkgs }} - steps: - - - name: Checkout - uses: actions/checkout@v6 - - - name: Matrix - id: matrix - uses: actions/github-script@v8 - with: - script: | - const fs = require('fs'); - const path = require('path'); - const disabledPkgs = (process.env.DISABLED_PACKAGES || '').split(',').map(s => s.trim()).filter(Boolean); - const pkgs = fs.readdirSync('./pkg', { withFileTypes: true }).filter(d => d.isDirectory()).map(d => d.name).filter(name => !disabledPkgs.includes(name)); - core.info(JSON.stringify(pkgs, null, 2)); - core.setOutput('pkgs', JSON.stringify(pkgs)); + pkgs: + uses: ./.github/workflows/.pkgs.yml build: uses: ./.github/workflows/.build.yml needs: - - prepare + - pkgs strategy: fail-fast: false matrix: - pkg: ${{ fromJson(needs.prepare.outputs.pkgs) }} + pkg: ${{ fromJson(needs.pkgs.outputs.list) }} with: name: ${{ matrix.pkg }} release: pushonly From f82a333debb513ee7cb702a7aa504de7052661e8 Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Thu, 27 Nov 2025 14:03:01 +0100 Subject: [PATCH 2/2] ci: update-go workflow to keep go version in sync Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- .github/workflows/update-go.yml | 124 ++++++++++++++++++++++++++++++++ docker-bake.hcl | 24 ++++--- 2 files changed, 140 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/update-go.yml diff --git a/.github/workflows/update-go.yml b/.github/workflows/update-go.yml new file mode 100644 index 00000000..876feb5b --- /dev/null +++ b/.github/workflows/update-go.yml @@ -0,0 +1,124 @@ +name: update-go + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + workflow_dispatch: + schedule: + - cron: '0 */6 * * *' + +jobs: + pkgs: + uses: ./.github/workflows/.pkgs.yml + + build: + runs-on: ubuntu-24.04 + needs: + - pkgs + steps: + - + name: Checkout + uses: actions/checkout@v6 + - + name: Get GO_VERSION from upstream repositories + id: get-go-versions + uses: actions/github-script@v8 + env: + INPUT_PKGS: ${{ needs.pkgs.outputs.list }} + with: + script: | + const inpPkgs = JSON.parse(core.getInput('pkgs')); + + const goVersions = []; + for (const pkg of inpPkgs) { + await core.group(`Getting go version for ${pkg} package`, async () => { + let pkgRepo = ''; + let pkgRef = ''; + let pkgDockerfile = ''; + await exec.getExecOutput('docker', ['buildx', 'bake', `metadata-${pkg}`, '--print'], { + ignoreReturnCode: true, + silent: true + }).then(res => { + if (res.stderr.length > 0 && res.exitCode != 0) { + throw new Error(res.stderr); + } + const dt = JSON.parse(res.stdout.trim()); + pkgRepo = dt.target[`metadata-${pkg}`].args.PKG_REPO; + pkgRef = dt.target[`metadata-${pkg}`].args.PKG_REF; + pkgDockerfile = dt.target[`metadata-${pkg}`].args.PKG_REMOTE_DOCKERFILE; + }); + + let goVersion = ''; + core.info(`Fetching GO_VERSION from ${pkgRepo}#${pkgRef}`); + await exec.getExecOutput('docker', ['buildx', 'build', '--call', 'outline,format=json', '-f', pkgDockerfile, `${pkgRepo}#${pkgRef}`], { + ignoreReturnCode: true, + silent: true + }).then(res => { + if (res.stderr.length > 0 && res.exitCode != 0) { + throw new Error(res.stderr); + } + const outline = JSON.parse(res.stdout.trim()); + goVersion = outline.args.find(arg => arg.name === 'GO_VERSION')?.value; + if (!goVersion) { + core.info(JSON.stringify(outline, null, 2)); + throw new Error(`GO_VERSION not found in outline args`); + } + core.info(`Found GO_VERSION: ${goVersion}`); + }); + goVersions.push({ pkg: pkg, go_version: goVersion }); + }); + } + + core.setOutput('list', JSON.stringify(goVersions)); + - + name: Set GO_VERSION in docker-bake.hcl and Dockerfiles + uses: actions/github-script@v8 + env: + INPUT_GO_VERSIONS: ${{ steps.get-go-versions.outputs.list }} + with: + script: | + const fs = require('fs'); + const path = require('path'); + + const inpGoVersions = JSON.parse(core.getInput('go_versions')); + + for (const item of inpGoVersions) { + const bakefilePath = 'docker-bake.hcl'; + core.info(`Updating GO_VERSION to ${item.go_version} in ${bakefilePath} for _pkg-${item.pkg} target`); + let bakeContent = fs.readFileSync(bakefilePath, 'utf8'); + const bakeRegex = new RegExp( + `target "_pkg-${item.pkg}" \\{[\\s\\S]*?GO_VERSION = GO_VERSION != null && GO_VERSION != "" \\? GO_VERSION : "([^"]+)"`, + 'm' + ); + bakeContent = bakeContent.replace(bakeRegex, (match, p1) => { + return match.replace(p1, item.go_version); + }); + fs.writeFileSync(bakefilePath, bakeContent); + + const dockerfilePath = path.join('pkg', item.pkg, 'Dockerfile'); + core.info(`Updating GO_VERSION to ${item.go_version} in ${dockerfilePath}`); + let dockerfileContent = fs.readFileSync(dockerfilePath, 'utf8'); + const dockerfileRegex = /^ARG GO_VERSION=.*$/m; + dockerfileContent = dockerfileContent.replace(dockerfileRegex, `ARG GO_VERSION="${item.go_version}"`); + fs.writeFileSync(dockerfilePath, dockerfileContent); + } + + await exec.exec(`git diff --color=always`); + - + name: Commit changes + run: | + git add -A . + - + name: Create PR + uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 + with: + base: main + branch: bot/update-go + signoff: true + delete-branch: true + title: "chore: align go version from upstream repositories" + body: | + Keep Go versions in sync with upstream repositories. + draft: false diff --git a/docker-bake.hcl b/docker-bake.hcl index 38e28b1d..25f93d04 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -522,9 +522,10 @@ target "_pkg-buildx" { PKG_NAME = PKG_NAME != null && PKG_NAME != "" ? PKG_NAME : "docker-buildx-plugin" PKG_REPO = PKG_REPO != null && PKG_REPO != "" ? PKG_REPO : "https://github.com/docker/buildx.git" PKG_REF = PKG_REF != null && PKG_REF != "" ? PKG_REF : "master" - GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.25.3" # https://github.com/docker/buildx/blob/854a58a65d5ada26ddc8b6ebd60ddb89fa5616a3/Dockerfile#L3 + GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.25.3" # https://github.com/docker/buildx/blob/master/Dockerfile GO_IMAGE_VARIANT = GO_IMAGE_VARIANT != null && GO_IMAGE_VARIANT != "" ? GO_IMAGE_VARIANT : "bookworm" PKG_DEB_EPOCH = PKG_DEB_EPOCH != null && PKG_DEB_EPOCH != "" ? PKG_DEB_EPOCH : "" + PKG_REMOTE_DOCKERFILE = "Dockerfile" } } @@ -533,9 +534,10 @@ target "_pkg-compose" { PKG_NAME = PKG_NAME != null && PKG_NAME != "" ? PKG_NAME : "docker-compose-plugin" PKG_REPO = PKG_REPO != null && PKG_REPO != "" ? PKG_REPO : "https://github.com/docker/compose.git" PKG_REF = PKG_REF != null && PKG_REF != "" ? PKG_REF : "main" - GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.24.9" # https://github.com/docker/compose/blob/fa081274567ac350f0e5f16abbe51701b320626e/Dockerfile#L18 + GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.24.9" # https://github.com/docker/compose/blob/main/Dockerfile GO_IMAGE_VARIANT = GO_IMAGE_VARIANT != null && GO_IMAGE_VARIANT != "" ? GO_IMAGE_VARIANT : "bookworm" PKG_DEB_EPOCH = PKG_DEB_EPOCH != null && PKG_DEB_EPOCH != "" ? PKG_DEB_EPOCH : "" + PKG_REMOTE_DOCKERFILE = "Dockerfile" } } @@ -544,10 +546,11 @@ target "_pkg-containerd" { PKG_NAME = PKG_NAME != null && PKG_NAME != "" ? PKG_NAME : "containerd.io" PKG_REPO = PKG_REPO != null && PKG_REPO != "" ? PKG_REPO : "https://github.com/containerd/containerd.git" PKG_REF = PKG_REF != null && PKG_REF != "" ? PKG_REF : "main" - GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.24.9" # https://github.com/containerd/containerd/blob/2d28d98490f53d78c98faecfc91f9fd54cdbc16e/.github/workflows/release.yml#L16 + GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.24.9" # https://github.com/containerd/containerd/blob/main/.github/workflows/release/Dockerfile GO_IMAGE_VARIANT = GO_IMAGE_VARIANT != null && GO_IMAGE_VARIANT != "" ? GO_IMAGE_VARIANT : "bookworm" PKG_DEB_EPOCH = PKG_DEB_EPOCH != null && PKG_DEB_EPOCH != "" ? PKG_DEB_EPOCH : "" RUNC_REF = RUNC_REF != null && RUNC_REF != "" ? RUNC_REF : null + PKG_REMOTE_DOCKERFILE = ".github/workflows/release/Dockerfile" } } @@ -556,9 +559,10 @@ target "_pkg-credential-helpers" { PKG_NAME = PKG_NAME != null && PKG_NAME != "" ? PKG_NAME : "docker-credential-helpers" PKG_REPO = PKG_REPO != null && PKG_REPO != "" ? PKG_REPO : "https://github.com/docker/docker-credential-helpers.git" PKG_REF = PKG_REF != null && PKG_REF != "" ? PKG_REF : "master" - GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.25.3" # https://github.com/docker/docker-credential-helpers/blob/b7a754b9ffdf0e99e63ca384435bdacf4bc83e6b/Dockerfile#L3 + GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.25.3" # https://github.com/docker/docker-credential-helpers/blob/master/Dockerfile GO_IMAGE_VARIANT = GO_IMAGE_VARIANT != null && GO_IMAGE_VARIANT != "" ? GO_IMAGE_VARIANT : "bookworm" PKG_DEB_EPOCH = PKG_DEB_EPOCH != null && PKG_DEB_EPOCH != "" ? PKG_DEB_EPOCH : "" + PKG_REMOTE_DOCKERFILE = "Dockerfile" } } @@ -567,9 +571,10 @@ target "_pkg-docker-cli" { PKG_NAME = PKG_NAME != null && PKG_NAME != "" ? PKG_NAME : "docker-ce-cli" PKG_REPO = PKG_REPO != null && PKG_REPO != "" ? PKG_REPO : "https://github.com/docker/cli.git" PKG_REF = PKG_REF != null && PKG_REF != "" ? PKG_REF : "master" - GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.25.3" # https://github.com/docker/cli/blob/d16defd9e237a02e4e8b8710d9ce4a15472e60c8/Dockerfile#L11 + GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.25.3" # https://github.com/docker/cli/blob/master/Dockerfile GO_IMAGE_VARIANT = GO_IMAGE_VARIANT != null && GO_IMAGE_VARIANT != "" ? GO_IMAGE_VARIANT : "bookworm" PKG_DEB_EPOCH = PKG_DEB_EPOCH != null && PKG_DEB_EPOCH != "" ? PKG_DEB_EPOCH : "5" + PKG_REMOTE_DOCKERFILE = "Dockerfile" } } @@ -578,9 +583,10 @@ target "_pkg-docker-engine" { PKG_NAME = PKG_NAME != null && PKG_NAME != "" ? PKG_NAME : "docker-ce" PKG_REPO = PKG_REPO != null && PKG_REPO != "" ? PKG_REPO : "https://github.com/docker/docker.git" PKG_REF = PKG_REF != null && PKG_REF != "" ? PKG_REF : "master" - GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.25.3" # https://github.com/moby/moby/blob/4b978319922166bab9116b3e60e716a62b9cf130/Dockerfile#L3 + GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.25.3" # https://github.com/moby/moby/blob/master/Dockerfile GO_IMAGE_VARIANT = GO_IMAGE_VARIANT != null && GO_IMAGE_VARIANT != "" ? GO_IMAGE_VARIANT : "bookworm" PKG_DEB_EPOCH = PKG_DEB_EPOCH != null && PKG_DEB_EPOCH != "" ? PKG_DEB_EPOCH : "5" + PKG_REMOTE_DOCKERFILE = "Dockerfile" } } @@ -589,9 +595,10 @@ target "_pkg-model" { PKG_NAME = PKG_NAME != null && PKG_NAME != "" ? PKG_NAME : "docker-model-plugin" PKG_REPO = PKG_REPO != null && PKG_REPO != "" ? PKG_REPO : "https://github.com/docker/model-runner.git" PKG_REF = PKG_REF != null && PKG_REF != "" ? PKG_REF : "main" - GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.24.9" # https://github.com/docker/model-runner/blob/039f7a31c0365f9161c9b9b6bb3888161d16e388/cmd/cli/Dockerfile#L3 + GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.24.9" # https://github.com/docker/model-runner/blob/main/cmd/cli/Dockerfile GO_IMAGE_VARIANT = GO_IMAGE_VARIANT != null && GO_IMAGE_VARIANT != "" ? GO_IMAGE_VARIANT : "bookworm" PKG_DEB_EPOCH = PKG_DEB_EPOCH != null && PKG_DEB_EPOCH != "" ? PKG_DEB_EPOCH : "" + PKG_REMOTE_DOCKERFILE = "Dockerfile" } } @@ -600,9 +607,10 @@ target "_pkg-cagent" { PKG_NAME = PKG_NAME != null && PKG_NAME != "" ? PKG_NAME : "cagent" PKG_REPO = PKG_REPO != null && PKG_REPO != "" ? PKG_REPO : "https://github.com/docker/cagent.git" PKG_REF = PKG_REF != null && PKG_REF != "" ? PKG_REF : "main" - GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.25.4" # https://github.com/docker/cagent/blob/259774ed55b2b51c4b602d9636d68a6bb23117ec/Dockerfile#L6 + GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.25.4" # https://github.com/docker/cagent/blob/main/Dockerfile GO_IMAGE_VARIANT = GO_IMAGE_VARIANT != null && GO_IMAGE_VARIANT != "" ? GO_IMAGE_VARIANT : "bookworm" PKG_DEB_EPOCH = PKG_DEB_EPOCH != null && PKG_DEB_EPOCH != "" ? PKG_DEB_EPOCH : "" + PKG_REMOTE_DOCKERFILE = "Dockerfile" } }