Skip to content

Commit

Permalink
feat: add release workflow (#2)
Browse files Browse the repository at this point in the history
* feat: add release workflow

Co-authored-by: Lukas <[email protected]>
  • Loading branch information
anbraten and lukashass authored May 21, 2021
1 parent 055d68b commit fc1b2ca
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 4 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: Release

on:
push:
tags:
- "*"

jobs:
goreleaser:
runs-on: ubuntu-latest
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 DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload assets
uses: actions/upload-artifact@v2
with:
name: lassie-bot-dog
path: dist/*
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

lassie-bot-dog
*~

dist/

.env
node_modules
58 changes: 58 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
project_name: lassie-bot-dog

before:
hooks:
- go mod tidy
builds:
-
flags:
- -trimpath
goos:
- darwin
- linux
- freebsd
goarch:
- amd64
- arm64
- ppc64le
- s390x
env:
- CGO_ENABLED=0
archives:
-
format_overrides:
- goos: windows
format: zip
files:
- README.md
- LICENSE

checksum:
name_template: 'checksums.txt'
snapshot:
name_template: 'snapshot-{{ time "2006-01-02" }}'
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
nfpms:
-
description: Lassie is a Gitlab bot which helps you with houskeeping
license: MIT License
formats:
- deb
- rpm
dockers:
-
# GOOS of the built binary that should be used.
goos: linux
# GOARCH of the built binary that should be used.
goarch: amd64
dockerfile: Dockerfile
image_templates:
- "geprog/lassie-bot-dog:{{ .Tag }}"
- "geprog/lassie-bot-dog:latest"
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM golang:1.16

FROM scratch

# Copy CA certificates to prevent x509: certificate signed by unknown authority errors
COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt

COPY lassie-bot-dog /lassie-bot-dog

ENTRYPOINT ["/lassie-bot-dog"]
5 changes: 1 addition & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ func loop(client *gitlab.Client) {
}

func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
godotenv.Load()

GITLAB_URL := os.Getenv("GITLAB_URL")
GITLAB_TOKEN := os.Getenv("GITLAB_TOKEN")
Expand Down

0 comments on commit fc1b2ca

Please sign in to comment.