Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(v7): only tag latest Docker images on default branch #301

Merged
merged 6 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ runs:
args: release --clean ${{ inputs.dry-run == 'true' && '--skip=publish' || '' }}
env:
GITHUB_TOKEN: ${{ inputs.token }}
NOT_DEFAULT_BRANCH: ${{ github.ref_name != github.event.repository.default_branch }}

- name: Upload Release Artifacts
shell: bash
Expand Down
72 changes: 59 additions & 13 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ dockers:
- image_templates:
- "launchdarkly/ld-relay:{{ .Version }}-i386"
Copy link
Contributor Author

@cwaldren-ld cwaldren-ld Feb 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this isn't exactly elegant.. but what I've done is just split out the latest tags from each instance of image_templates, into a new image_template block.

This is because we can only control the skip_push argument at the image_template level.

The idea is - for each architecture, build all the tags (we don't really have a choice here, unless we dynamically generate the config file), but only push the latest tag for the architecture if we're on the default branch (via skip_push config item).

Then in the manifest section starting on line 169, don't push the latest manifest unless we're on the default branch.

More yaml, but this should allow for us to have a safe switchover when we make a new major version and mark it as default.

- "launchdarkly/ld-relay:v{{ .Major }}-i386"
- "launchdarkly/ld-relay:latest-i386"
use: buildx
goos: linux
goarch: '386'
Expand All @@ -77,11 +76,22 @@ dockers:
- "--pull"
- "--platform=linux/386"

# i386 - latest tag
- image_templates:
- "launchdarkly/ld-relay:latest-i386"
use: buildx
goos: linux
goarch: '386'
dockerfile: Dockerfile.goreleaser
skip_push: "{{ .Env.NOT_DEFAULT_BRANCH }}"
build_flag_templates:
- "--pull"
- "--platform=linux/386"

# AMD64
- image_templates:
- "launchdarkly/ld-relay:{{ .Version }}-amd64"
- "launchdarkly/ld-relay:v{{ .Major }}-amd64"
- "launchdarkly/ld-relay:latest-amd64"
use: buildx
goos: linux
goarch: amd64
Expand All @@ -91,11 +101,22 @@ dockers:
- "--pull"
- "--platform=linux/amd64"

# AMD64 - latest tag
- image_templates:
- "launchdarkly/ld-relay:latest-amd64"
use: buildx
goos: linux
goarch: amd64
dockerfile: Dockerfile.goreleaser
skip_push: "{{ .Env.NOT_DEFAULT_BRANCH }}"
build_flag_templates:
- "--pull"
- "--platform=linux/amd64"

# ARMv7
- image_templates:
- "launchdarkly/ld-relay:{{ .Version }}-armv7"
- "launchdarkly/ld-relay:v{{ .Major }}-armv7"
- "launchdarkly/ld-relay:latest-armv7"
use: buildx
goos: linux
goarch: arm
Expand All @@ -106,11 +127,23 @@ dockers:
- "--pull"
- "--platform=linux/arm/v7"

# ARMv7 - latest tag
- image_templates:
- "launchdarkly/ld-relay:latest-armv7"
use: buildx
goos: linux
goarch: arm
goarm: 7
dockerfile: Dockerfile.goreleaser
skip_push: "{{ .Env.NOT_DEFAULT_BRANCH }}"
build_flag_templates:
- "--pull"
- "--platform=linux/arm/v7"

# ARM64v8
- image_templates:
- "launchdarkly/ld-relay:{{ .Version }}-arm64v8"
- "launchdarkly/ld-relay:v{{ .Major }}-arm64v8"
- "launchdarkly/ld-relay:latest-arm64v8"
use: buildx
goos: linux
goarch: arm64
Expand All @@ -119,6 +152,19 @@ dockers:
build_flag_templates:
- "--pull"
- "--platform=linux/arm64/v8"

# ARM64v8 - latest tag
- image_templates:
- "launchdarkly/ld-relay:latest-arm64v8"
use: buildx
goos: linux
goarch: arm64
dockerfile: Dockerfile.goreleaser
skip_push: "{{ .Env.NOT_DEFAULT_BRANCH }}"
build_flag_templates:
- "--pull"
- "--platform=linux/arm64/v8"

docker_manifests:
- name_template: "launchdarkly/ld-relay:{{ .Version}}"
skip_push: false
Expand All @@ -131,15 +177,15 @@ docker_manifests:
- name_template: "launchdarkly/ld-relay:v{{ .Major }}"
skip_push: false
image_templates:
- "launchdarkly/ld-relay:v{{ .Major }}-amd64"
- "launchdarkly/ld-relay:v{{ .Major }}-armv7"
- "launchdarkly/ld-relay:v{{ .Major }}-arm64v8"
- "launchdarkly/ld-relay:v{{ .Major }}-i386"
- "launchdarkly/ld-relay:v{{ .Major }}-amd64"
- "launchdarkly/ld-relay:v{{ .Major }}-armv7"
- "launchdarkly/ld-relay:v{{ .Major }}-arm64v8"
- "launchdarkly/ld-relay:v{{ .Major }}-i386"

- name_template: "launchdarkly/ld-relay:latest"
skip_push: false
skip_push: "{{ .Env.NOT_DEFAULT_BRANCH }}"
image_templates:
- "launchdarkly/ld-relay:latest-amd64"
- "launchdarkly/ld-relay:latest-armv7"
- "launchdarkly/ld-relay:latest-arm64v8"
- "launchdarkly/ld-relay:latest-i386"
- "launchdarkly/ld-relay:latest-amd64"
- "launchdarkly/ld-relay:latest-armv7"
- "launchdarkly/ld-relay:latest-arm64v8"
- "launchdarkly/ld-relay:latest-i386"
Loading