Skip to content

Commit fda39f0

Browse files
authored
Merge pull request #91 from caian-org/chore/harmonize-baseline
chore: harmonize with caian-org baseline
2 parents f9dcd67 + ac04d91 commit fda39f0

5 files changed

Lines changed: 41 additions & 49 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
- name: Upload coverage
3636
if: always()
37-
uses: actions/upload-artifact@v6
37+
uses: actions/upload-artifact@v7
3838
with:
3939
name: coverage
4040
path: coverage.out
@@ -54,6 +54,6 @@ jobs:
5454
cache: true
5555

5656
- name: golangci-lint
57-
uses: golangci/golangci-lint-action@v8
57+
uses: golangci/golangci-lint-action@v9
5858
with:
5959
version: latest

.github/workflows/release.yml

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ permissions:
1111
jobs:
1212
goreleaser:
1313
runs-on: ubuntu-latest
14+
env:
15+
REGISTRY: ghcr.io
16+
IMAGE_NAME: ${{ github.repository }}
1417
steps:
1518
- name: Checkout
1619
uses: actions/checkout@v6
@@ -22,20 +25,41 @@ jobs:
2225
with:
2326
go-version-file: go.mod
2427

25-
- name: Setup Docker Buildx
28+
- name: Run GoReleaser
29+
uses: goreleaser/goreleaser-action@v7
30+
with:
31+
version: '~> v2'
32+
args: release --clean
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Set up QEMU
37+
uses: docker/setup-qemu-action@v4
38+
39+
- name: Set up Docker Buildx
2640
uses: docker/setup-buildx-action@v4
2741

28-
- name: Login to GHCR
42+
- name: Log in to GitHub Container Registry
2943
uses: docker/login-action@v4
3044
with:
31-
registry: ghcr.io
45+
registry: ${{ env.REGISTRY }}
3246
username: ${{ github.actor }}
3347
password: ${{ secrets.GITHUB_TOKEN }}
3448

35-
- name: Run GoReleaser
36-
uses: goreleaser/goreleaser-action@v7
49+
- name: Extract Docker metadata
50+
id: meta
51+
uses: docker/metadata-action@v6
3752
with:
38-
version: '~> v2'
39-
args: release --clean
40-
env:
41-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
54+
tags: |
55+
type=ref,event=tag
56+
type=raw,value=latest
57+
58+
- name: Build and push Docker image
59+
uses: docker/build-push-action@v7
60+
with:
61+
context: .
62+
platforms: linux/amd64,linux/arm64
63+
push: true
64+
tags: ${{ steps.meta.outputs.tags }}
65+
labels: ${{ steps.meta.outputs.labels }}

.goreleaser.yaml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,6 @@ archives:
3636
- README.md
3737
- LICENSE*
3838

39-
dockers_v2:
40-
- id: lgs
41-
ids:
42-
- lgs
43-
dockerfile: Dockerfile
44-
images:
45-
- ghcr.io/caian-org/list-github-stars
46-
tags:
47-
- '{{ .Tag }}'
48-
- latest
49-
platforms:
50-
- linux/amd64
51-
flags:
52-
- --target=goreleaser-runtime
53-
labels:
54-
org.opencontainers.image.title: list-github-stars
55-
org.opencontainers.image.description: List a GitHub user's starred repositories as Markdown
56-
org.opencontainers.image.source: https://github.com/caian-org/list-github-stars
57-
org.opencontainers.image.revision: '{{ .FullCommit }}'
58-
org.opencontainers.image.version: '{{ .Version }}'
59-
6039
checksum:
6140
name_template: 'checksums.txt'
6241
algorithm: sha256

.tool-versions

Lines changed: 0 additions & 2 deletions
This file was deleted.

Dockerfile

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
# syntax=docker/dockerfile:1
22
ARG GO_VERSION=1.26.2
33

4-
# Build stage shared by the local-runtime target. Goreleaser bypasses this and
5-
# uses the pre-built binary from its own build context (see the
6-
# goreleaser-runtime stage below).
7-
FROM golang:${GO_VERSION}-bookworm AS build
4+
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-bookworm AS build
5+
ARG TARGETOS
6+
ARG TARGETARCH
87
WORKDIR /src
9-
COPY go.* ./
8+
COPY go.mod go.sum ./
109
RUN go mod download
1110
COPY . .
12-
RUN CGO_ENABLED=0 go build -ldflags='-s -w' -o /out/lgs ./cmd/lgs
11+
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
12+
go build -ldflags='-s -w' -o /out/lgs ./cmd/lgs
1313

14-
15-
# `docker build .` (no --target) builds from source. Handy for development.
1614
FROM gcr.io/distroless/static-debian12 AS local-runtime
1715
COPY --from=build /out/lgs /usr/local/bin/lgs
1816
ENTRYPOINT ["/usr/local/bin/lgs"]
19-
20-
21-
# Used by goreleaser's dockers_v2 step at release time. The build context
22-
# already contains linux/amd64/lgs (the binary goreleaser cross-built).
23-
FROM gcr.io/distroless/static-debian12 AS goreleaser-runtime
24-
COPY linux/amd64/lgs /usr/local/bin/lgs
25-
ENTRYPOINT ["/usr/local/bin/lgs"]

0 commit comments

Comments
 (0)