Skip to content

Commit

Permalink
add tagged image releases
Browse files Browse the repository at this point in the history
  • Loading branch information
schlapzz committed Jun 7, 2023
1 parent 2e6f34a commit 46e45b3
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions ci/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ func main() {

//Add GOFF and Gitlab CLI to our standard build container
//Push into registry
if refName == "main" {
err = publishImage(ctx, goffGitlab, daggerClient, regUser, secret)
if refName == "main" || isReleaseTag(refName, refType) {
tag := "latest"
if isReleaseTag(refName, refType) {
tag = refName
}
err = publishImage(ctx, goffGitlab, daggerClient, regUser, secret, tag)
}

return err
Expand All @@ -102,15 +106,15 @@ func main() {
}

//If version tag, build binary releases and release them on github
if refType == "tag" && strings.HasPrefix(refName, "v") {
if isReleaseTag(refName, refType) {
buildAndRelease(ctx, daggerClient, golang, refName)
//Build patched ArgoCD Repo server
buildArgoCdRepoServer(ctx, regUser, secret, daggerClient)
}

}

func publishImage(ctx context.Context, golang *dagger.Container, daggerClient *dagger.Client, regUser string, secret *dagger.Secret) error {
func publishImage(ctx context.Context, golang *dagger.Container, daggerClient *dagger.Client, regUser string, secret *dagger.Secret, tag string) error {
goffBin := golang.File("/app/goff")
glabBin := golang.File("/go/bin/glab")

Expand All @@ -121,7 +125,8 @@ func publishImage(ctx context.Context, golang *dagger.Container, daggerClient *d

goffContainer = goffContainer.WithEntrypoint([]string{"/bin/goff"})

_, err := goffContainer.WithRegistryAuth("quay.io", regUser, secret).Publish(ctx, "quay.io/puzzle/goff")
imageName := fmt.Sprintf("quay.io/puzzle/goff:%s", tag)
_, err := goffContainer.WithRegistryAuth("quay.io", regUser, secret).Publish(ctx, imageName)

return err
}
Expand Down Expand Up @@ -206,3 +211,7 @@ func buildAndRelease(ctx context.Context, client *dagger.Client, golang *dagger.
panic(err)
}
}

func isReleaseTag(refName, refType string) bool {
return refType == "tag" && strings.HasPrefix(refName, "v")
}

0 comments on commit 46e45b3

Please sign in to comment.