Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(build): Add major and minor tagging too #195

Merged
merged 5 commits into from
Jan 29, 2025
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
66 changes: 65 additions & 1 deletion actions/push-images/__tests__/docker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,65 +157,129 @@ describe('buildCommands', () => {
'docker load -i /images/fluentd-2.9.4-linux-amd64.tar',
'docker tag grafana/fluentd:2.9.4-amd64 grafana/fluentd:latest-amd64',
'docker push grafana/fluentd:latest-amd64',
'docker tag grafana/fluentd:2.9.4-amd64 grafana/fluentd:v2-amd64',
'docker push grafana/fluentd:v2-amd64',
'docker tag grafana/fluentd:2.9.4-amd64 grafana/fluentd:v2.9-amd64',
'docker push grafana/fluentd:v2.9-amd64',
'docker push -a grafana/fluentd',
'docker manifest create grafana/fluentd:2.9.4 grafana/fluentd:2.9.4-amd64',
'docker manifest push grafana/fluentd:2.9.4',
'docker manifest create grafana/fluentd:latest grafana/fluentd:latest-amd64',
'docker manifest push grafana/fluentd:latest',
'docker manifest create grafana/fluentd:v2 grafana/fluentd:v2-amd64',
'docker manifest push grafana/fluentd:v2',
'docker manifest create grafana/fluentd:v2.9 grafana/fluentd:v2.9-amd64',
'docker manifest push grafana/fluentd:v2.9',

'docker load -i /images/logcli-2.9.4-linux-amd64.tar',
'docker tag grafana/logcli:2.9.4-amd64 grafana/logcli:latest-amd64',
'docker push grafana/logcli:latest-amd64',
'docker tag grafana/logcli:2.9.4-amd64 grafana/logcli:v2-amd64',
'docker push grafana/logcli:v2-amd64',
'docker tag grafana/logcli:2.9.4-amd64 grafana/logcli:v2.9-amd64',
'docker push grafana/logcli:v2.9-amd64',
'docker load -i /images/logcli-2.9.4-linux-arm.tar',
'docker tag grafana/logcli:2.9.4-arm grafana/logcli:latest-arm',
'docker push grafana/logcli:latest-arm',
'docker tag grafana/logcli:2.9.4-arm grafana/logcli:v2-arm',
'docker push grafana/logcli:v2-arm',
'docker tag grafana/logcli:2.9.4-arm grafana/logcli:v2.9-arm',
'docker push grafana/logcli:v2.9-arm',
'docker load -i /images/logcli-2.9.4-linux-arm64.tar',
'docker tag grafana/logcli:2.9.4-arm64 grafana/logcli:latest-arm64',
'docker push grafana/logcli:latest-arm64',
'docker tag grafana/logcli:2.9.4-arm64 grafana/logcli:v2-arm64',
'docker push grafana/logcli:v2-arm64',
'docker tag grafana/logcli:2.9.4-arm64 grafana/logcli:v2.9-arm64',
'docker push grafana/logcli:v2.9-arm64',
'docker push -a grafana/logcli',
'docker manifest create grafana/logcli:2.9.4 grafana/logcli:2.9.4-amd64 grafana/logcli:2.9.4-arm grafana/logcli:2.9.4-arm64',
'docker manifest push grafana/logcli:2.9.4',
'docker manifest create grafana/logcli:latest grafana/logcli:latest-amd64 grafana/logcli:latest-arm grafana/logcli:latest-arm64',
'docker manifest push grafana/logcli:latest',
'docker manifest create grafana/logcli:v2 grafana/logcli:v2-amd64 grafana/logcli:v2-arm grafana/logcli:v2-arm64',
'docker manifest push grafana/logcli:v2',
'docker manifest create grafana/logcli:v2.9 grafana/logcli:v2.9-amd64 grafana/logcli:v2.9-arm grafana/logcli:v2.9-arm64',
'docker manifest push grafana/logcli:v2.9',

'docker load -i /images/logstash-2.9.4-linux-amd64.tar',
'docker tag grafana/logstash:2.9.4-amd64 grafana/logstash:latest-amd64',
'docker push grafana/logstash:latest-amd64',
'docker tag grafana/logstash:2.9.4-amd64 grafana/logstash:v2-amd64',
'docker push grafana/logstash:v2-amd64',
'docker tag grafana/logstash:2.9.4-amd64 grafana/logstash:v2.9-amd64',
'docker push grafana/logstash:v2.9-amd64',
'docker push -a grafana/logstash',
'docker manifest create grafana/logstash:2.9.4 grafana/logstash:2.9.4-amd64',
'docker manifest push grafana/logstash:2.9.4',
'docker manifest create grafana/logstash:latest grafana/logstash:latest-amd64',
'docker manifest push grafana/logstash:latest',
'docker manifest create grafana/logstash:v2 grafana/logstash:v2-amd64',
'docker manifest push grafana/logstash:v2',
'docker manifest create grafana/logstash:v2.9 grafana/logstash:v2.9-amd64',
'docker manifest push grafana/logstash:v2.9',

'docker load -i /images/loki-2.9.4-linux-amd64.tar',
'docker tag grafana/loki:2.9.4-amd64 grafana/loki:latest-amd64',
'docker push grafana/loki:latest-amd64',
'docker tag grafana/loki:2.9.4-amd64 grafana/loki:v2-amd64',
'docker push grafana/loki:v2-amd64',
'docker tag grafana/loki:2.9.4-amd64 grafana/loki:v2.9-amd64',
'docker push grafana/loki:v2.9-amd64',
'docker load -i /images/loki-2.9.4-linux-arm.tar',
'docker tag grafana/loki:2.9.4-arm grafana/loki:latest-arm',
'docker push grafana/loki:latest-arm',
'docker tag grafana/loki:2.9.4-arm grafana/loki:v2-arm',
'docker push grafana/loki:v2-arm',
'docker tag grafana/loki:2.9.4-arm grafana/loki:v2.9-arm',
'docker push grafana/loki:v2.9-arm',
'docker load -i /images/loki-2.9.4-linux-arm64.tar',
'docker tag grafana/loki:2.9.4-arm64 grafana/loki:latest-arm64',
'docker push grafana/loki:latest-arm64',
'docker tag grafana/loki:2.9.4-arm64 grafana/loki:v2-arm64',
'docker push grafana/loki:v2-arm64',
'docker tag grafana/loki:2.9.4-arm64 grafana/loki:v2.9-arm64',
'docker push grafana/loki:v2.9-arm64',
'docker push -a grafana/loki',
'docker manifest create grafana/loki:2.9.4 grafana/loki:2.9.4-amd64 grafana/loki:2.9.4-arm grafana/loki:2.9.4-arm64',
'docker manifest push grafana/loki:2.9.4',
'docker manifest create grafana/loki:latest grafana/loki:latest-amd64 grafana/loki:latest-arm grafana/loki:latest-arm64',
'docker manifest push grafana/loki:latest',
'docker manifest create grafana/loki:v2 grafana/loki:v2-amd64 grafana/loki:v2-arm grafana/loki:v2-arm64',
'docker manifest push grafana/loki:v2',
'docker manifest create grafana/loki:v2.9 grafana/loki:v2.9-amd64 grafana/loki:v2.9-arm grafana/loki:v2.9-arm64',
'docker manifest push grafana/loki:v2.9',

'docker load -i /images/loki-canary-2.9.4-linux-amd64.tar',
'docker tag grafana/loki-canary:2.9.4-amd64 grafana/loki-canary:latest-amd64',
'docker push grafana/loki-canary:latest-amd64',
'docker tag grafana/loki-canary:2.9.4-amd64 grafana/loki-canary:v2-amd64',
'docker push grafana/loki-canary:v2-amd64',
'docker tag grafana/loki-canary:2.9.4-amd64 grafana/loki-canary:v2.9-amd64',
'docker push grafana/loki-canary:v2.9-amd64',
'docker load -i /images/loki-canary-2.9.4-linux-arm.tar',
'docker tag grafana/loki-canary:2.9.4-arm grafana/loki-canary:latest-arm',
'docker push grafana/loki-canary:latest-arm',
'docker tag grafana/loki-canary:2.9.4-arm grafana/loki-canary:v2-arm',
'docker push grafana/loki-canary:v2-arm',
'docker tag grafana/loki-canary:2.9.4-arm grafana/loki-canary:v2.9-arm',
'docker push grafana/loki-canary:v2.9-arm',
'docker load -i /images/loki-canary-2.9.4-linux-arm64.tar',
'docker tag grafana/loki-canary:2.9.4-arm64 grafana/loki-canary:latest-arm64',
'docker push grafana/loki-canary:latest-arm64',
'docker tag grafana/loki-canary:2.9.4-arm64 grafana/loki-canary:v2-arm64',
'docker push grafana/loki-canary:v2-arm64',
'docker tag grafana/loki-canary:2.9.4-arm64 grafana/loki-canary:v2.9-arm64',
'docker push grafana/loki-canary:v2.9-arm64',
'docker push -a grafana/loki-canary',
'docker manifest create grafana/loki-canary:2.9.4 grafana/loki-canary:2.9.4-amd64 grafana/loki-canary:2.9.4-arm grafana/loki-canary:2.9.4-arm64',
'docker manifest push grafana/loki-canary:2.9.4',
'docker manifest create grafana/loki-canary:latest grafana/loki-canary:latest-amd64 grafana/loki-canary:latest-arm grafana/loki-canary:latest-arm64',
'docker manifest push grafana/loki-canary:latest'
'docker manifest push grafana/loki-canary:latest',
'docker manifest create grafana/loki-canary:v2 grafana/loki-canary:v2-amd64 grafana/loki-canary:v2-arm grafana/loki-canary:v2-arm64',
'docker manifest push grafana/loki-canary:v2',
'docker manifest create grafana/loki-canary:v2.9 grafana/loki-canary:v2.9-amd64 grafana/loki-canary:v2.9-arm grafana/loki-canary:v2.9-arm64',
'docker manifest push grafana/loki-canary:v2.9'
])
})

