-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from cortexproject/release-to-quay
Use goreleaser for releases to quay.io
- Loading branch information
Showing
8 changed files
with
198 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ docker-images/ | |
.vscode | ||
compose | ||
compose-simple | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
before: | ||
hooks: | ||
- go mod download | ||
# you may remove this if you don't need go generate | ||
- go generate ./... | ||
project_name: auth-gateway | ||
builds: | ||
- id: auth-gateway-darwin | ||
ldflags: | ||
-s -w -X github.com/cortexproject/auth-gateway/version.Version={{.Version}} | ||
binary: auth-gateway | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
- id: auth-gateway-linux | ||
ldflags: | ||
-s -w -X github.com/cortexproject/auth-gateway/version.Version={{.Version}} | ||
binary: auth-gateway | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
- id: auth-gateway-windows | ||
ldflags: | ||
-s -w -X github.com/cortexproject/auth-gateway/version.Version={{.Version}} | ||
binary: auth-gateway | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- windows | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
archives: | ||
- format_overrides: | ||
- goos: windows | ||
format: zip | ||
files: | ||
- none* | ||
format: binary | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ .Tag }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
dockers: | ||
- goarch: amd64 | ||
image_templates: | ||
- "quay.io/cortexproject/auth-gateway:{{ .Tag }}-amd64" | ||
build_flag_templates: | ||
- "--label=org.opencontainers.image.created={{.Date}}" | ||
- "--label=org.opencontainers.image.name={{.ProjectName}}" | ||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
- "--label=org.opencontainers.image.version={{.Version}}" | ||
- "--label=repository=https://github.com/cortexproject/auth-gateway" | ||
- "--label=homepage=https://cortexmetrics.io" | ||
- "--platform=linux/amd64" | ||
use: buildx | ||
- goarch: arm64 | ||
image_templates: | ||
- "quay.io/cortexproject/auth-gateway:{{ .Tag }}-arm64" | ||
build_flag_templates: | ||
- "--label=org.opencontainers.image.created={{.Date}}" | ||
- "--label=org.opencontainers.image.name={{.ProjectName}}" | ||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
- "--label=org.opencontainers.image.version={{.Version}}" | ||
- "--label=repository=https://github.com/cortexproject/auth-gateway" | ||
- "--label=homepage=https://cortexmetrics.io" | ||
- "--platform=linux/arm64" | ||
use: buildx | ||
docker_manifests: | ||
- name_template: "quay.io/cortexproject/auth-gateway:{{.Tag}}" | ||
image_templates: | ||
- "quay.io/cortexproject/auth-gateway:{{.Tag}}-amd64" | ||
- "quay.io/cortexproject/auth-gateway:{{.Tag}}-arm64" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM alpine:3.18 | ||
RUN apk add --update --no-cache ca-certificates | ||
COPY auth-gateway /usr/bin/auth-gateway | ||
EXPOSE 80 | ||
ENTRYPOINT [ "/usr/bin/auth-gateway" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Release process | ||
|
||
1. Create a new tag that follows semantic versioning: | ||
|
||
```bash | ||
$ tag=v0.3.0 | ||
$ git tag -s "${tag}" -m "${tag}" | ||
$ git push origin "${tag}" | ||
``` | ||
|
||
2. Make sure you are using goreleaser >= v1.19.2 | ||
3. Run `$ goreleaser release --rm-dist` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package version | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/google/go-github/v53/github" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
var ( | ||
errUnableToRetrieveLatestVersion = errors.New("unable to fetch the latest version from GitHub") | ||
) | ||
|
||
// Version defines the version for the binary, this is actually set by GoReleaser. | ||
var Version = "main" | ||
|
||
// Template controls how the version is displayed | ||
var Template = fmt.Sprintf("version %s\n", Version) | ||
|
||
// CheckLatest asks GitHub | ||
func CheckLatest() { | ||
if Version != "main" { | ||
latest, err := getLatestFromGitHub() | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
|
||
version := Version | ||
if latest != "" && (strings.TrimPrefix(latest, "v") != strings.TrimPrefix(version, "v")) { | ||
fmt.Printf("A newer version of auth-gateway is available, please update to %s\n", latest) | ||
} else { | ||
fmt.Println("You are on the latest version") | ||
} | ||
} | ||
} | ||
|
||
func getLatestFromGitHub() (string, error) { | ||
fmt.Print("checking latest version... ") | ||
c := github.NewClient(nil) | ||
repoRelease, resp, err := c.Repositories.GetLatestRelease(context.Background(), "cortexproject", "auth-gateway") | ||
if err != nil { | ||
log.WithFields(log.Fields{"err": err}).Debugln("error while retrieving the latest version") | ||
return "", errUnableToRetrieveLatestVersion | ||
} | ||
|
||
if resp.StatusCode/100 != 2 { | ||
log.WithFields(log.Fields{"status": resp.StatusCode}).Debugln("non-2xx status code while contacting the GitHub API") | ||
return "", errUnableToRetrieveLatestVersion | ||
} | ||
|
||
return *repoRelease.TagName, nil | ||
} |