Skip to content

Commit

Permalink
Add Docker image to goreleaser (#31)
Browse files Browse the repository at this point in the history
* Add Docker image to goreleaser

* Set --build-arg flag

* Updated workflow
  • Loading branch information
applejag authored Apr 8, 2024
1 parent 68349bb commit 569aea4
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 14 deletions.
34 changes: 20 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,36 @@ on:

permissions:
contents: write
packages: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Fetch all tags
run: git fetch --force --tags
-
name: Set up Go
uses: actions/setup-go@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Docker login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41 changes: 41 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,54 @@
before:
hooks:
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64

dockers:
- image_templates:
- "ghcr.io/riskident/{{ .ProjectName }}:{{ .Version }}-amd64"
dockerfile: Dockerfile
use: buildx
goarch: arm64
goos: linux
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --build-arg=VERSION={{ .Version }}

- image_templates:
- "ghcr.io/riskident/{{ .ProjectName }}:{{ .Version }}-arm64v8"
dockerfile: Dockerfile
use: buildx
goarch: arm64
goos: linux
build_flag_templates:
- --platform=linux/arm64/v8
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --build-arg=VERSION={{ .Version }}

docker_manifests:
- name_template: "ghcr.io/riskident/{{ .ProjectName }}:{{ .Version }}"
image_templates:
- "ghcr.io/riskident/{{ .ProjectName }}:{{ .Version }}-amd64"
- "ghcr.io/riskident/{{ .ProjectName }}:{{ .Version }}-arm64v8"
- name_template: "ghcr.io/riskident/{{ .ProjectName }}:latest"
image_templates:
- "ghcr.io/riskident/{{ .ProjectName }}:{{ .Version }}-amd64"
- "ghcr.io/riskident/{{ .ProjectName }}:{{ .Version }}-arm64v8"

archives:
- format: tar.gz
Expand Down

0 comments on commit 569aea4

Please sign in to comment.