Skip to content

Commit

Permalink
release with github actions (and arm builds)
Browse files Browse the repository at this point in the history
  • Loading branch information
fopina committed Dec 11, 2022
1 parent 2f1167e commit d00f776
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: goreleaser

on:
push:
branches-ignore:
- '**'
tags:
- '*.*.*'
- '*.*.*'

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v3
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
smtp_to_telegram
dist
57 changes: 57 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
project_name: smtp_to_telegram

release:
prerelease: auto

builds:
- id: smtp_to_telegram
env:
- CGO_ENABLED=0
goos:
- windows
- darwin
- linux
goarch:
- amd64
- arm64
- arm
goarm:
- '7'
ldflags:
- -s -w -X main.Version={{.Version}}

snapshot:
name_template: "{{ .Tag }}-next"

dockers:
- &xdocker
image_templates:
- kostyaesmukov/{{ .ProjectName }}:{{ .Version }}-amd64
dockerfile: Dockerfile.release
use: buildx
goos: linux
goarch: amd64
build_flag_templates:
- --platform=linux/amd64

- <<: *xdocker
image_templates:
- kostyaesmukov/{{ .ProjectName }}:{{ .Version }}-arm64
goarch: arm64
build_flag_templates:
- --platform=linux/arm64/v8

- <<: *xdocker
image_templates:
- kostyaesmukov/{{ .ProjectName }}:{{ .Version }}-armv7
goarch: arm
goarm: 7
build_flag_templates:
- --platform=linux/arm/v7

docker_manifests:
- name_template: kostyaesmukov/{{ .ProjectName }}:latest
image_templates:
- kostyaesmukov/{{ .ProjectName }}:{{ .Version }}-amd64
- kostyaesmukov/{{ .ProjectName }}:{{ .Version }}-arm64
- kostyaesmukov/{{ .ProjectName }}:{{ .Version }}-armv7
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ RUN apk add --no-cache git ca-certificates mailcap

WORKDIR /app

COPY go.mod .
COPY go.sum .

RUN go mod download

COPY . .

# The image should be built with
Expand Down
12 changes: 12 additions & 0 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM alpine:3.16

RUN apk add --no-cache ca-certificates mailcap

COPY smtp_to_telegram /smtp_to_telegram

USER daemon

ENV ST_SMTP_LISTEN="0.0.0.0:2525"
EXPOSE 2525

ENTRYPOINT ["/smtp_to_telegram"]
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
GOLANG_CROSS_VERSION ?= v1.18.1

test-release:
@docker run \
--rm \
--privileged \
-v ${PWD}:/smtp_to_telegram \
-w /smtp_to_telegram \
-e GITHUB_TOKEN \
-e DOCKER_USERNAME \
-e DOCKER_PASSWORD \
-e DOCKER_REGISTRY \
-v /var/run/docker.sock:/var/run/docker.sock \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--rm-dist --skip-validate --timeout=1h --snapshot

0 comments on commit d00f776

Please sign in to comment.