-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This updates the build process to use goreleaser for compiling the binaries and Docker containers, adding support for arm-based builds and Docker containers. It also bundles version information into the binary and log output for easier debugging. Closes #96 Closes #52
- Loading branch information
Showing
16 changed files
with
405 additions
and
274 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: 'release' | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
permissions: | ||
contents: 'write' | ||
packages: 'write' | ||
|
||
jobs: | ||
release: | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- uses: 'docker/setup-qemu-action@v2' | ||
|
||
- uses: 'actions/checkout@v3' | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: 'actions/setup-go@v3' | ||
with: | ||
go-version: '1.19' | ||
|
||
- uses: 'docker/login-action@v2' | ||
with: | ||
registry: 'asia-docker.pkg.dev' | ||
username: '_json_key' | ||
password: '${{ secrets.GOOGLE_CREDENTIALS }}' | ||
|
||
- uses: 'docker/login-action@v2' | ||
with: | ||
registry: 'europe-docker.pkg.dev' | ||
username: '_json_key' | ||
password: '${{ secrets.GOOGLE_CREDENTIALS }}' | ||
|
||
- uses: 'docker/login-action@v2' | ||
with: | ||
registry: 'us-docker.pkg.dev' | ||
username: '_json_key' | ||
password: '${{ secrets.GOOGLE_CREDENTIALS }}' | ||
|
||
- id: 'import_gpg' | ||
uses: 'crazy-max/ghaction-import-gpg@v5' | ||
with: | ||
gpg_private_key: '${{ secrets.GPG_PRIVATE_KEY }}' | ||
passphrase: '${{ secrets.GPG_PASSPHRASE }}' | ||
|
||
- uses: 'goreleaser/goreleaser-action@v3' | ||
with: | ||
version: 'latest' | ||
args: 'release --rm-dist' | ||
env: | ||
GPG_FINGERPRINT: '${{ steps.import_gpg.outputs.fingerprint }}' | ||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
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,253 @@ | ||
before: | ||
hooks: | ||
- 'go mod tidy' | ||
|
||
builds: | ||
# cli | ||
- | ||
id: 'cli' | ||
env: | ||
- 'CGO_ENABLED=0' | ||
- 'GO111MODULE=on' | ||
- 'GOPROXY=https://proxy.golang.org,direct' | ||
mod_timestamp: '{{ .CommitTimestamp }}' | ||
flags: | ||
- '-a' | ||
- '-trimpath' | ||
ldflags: | ||
- '-s' | ||
- '-w' | ||
- '-X={{ .ModulePath }}/internal/version.Name=gcr-cleaner-cli' | ||
- '-X={{ .ModulePath }}/internal/version.Version={{ .Version }}' | ||
- '-X={{ .ModulePath }}/internal/version.Commit={{ .FullCommit }}' | ||
- '-extldflags=-static' | ||
main: './cmd/gcr-cleaner-cli/...' | ||
goos: | ||
- 'darwin' | ||
- 'linux' | ||
- 'windows' | ||
goarch: | ||
- 'amd64' | ||
- 'arm64' | ||
|
||
# server | ||
- | ||
id: 'server' | ||
env: | ||
- 'CGO_ENABLED=0' | ||
- 'GO111MODULE=on' | ||
- 'GOPROXY=https://proxy.golang.org,direct' | ||
mod_timestamp: '{{ .CommitTimestamp }}' | ||
flags: | ||
- '-a' | ||
- '-trimpath' | ||
ldflags: | ||
- '-s' | ||
- '-w' | ||
- '-X={{ .ModulePath }}/internal/version.Name=gcr-cleaner' | ||
- '-X={{ .ModulePath }}/internal/version.Version={{ .Version }}' | ||
- '-X={{ .ModulePath }}/internal/version.Commit={{ .FullCommit }}' | ||
- '-extldflags=-static' | ||
main: './cmd/gcr-cleaner-server/...' | ||
goos: | ||
- 'darwin' | ||
- 'linux' | ||
- 'windows' | ||
goarch: | ||
- 'amd64' | ||
- 'arm64' | ||
|
||
dockers: | ||
# cli | ||
- | ||
use: 'buildx' | ||
goos: 'linux' | ||
goarch: 'amd64' | ||
dockerfile: 'docker/cli.dockerfile' | ||
ids: | ||
- 'cli' | ||
image_templates: | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:{{ .Version }}-amd64' | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest-amd64' | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:{{ .Version }}-amd64' | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest-amd64' | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:{{ .Version }}-amd64' | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest-amd64' | ||
build_flag_templates: | ||
- '--platform=linux/amd64' | ||
- '--pull' | ||
- '--label=org.opencontainers.image.created={{ .CommitTimestamp }}' | ||
- '--label=org.opencontainers.image.description=gcr-cleaner deletes untagged images in Docker container registries.' | ||
- '--label=org.opencontainers.image.licenses=Apache-2.0' | ||
- '--label=org.opencontainers.image.name=gcr-cleaner' | ||
- '--label=org.opencontainers.image.revision={{ .FullCommit }}' | ||
- '--label=org.opencontainers.image.source={{ .GitURL }}' | ||
- '--label=org.opencontainers.image.title=gcr-cleaner' | ||
- '--label=org.opencontainers.image.version={{ .Version }}' | ||
- | ||
use: 'buildx' | ||
goos: 'linux' | ||
goarch: 'arm64' | ||
dockerfile: 'docker/cli.dockerfile' | ||
ids: | ||
- 'cli' | ||
image_templates: | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:{{ .Version }}-arm64' | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest-arm64' | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:{{ .Version }}-arm64' | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest-arm64' | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:{{ .Version }}-arm64' | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest-arm64' | ||
build_flag_templates: | ||
- '--platform=linux/arm64' | ||
- '--pull' | ||
- '--label=org.opencontainers.image.created={{ .CommitTimestamp }}' | ||
- '--label=org.opencontainers.image.description=gcr-cleaner deletes untagged images in Docker container registries.' | ||
- '--label=org.opencontainers.image.licenses=Apache-2.0' | ||
- '--label=org.opencontainers.image.name=gcr-cleaner' | ||
- '--label=org.opencontainers.image.revision={{ .FullCommit }}' | ||
- '--label=org.opencontainers.image.source={{ .GitURL }}' | ||
- '--label=org.opencontainers.image.title=gcr-cleaner' | ||
- '--label=org.opencontainers.image.version={{ .Version }}' | ||
|
||
# server | ||
- | ||
use: 'buildx' | ||
goos: 'linux' | ||
goarch: 'amd64' | ||
dockerfile: 'docker/server.dockerfile' | ||
ids: | ||
- 'server' | ||
image_templates: | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:{{ .Version }}-amd64' | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:latest-amd64' | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:{{ .Version }}-amd64' | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:latest-amd64' | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:{{ .Version }}-amd64' | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:latest-amd64' | ||
build_flag_templates: | ||
- '--platform=linux/amd64' | ||
- '--pull' | ||
- '--label=org.opencontainers.image.created={{ .CommitTimestamp }}' | ||
- '--label=org.opencontainers.image.description=gcr-cleaner deletes untagged images in Docker container registries.' | ||
- '--label=org.opencontainers.image.licenses=Apache-2.0' | ||
- '--label=org.opencontainers.image.name=gcr-cleaner' | ||
- '--label=org.opencontainers.image.revision={{ .FullCommit }}' | ||
- '--label=org.opencontainers.image.source={{ .GitURL }}' | ||
- '--label=org.opencontainers.image.title=gcr-cleaner' | ||
- '--label=org.opencontainers.image.version={{ .Version }}' | ||
- | ||
use: 'buildx' | ||
goos: 'linux' | ||
goarch: 'arm64' | ||
dockerfile: 'docker/server.dockerfile' | ||
ids: | ||
- 'server' | ||
image_templates: | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:{{ .Version }}-arm64' | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:latest-arm64' | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:{{ .Version }}-arm64' | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:latest-arm64' | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:{{ .Version }}-arm64' | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:latest-arm64' | ||
build_flag_templates: | ||
- '--platform=linux/arm64' | ||
- '--pull' | ||
- '--label=org.opencontainers.image.created={{ .CommitTimestamp }}' | ||
- '--label=org.opencontainers.image.description=gcr-cleaner deletes untagged images in Docker container registries.' | ||
- '--label=org.opencontainers.image.licenses=Apache-2.0' | ||
- '--label=org.opencontainers.image.name=gcr-cleaner' | ||
- '--label=org.opencontainers.image.revision={{ .FullCommit }}' | ||
- '--label=org.opencontainers.image.source={{ .GitURL }}' | ||
- '--label=org.opencontainers.image.title=gcr-cleaner' | ||
- '--label=org.opencontainers.image.version={{ .Version }}' | ||
|
||
docker_manifests: | ||
# cli | ||
- | ||
name_template: 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:{{ .Version }}' | ||
image_templates: | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:{{ .Version }}-amd64' | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:{{ .Version }}-arm64' | ||
- | ||
name_template: 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest' | ||
image_templates: | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest-amd64' | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest-arm64' | ||
- | ||
name_template: 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:{{ .Version }}' | ||
image_templates: | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:{{ .Version }}-amd64' | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:{{ .Version }}-arm64' | ||
- | ||
name_template: 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest' | ||
image_templates: | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest-amd64' | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest-arm64' | ||
- | ||
name_template: 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:{{ .Version }}' | ||
image_templates: | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:{{ .Version }}-amd64' | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:{{ .Version }}-arm64' | ||
- | ||
name_template: 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest' | ||
image_templates: | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest-amd64' | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest-arm64' | ||
|
||
# server | ||
- | ||
name_template: 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:{{ .Version }}' | ||
image_templates: | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:{{ .Version }}-amd64' | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:{{ .Version }}-arm64' | ||
- | ||
name_template: 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:latest' | ||
image_templates: | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:latest-amd64' | ||
- 'asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:latest-arm64' | ||
- | ||
name_template: 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:{{ .Version }}' | ||
image_templates: | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:{{ .Version }}-amd64' | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:{{ .Version }}-arm64' | ||
- | ||
name_template: 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:latest' | ||
image_templates: | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:latest-amd64' | ||
- 'europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:latest-arm64' | ||
- | ||
name_template: 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:{{ .Version }}' | ||
image_templates: | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:{{ .Version }}-amd64' | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:{{ .Version }}-arm64' | ||
- | ||
name_template: 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:latest' | ||
image_templates: | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:latest-amd64' | ||
- 'us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner:latest-arm64' | ||
|
||
archives: | ||
- format: 'tar.gz' | ||
name_template: 'gcr-cleaner_{{ .Version }}_{{ .Os }}_{{ .Arch }}' | ||
format_overrides: | ||
- goos: 'windows' | ||
format: 'zip' | ||
|
||
checksum: | ||
name_template: 'gcr-cleaner_{{ .Version }}_SHA512SUMS' | ||
algorithm: 'sha512' | ||
|
||
signs: | ||
- artifacts: 'checksum' | ||
args: | ||
- '--batch' | ||
- '--local-user' | ||
- '{{ .Env.GPG_FINGERPRINT }}' | ||
- '--output' | ||
- '${signature}' | ||
- '--detach-sign' | ||
- '${artifact}' | ||
|
||
release: | ||
draft: false |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.