Skip to content

Commit

Permalink
Chore: switch to goreleaser for building
Browse files Browse the repository at this point in the history
  • Loading branch information
till committed Dec 26, 2022
1 parent 56ccff5 commit 696021a
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 17 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ jobs:
fi
- name: Build
run: go build -v -o larry-build ./cmd/larry/.
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: build --single-target --snapshot --rm-dist

- name: Run golangci-lint
uses: golangci/[email protected]
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ jobs:
- name: Install dependencies
run: |
go mod download
- name: Lint build config
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: check
- name: Run Unit tests
run: |
go test -race -covermode atomic -coverprofile=covprofile ./...
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ coverage.out
.env
.envrc
larry-build

dist/
26 changes: 26 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
before:
hooks:
- go mod tidy
builds:
- id: larry
main: ./cmd/larry/main.go
env:
- CGO_ENABLED=0
goos:
- darwin
- freebsd
- linux
- windows
goarch:
- "amd64"
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
18 changes: 5 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## build: build the application and place the built app in the bin folder
## build: build the application (for current GOOS/GOARCH) and place the built app in the dist folder
build:
go build -o bin/larry ./cmd/larry/.
goreleaser build --single-target --snapshot --rm-dist

## start: start container
start:
Expand All @@ -14,22 +14,14 @@ run-dev:
test:
go test -v ./... --cover

## compile: compiles the application for multiple environments and place the output executables under the bin folder
## compile: compiles the application for multiple environments and place the output under the dist folder
compile:
# 64-Bit
# FreeBDS
GOOS=freebsd GOARCH=amd64 go build -ldflags="-s -w" -o ./bin/larry-freebsd-64 ./cmd/larry/.
# MacOS
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o ./bin/larry-macos-64 ./cmd/larry/.
# Linux
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ./bin/larry-linux-64 ./cmd/larry/.
# Windows
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o ./bin/larry-windows-64 ./cmd/larry/.
goreleaser release --snapshot --rm-dist

lint:
docker run --rm -v $(CURDIR):/app -w /app golangci/golangci-lint:v1.46.2 golangci-lint run

## help: prints this help message
help:
@echo "Usage: \n"
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
10 changes: 7 additions & 3 deletions cmd/larry/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@ var (
mastodonAccessToken = envString("MASTODON_ACCESS_TOKEN", "")
mastodonAccount = envString("MASTODON_ACCOUNT", "")
mastodonPassword = envString("MASTODON_PASSWORD", "")

// injected via build/goreleaser
version = ""
)

func main() {
cfg := config.Config{}

app := &cli.App{
Name: "Larry",
Usage: "Bot that publishes information from providers to different publishers",
Flags: larry.GetFlags(&cfg),
Name: "Larry",
Version: version,
Usage: "Bot that publishes information from providers to different publishers",
Flags: larry.GetFlags(&cfg),
Authors: []*cli.Author{
{Name: "@ezeoleaf", Email: "[email protected]"},
{Name: "@beesaferoot", Email: "[email protected]"},
Expand Down

0 comments on commit 696021a

Please sign in to comment.