Skip to content

Commit

Permalink
Add Docker tags for major releases (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi committed Mar 19, 2024
1 parent 59b08d1 commit 7f624fa
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 31 deletions.
1 change: 1 addition & 0 deletions .golangci-new.yml
Expand Up @@ -93,6 +93,7 @@ linters:
- nonamedreturns
- nosprintfhostport
- paralleltest
- perfsprint
- prealloc
- predeclared
- promlinter
Expand Down
14 changes: 14 additions & 0 deletions extract-docker-tag/main.go
Expand Up @@ -212,19 +212,33 @@ func extract(action *githubactions.Action) (*result, error) {
}

if prerelease == "" {
res.developmentImages = append(res.developmentImages, fmt.Sprintf("ghcr.io/%s/%s-dev:%s", owner, name, major))
res.productionImages = append(res.productionImages, fmt.Sprintf("ghcr.io/%s/%s:%s", owner, name, major))

res.developmentImages = append(res.developmentImages, fmt.Sprintf("ghcr.io/%s/%s-dev:latest", owner, name))
res.productionImages = append(res.productionImages, fmt.Sprintf("ghcr.io/%s/%s:latest", owner, name))

// all-in-one only for FerretDB
if name == "ferretdb" {
res.allInOneImages = append(res.allInOneImages, fmt.Sprintf("ghcr.io/%s/all-in-one:%s", owner, major))

res.allInOneImages = append(res.allInOneImages, fmt.Sprintf("ghcr.io/%s/all-in-one:latest", owner))

// no forks, no other repos for Quay.io and Docker Hub
//nolint:lll // for readibility
if owner == "ferretdb" {
res.allInOneImages = append(res.allInOneImages, fmt.Sprintf("quay.io/ferretdb/all-in-one:%s", major))
res.developmentImages = append(res.developmentImages, fmt.Sprintf("quay.io/ferretdb/ferretdb-dev:%s", major))
res.productionImages = append(res.productionImages, fmt.Sprintf("quay.io/ferretdb/ferretdb:%s", major))

res.allInOneImages = append(res.allInOneImages, "quay.io/ferretdb/all-in-one:latest")
res.developmentImages = append(res.developmentImages, "quay.io/ferretdb/ferretdb-dev:latest")
res.productionImages = append(res.productionImages, "quay.io/ferretdb/ferretdb:latest")

res.allInOneImages = append(res.allInOneImages, fmt.Sprintf("ferretdb/all-in-one:%s", major))
res.developmentImages = append(res.developmentImages, fmt.Sprintf("ferretdb/ferretdb-dev:%s", major))
res.productionImages = append(res.productionImages, fmt.Sprintf("ferretdb/ferretdb:%s", major))

res.allInOneImages = append(res.allInOneImages, "ferretdb/all-in-one:latest")
res.developmentImages = append(res.developmentImages, "ferretdb/ferretdb-dev:latest")
res.productionImages = append(res.productionImages, "ferretdb/ferretdb:latest")
Expand Down
73 changes: 42 additions & 31 deletions extract-docker-tag/main_test.go
Expand Up @@ -146,7 +146,7 @@ func TestExtractFerretDB(t *testing.T) {
"GITHUB_BASE_REF": "",
"GITHUB_EVENT_NAME": "push",
"GITHUB_HEAD_REF": "",
"GITHUB_REF_NAME": "releases/1.2",
"GITHUB_REF_NAME": "releases/2.1",
"GITHUB_REF_TYPE": "branch",
"GITHUB_REPOSITORY": "FerretDB/FerretDB",
})
Expand All @@ -157,14 +157,14 @@ func TestExtractFerretDB(t *testing.T) {

expected := &result{
allInOneImages: []string{
"ferretdb/all-in-one:releases-1.2",
"ghcr.io/ferretdb/all-in-one:releases-1.2",
"quay.io/ferretdb/all-in-one:releases-1.2",
"ferretdb/all-in-one:releases-2.1",
"ghcr.io/ferretdb/all-in-one:releases-2.1",
"quay.io/ferretdb/all-in-one:releases-2.1",
},
developmentImages: []string{
"ferretdb/ferretdb-dev:releases-1.2",
"ghcr.io/ferretdb/ferretdb-dev:releases-1.2",
"quay.io/ferretdb/ferretdb-dev:releases-1.2",
"ferretdb/ferretdb-dev:releases-2.1",
"ghcr.io/ferretdb/ferretdb-dev:releases-2.1",
"quay.io/ferretdb/ferretdb-dev:releases-2.1",
},
}
assert.Equal(t, expected, actual)
Expand All @@ -175,7 +175,7 @@ func TestExtractFerretDB(t *testing.T) {
"GITHUB_BASE_REF": "",
"GITHUB_EVENT_NAME": "push",
"GITHUB_HEAD_REF": "",
"GITHUB_REF_NAME": "v0.1.0-beta",
"GITHUB_REF_NAME": "v2.1.0-beta",
"GITHUB_REF_TYPE": "tag",
"GITHUB_REPOSITORY": "FerretDB/FerretDB",
})
Expand All @@ -186,19 +186,19 @@ func TestExtractFerretDB(t *testing.T) {

expected := &result{
allInOneImages: []string{
"ferretdb/all-in-one:0.1.0-beta",
"ghcr.io/ferretdb/all-in-one:0.1.0-beta",
"quay.io/ferretdb/all-in-one:0.1.0-beta",
"ferretdb/all-in-one:2.1.0-beta",
"ghcr.io/ferretdb/all-in-one:2.1.0-beta",
"quay.io/ferretdb/all-in-one:2.1.0-beta",
},
developmentImages: []string{
"ferretdb/ferretdb-dev:0.1.0-beta",
"ghcr.io/ferretdb/ferretdb-dev:0.1.0-beta",
"quay.io/ferretdb/ferretdb-dev:0.1.0-beta",
"ferretdb/ferretdb-dev:2.1.0-beta",
"ghcr.io/ferretdb/ferretdb-dev:2.1.0-beta",
"quay.io/ferretdb/ferretdb-dev:2.1.0-beta",
},
productionImages: []string{
"ferretdb/ferretdb:0.1.0-beta",
"ghcr.io/ferretdb/ferretdb:0.1.0-beta",
"quay.io/ferretdb/ferretdb:0.1.0-beta",
"ferretdb/ferretdb:2.1.0-beta",
"ghcr.io/ferretdb/ferretdb:2.1.0-beta",
"quay.io/ferretdb/ferretdb:2.1.0-beta",
},
}
assert.Equal(t, expected, actual)
Expand All @@ -209,7 +209,7 @@ func TestExtractFerretDB(t *testing.T) {
"GITHUB_BASE_REF": "",
"GITHUB_EVENT_NAME": "push",
"GITHUB_HEAD_REF": "",
"GITHUB_REF_NAME": "v0.1.0",
"GITHUB_REF_NAME": "v2.1.0",
"GITHUB_REF_TYPE": "tag",
"GITHUB_REPOSITORY": "FerretDB/FerretDB",
})
Expand All @@ -220,27 +220,36 @@ func TestExtractFerretDB(t *testing.T) {

expected := &result{
allInOneImages: []string{
"ferretdb/all-in-one:0.1.0",
"ferretdb/all-in-one:2",
"ferretdb/all-in-one:2.1.0",
"ferretdb/all-in-one:latest",
"ghcr.io/ferretdb/all-in-one:0.1.0",
"ghcr.io/ferretdb/all-in-one:2",
"ghcr.io/ferretdb/all-in-one:2.1.0",
"ghcr.io/ferretdb/all-in-one:latest",
"quay.io/ferretdb/all-in-one:0.1.0",
"quay.io/ferretdb/all-in-one:2",
"quay.io/ferretdb/all-in-one:2.1.0",
"quay.io/ferretdb/all-in-one:latest",
},
developmentImages: []string{
"ferretdb/ferretdb-dev:0.1.0",
"ferretdb/ferretdb-dev:2",
"ferretdb/ferretdb-dev:2.1.0",
"ferretdb/ferretdb-dev:latest",
"ghcr.io/ferretdb/ferretdb-dev:0.1.0",
"ghcr.io/ferretdb/ferretdb-dev:2",
"ghcr.io/ferretdb/ferretdb-dev:2.1.0",
"ghcr.io/ferretdb/ferretdb-dev:latest",
"quay.io/ferretdb/ferretdb-dev:0.1.0",
"quay.io/ferretdb/ferretdb-dev:2",
"quay.io/ferretdb/ferretdb-dev:2.1.0",
"quay.io/ferretdb/ferretdb-dev:latest",
},
productionImages: []string{
"ferretdb/ferretdb:0.1.0",
"ferretdb/ferretdb:2",
"ferretdb/ferretdb:2.1.0",
"ferretdb/ferretdb:latest",
"ghcr.io/ferretdb/ferretdb:0.1.0",
"ghcr.io/ferretdb/ferretdb:2",
"ghcr.io/ferretdb/ferretdb:2.1.0",
"ghcr.io/ferretdb/ferretdb:latest",
"quay.io/ferretdb/ferretdb:0.1.0",
"quay.io/ferretdb/ferretdb:2",
"quay.io/ferretdb/ferretdb:2.1.0",
"quay.io/ferretdb/ferretdb:latest",
},
}
Expand All @@ -252,7 +261,7 @@ func TestExtractFerretDB(t *testing.T) {
"GITHUB_BASE_REF": "",
"GITHUB_EVENT_NAME": "push",
"GITHUB_HEAD_REF": "",
"GITHUB_REF_NAME": "0.1.0", // no leading v
"GITHUB_REF_NAME": "2.1.0", // no leading v
"GITHUB_REF_TYPE": "tag",
"GITHUB_REPOSITORY": "FerretDB/FerretDB",
})
Expand Down Expand Up @@ -371,7 +380,7 @@ func TestExtractOther(t *testing.T) {
"GITHUB_BASE_REF": "",
"GITHUB_EVENT_NAME": "push",
"GITHUB_HEAD_REF": "",
"GITHUB_REF_NAME": "v0.1.0",
"GITHUB_REF_NAME": "v2.1.0",
"GITHUB_REF_TYPE": "tag",
"GITHUB_REPOSITORY": "FerretDB/some-repo",
})
Expand All @@ -382,11 +391,13 @@ func TestExtractOther(t *testing.T) {

expected := &result{
developmentImages: []string{
"ghcr.io/ferretdb/some-repo-dev:0.1.0",
"ghcr.io/ferretdb/some-repo-dev:2",
"ghcr.io/ferretdb/some-repo-dev:2.1.0",
"ghcr.io/ferretdb/some-repo-dev:latest",
},
productionImages: []string{
"ghcr.io/ferretdb/some-repo:0.1.0",
"ghcr.io/ferretdb/some-repo:2",
"ghcr.io/ferretdb/some-repo:2.1.0",
"ghcr.io/ferretdb/some-repo:latest",
},
}
Expand Down

0 comments on commit 7f624fa

Please sign in to comment.