Skip to content

Commit b802fb9

Browse files
committed
ci(goreleaser): migrate to new docker v2 builder
1 parent aaead4a commit b802fb9

File tree

3 files changed

+25
-47
lines changed

3 files changed

+25
-47
lines changed

.github/workflows/build.yaml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,16 @@ jobs:
9191
- name: Push beta image
9292
if: github.ref_name == 'main'
9393
run: |
94-
export REPO="$(tr '[[:upper:]]' '[[:lower:]]' <<< "ghcr.io/gabe565/moreutils")"
94+
export REPO="$(tr '[[:upper:]]' '[[:lower:]]' <<< "ghcr.io/$GITHUB_REPOSITORY")"
9595
IMAGES=()
96-
while read -r SOURCE DEST; do
97-
docker tag "$SOURCE" "$DEST"
98-
docker push "$DEST"
99-
IMAGES+=("$DEST")
96+
while read -r IMAGE; do
97+
docker push "$IMAGE"
98+
IMAGES+=("$IMAGE")
10099
done \
101100
< <(docker image ls --format=json | \
102-
yq --input-format=json --output-format=tsv '
103-
select(.Repository == strenv(REPO)) |
104-
[
105-
.Repository + ":" + .Tag,
106-
.Repository + ":beta-" + (.Tag | sub(".*-", ""))
107-
]
101+
yq --input-format=json --no-doc '
102+
select(.Repository == strenv(REPO) and .Tag == "beta-*") |
103+
.Repository + ":" + .Tag
108104
')
109105
110106
docker manifest create "$REPO:beta" "${IMAGES[@]}"

.goreleaser.yaml

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -159,37 +159,19 @@ aurs:
159159
commit_author:
160160
name: goreleaserbot
161161
email: bot@goreleaser.com
162-
dockers:
163-
- &dockers
164-
image_templates:
165-
- ghcr.io/gabe565/moreutils:{{ .Version }}-amd64
166-
use: buildx
167-
dockerfile: goreleaser.Dockerfile
168-
build_flag_templates:
169-
- "--platform=linux/amd64"
170-
- <<: *dockers
171-
image_templates:
172-
- ghcr.io/gabe565/moreutils:{{ .Version }}-armv7
173-
goarch: arm
174-
goarm: 7
175-
build_flag_templates:
176-
- "--platform=linux/arm/v7"
177-
- <<: *dockers
178-
image_templates:
179-
- ghcr.io/gabe565/moreutils:{{ .Version }}-arm64v8
180-
goarch: arm64
181-
build_flag_templates:
182-
- "--platform=linux/arm64/v8"
183-
docker_manifests:
184-
- &docker_manifests
185-
name_template: ghcr.io/gabe565/moreutils:latest
186-
image_templates:
187-
- ghcr.io/gabe565/moreutils:{{ .Version }}-amd64
188-
- ghcr.io/gabe565/moreutils:{{ .Version }}-armv7
189-
- ghcr.io/gabe565/moreutils:{{ .Version }}-arm64v8
190-
- <<: *docker_manifests
191-
name_template: ghcr.io/gabe565/moreutils:{{ .Version }}
192-
- <<: *docker_manifests
193-
name_template: ghcr.io/gabe565/moreutils:{{ .Major }}
194-
- <<: *docker_manifests
195-
name_template: ghcr.io/gabe565/moreutils:{{ .Major }}.{{ .Minor }}
162+
dockers_v2:
163+
- dockerfile: goreleaser.Dockerfile
164+
images:
165+
- ghcr.io/gabe565/{{ .ProjectName }}
166+
tags:
167+
- "{{ if not .IsSnapshot }}{{ .Version }}{{ end }}"
168+
- "{{ if not .IsSnapshot }}{{ .Major }}.{{ .Minor }}{{ end }}"
169+
- "{{ if not .IsSnapshot }}{{ .Major }}{{ end }}"
170+
- "{{ if not .IsSnapshot }}latest{{ else }}beta{{ end }}"
171+
labels:
172+
org.opencontainers.image.description: "Go rewrite of the moreutils command-line tools."
173+
org.opencontainers.image.created: "{{ .Date }}"
174+
org.opencontainers.image.name: "{{ .ProjectName }}"
175+
org.opencontainers.image.revision: "{{ .FullCommit }}"
176+
org.opencontainers.image.version: "{{ .Version }}"
177+
org.opencontainers.image.source: "{{ .GitURL }}"

goreleaser.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
FROM alpine AS source
22
WORKDIR /app
3-
COPY moreutils .
3+
ARG TARGETPLATFORM
4+
COPY $TARGETPLATFORM/moreutils .
45
RUN ./moreutils install .
56

67
FROM alpine
78
WORKDIR /data
8-
LABEL org.opencontainers.image.source="https://github.com/gabe565/moreutils-go"
99
COPY --from=source /app /usr/bin
1010
ENTRYPOINT ["moreutils"]

0 commit comments

Comments
 (0)