From bd2ddc5e90ddca92ab7b53a8af42ae5766be758f Mon Sep 17 00:00:00 2001 From: Clement Michaud Date: Tue, 10 Dec 2019 09:21:54 +0100 Subject: [PATCH] Strip v prefix in git tag name when publishing in Docker. --- cmd/authelia-scripts/cmd_docker.go | 35 +++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/cmd/authelia-scripts/cmd_docker.go b/cmd/authelia-scripts/cmd_docker.go index f7ab41faa..4656685ed 100644 --- a/cmd/authelia-scripts/cmd_docker.go +++ b/cmd/authelia-scripts/cmd_docker.go @@ -19,7 +19,7 @@ var defaultArch = "amd64" var travisBranch = os.Getenv("TRAVIS_BRANCH") var travisPullRequest = os.Getenv("TRAVIS_PULL_REQUEST") var travisTag = os.Getenv("TRAVIS_TAG") -var dockerTags = regexp.MustCompile(`(?P(?Pv\d+)\.\d+)\.\d+.*`) +var dockerTags = regexp.MustCompile(`v(?P(?P(?P\d+)\.\d+)\.\d+.*)`) var ignoredSuffixes = regexp.MustCompile("alpha|beta") var tags = dockerTags.FindStringSubmatch(travisTag) @@ -204,17 +204,19 @@ func publishDockerImage(arch string) { login(docker) deploy(docker, "master-"+arch) } else if travisTag != "" { - if len(tags) == 3 { + if len(tags) == 4 { + fmt.Printf("Detected tags: '%s' | '%s' | '%s'", tags[1], tags[2], tags[3]) + login(docker) - deploy(docker, tags[0]+"-"+arch) + deploy(docker, tags[1]+"-"+arch) + if !ignoredSuffixes.MatchString(travisTag) { + deploy(docker, tags[2]+"-"+arch) + deploy(docker, tags[3]+"-"+arch) + deploy(docker, "latest-"+arch) + } } else { log.Fatal("Docker image will not be published, the specified tag does not conform to the standard") } - if !ignoredSuffixes.MatchString(travisTag) { - deploy(docker, tags[1]+"-"+arch) - deploy(docker, tags[2]+"-"+arch) - deploy(docker, "latest-"+arch) - } } else { log.Info("Docker image will not be published") } @@ -227,17 +229,20 @@ func publishDockerManifest() { login(docker) deployManifest(docker, "master", "master-amd64", "master-arm32v7", "master-arm64v8") } else if travisTag != "" { - if len(tags) == 3 { + if len(tags) == 4 { + fmt.Printf("Detected tags: '%s' | '%s' | '%s'", tags[1], tags[2], tags[3]) + login(docker) - deployManifest(docker, tags[0], tags[0]+"-amd64", tags[0]+"-arm32v7", tags[0]+"-arm64v8") + deployManifest(docker, tags[1], tags[1]+"-amd64", tags[1]+"-arm32v7", tags[1]+"-arm64v8") + + if !ignoredSuffixes.MatchString(travisTag) { + deployManifest(docker, tags[2], tags[2]+"-amd64", tags[2]+"-arm32v7", tags[2]+"-arm64v8") + deployManifest(docker, tags[3], tags[3]+"-amd64", tags[3]+"-arm32v7", tags[3]+"-arm64v8") + deployManifest(docker, "latest", "latest-amd64", "latest-arm32v7", "latest-arm64v8") + } } else { log.Fatal("Docker manifest will not be published, the specified tag does not conform to the standard") } - if !ignoredSuffixes.MatchString(travisTag) { - deployManifest(docker, tags[1], tags[1]+"-amd64", tags[1]+"-arm32v7", tags[1]+"-arm64v8") - deployManifest(docker, tags[2], tags[2]+"-amd64", tags[2]+"-arm32v7", tags[2]+"-arm64v8") - deployManifest(docker, "latest", "latest-amd64", "latest-arm32v7", "latest-arm64v8") - } } else { fmt.Println("Docker manifest will not be published") }