Expand Down
16 changes: 13 additions & 3 deletions actions/push-images/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 28 additions & 3 deletions actions/push-images/src/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ export function buildDockerPluginCommands(
if (isLatest) {
commands.push(
`docker plugin create ${repo}/${image}:latest-${shortPlatform} "${buildDir}"`,
`docker plugin push "${repo}/${image}:latest-${shortPlatform}"`
`docker plugin push "${repo}/${image}:latest-${shortPlatform}"`,
// Add major version tag (e.g., v2-amd64)
`docker plugin create ${repo}/${image}:v${version.major}-${shortPlatform} "${buildDir}"`,
`docker plugin push "${repo}/${image}:v${version.major}-${shortPlatform}"`,
// Add major.minor version tag (e.g., v2.9-amd64)
`docker plugin create ${repo}/${image}:v${version.major}.${version.minor}-${shortPlatform} "${buildDir}"`,
`docker plugin push "${repo}/${image}:v${version.major}.${version.minor}-${shortPlatform}"`
)
}
}
Expand Down Expand Up @@ -115,7 +121,13 @@ export function buildCommands(
if (isLatest) {
commands.push(
`docker tag ${repo}/${image}:${version.toString()}-${shortPlatform} ${repo}/${image}:latest-${shortPlatform}`,
`docker push ${repo}/${image}:latest-${shortPlatform}`
`docker push ${repo}/${image}:latest-${shortPlatform}`,
// Add major version tag (e.g., v2-amd64)
`docker tag ${repo}/${image}:${version.toString()}-${shortPlatform} ${repo}/${image}:v${version.major}-${shortPlatform}`,
`docker push ${repo}/${image}:v${version.major}-${shortPlatform}`,
// Add major.minor version tag (e.g., v2.9-amd64)
`docker tag ${repo}/${image}:${version.toString()}-${shortPlatform} ${repo}/${image}:v${version.major}.${version.minor}-${shortPlatform}`,
`docker push ${repo}/${image}:v${version.major}.${version.minor}-${shortPlatform}`
)
}
}
Expand All @@ -131,9 +143,22 @@ export function buildCommands(
const latestManifests = manifests.map(m =>
m.replace(`:${version.toString()}-`, ':latest-')
)
const majorManifests = manifests.map(m =>
m.replace(`:${version.toString()}-`, `:v${version.major}-`)
)
const majorMinorManifests = manifests.map(m =>
m.replace(
`:${version.toString()}-`,
`:v${version.major}.${version.minor}-`
)
)
commands.push(
`docker manifest create ${repo}/${image}:latest ${latestManifests.join(' ')}`,
`docker manifest push ${repo}/${image}:latest`
`docker manifest push ${repo}/${image}:latest`,
`docker manifest create ${repo}/${image}:v${version.major} ${majorManifests.join(' ')}`,
`docker manifest push ${repo}/${image}:v${version.major}`,
`docker manifest create ${repo}/${image}:v${version.major}.${version.minor} ${majorMinorManifests.join(' ')}`,
`docker manifest push ${repo}/${image}:v${version.major}.${version.minor}`
)
}
}
Expand Down