Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/.pkgs.yml
Original file line number Diff line number Diff line change
@@ -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));
26 changes: 4 additions & 22 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
124 changes: 124 additions & 0 deletions .github/workflows/update-go.yml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 16 additions & 8 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

Expand All @@ -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"
}
}

Expand All @@ -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"
}
}

Expand All @@ -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"
}
}

Expand All @@ -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"
}
}

Expand All @@ -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"
}
}

Expand All @@ -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"
}
}

Expand All @@ -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"
}
}

Expand Down