Skip to content

Commit

Permalink
Add goreleaser and release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
burkaydurdu committed Mar 5, 2022
1 parent c047962 commit 7517948
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
README.md
README.md
.git
.idea
dist/
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: GoReleaser

on:
push:
tags:
- '*'

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Docker Login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
.mem/*.json
unit_coverage.out
shortly
shortly
dist/
44 changes: 44 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
builds:
- env: [CGO_ENABLED=0]
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
dockers:
- image_templates: ["ghcr.io/burkaydurdu/{{ .ProjectName }}:{{ .Version }}-amd64"]
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/burkaydurdu/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/burkaydurdu/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
- image_templates: ["ghcr.io/burkaydurdu/{{ .ProjectName }}:{{ .Version }}-arm64v8"]
goarch: arm64
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- --platform=linux/arm64/v8
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/burkaydurdu/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/burkaydurdu/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
docker_manifests:
- name_template: ghcr.io/burkaydurdu/{{ .ProjectName }}:{{ .Version }}
image_templates:
- ghcr.io/burkaydurdu/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/burkaydurdu/{{ .ProjectName }}:{{ .Version }}-arm64v8
- name_template: ghcr.io/burkaydurdu/{{ .ProjectName }}:latest
image_templates:
- ghcr.io/burkaydurdu/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/burkaydurdu/{{ .ProjectName }}:{{ .Version }}-arm64v8
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
FROM golang:1.17.2-alpine as builder
WORKDIR /go/src/app
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
#FROM golang:1.17.2-alpine as builder
#WORKDIR /go/src/app
#COPY . .
#RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
#
#FROM scratch
#COPY --from=builder /go/src/app/app /app
#ENTRYPOINT ["/app"]

FROM scratch
COPY --from=builder /go/src/app/app /app
COPY shortly /app
ENTRYPOINT ["/app"]

0 comments on commit 7517948

Please sign in to comment.