Skip to content

Commit

Permalink
Add goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
o1egl committed Mar 1, 2021
1 parent 544b8b5 commit 20f7a8b
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 37 deletions.
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These owners will be the default owners for everything in the repo.
# Unless a later match takes precedence, @o1egl will be requested for
# review when someone opens a pull request.

* @o1egl
36 changes: 0 additions & 36 deletions .github/workflows/ci-test.yaml

This file was deleted.

61 changes: 61 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: main

on:
push:
branches: [ master ]
tags: v*
pull_request:
branches:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.37.1
skip-go-installation: true
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Test
run: go test -race -timeout=60s -v -coverprofile=coverage.txt -covermode=atomic ./...
- uses: codecov/codecov-action@v1
with:
file: ./coverage.txt
release:
runs-on: ubuntu-latest
needs: [lint, test]
if: startsWith(github.event.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
build/
.idea
vendor
coverage.txt
coverage.txt
dist/
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM alpine:latest as alpine
RUN apk --update add ca-certificates
RUN apk --update add mailcap

FROM scratch
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=alpine /etc/mime.types /etc/mime.types

VOLUME /data

COPY govatar /govatar

ENTRYPOINT [ "/govatar" ]
71 changes: 71 additions & 0 deletions goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
project_name: govatar

before:
hooks:
- go mod download

build:
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X main.version={{ .Version }}
main: govatar/main.go
binary: govatar
goos:
- darwin
- linux
- windows
- freebsd
goarch:
- amd64
- 386
- arm
- arm64
goarm:
- 5
- 6
- 7
ignore:
- goos: darwin
goarch: 386
- goos: freebsd
goarch: arm

archives:
-
name_template: "{{.Os}}-{{.Arch}}{{if .Arm}}v{{.Arm}}{{end}}-{{ .ProjectName }}"
format: tar.gz
format_overrides:
- goos: windows
format: zip

dockers:
-
dockerfile: Dockerfile
goos: linux
goarch: amd64
goarm: ''
image_templates:
- "o1egl/govatar:latest"
- "o1egl/govatar:{{ .Tag }}"
- "o1egl/govatar:v{{ .Major }}"
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.authors=Oleg Lobanov"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"

brews:
- name: govatar
tap:
owner: o1egl
name: homebrew-tap
folder: Formula
homepage: https://github.com/o1egl/govatar
commit_author:
name: Oleg Lobanov
email: [email protected]
description: GOvatar is an avatar generation library written in GO
license: "MIT"

0 comments on commit 20f7a8b

Please sign in to comment.