47 lines
1.5 KiB
YAML
47 lines
1.5 KiB
YAML
version: '3'
|
|
|
|
vars:
|
|
BASE_DIR:
|
|
sh: dirname $(pwd)
|
|
PROJECT_NAME:
|
|
sh: pwd|sed "s#{{.BASE_DIR}}/##g"
|
|
GOOS: ''
|
|
GOARCH: ''
|
|
|
|
tasks:
|
|
default:
|
|
cmds:
|
|
- task: deps
|
|
- task: build:binary
|
|
silent: true
|
|
|
|
deps:
|
|
desc: Install all dependencies (except dredd requirements)
|
|
cmds:
|
|
- task: deps:be
|
|
- task: deps:tools
|
|
|
|
deps:be:
|
|
desc: application dependencies
|
|
cmds:
|
|
- go mod tidy
|
|
|
|
deps:tools:
|
|
desc: Installs tools needed for building
|
|
vars:
|
|
GORELEASER_VERSION: "1.19.2"
|
|
cmds:
|
|
- '{{ if ne OS "windows" }} sh -c "curl -L https://github.com/goreleaser/goreleaser/releases/download/v{{ .GORELEASER_VERSION }}/goreleaser_$(uname -s)_$(uname -m).tar.gz | tar -xz -C $(go env GOPATH)/bin goreleaser"{{ else }} {{ end }}'
|
|
- '{{ if ne OS "windows" }} chmod +x $(go env GOPATH)/bin/goreleaser{{ else }} {{ end }}'
|
|
- '{{ if eq OS "windows" }} echo "NOTICE: You must download goreleaser manually to build this application https://github.com/goreleaser/goreleaser/releases "{{ else }}:{{ end }}'
|
|
- '{{ if eq OS "windows" }} echo "NOTICE: You need to install golangci-lint manually to build this application https://github.com/golangci/golangci-lint#install"{{ else }}{{ end }}'
|
|
|
|
build:binary:
|
|
desc: Build a binary for the current architecture
|
|
platforms: [amd64]
|
|
cmds:
|
|
- env CGO_ENABLED=0 GOOS={{ .GOOS }} GOARCH={{ .GOARCH }} go build -o ./bin/{{.PROJECT_NAME}}{{ if eq OS "windows" }}.exe{{ end }}
|
|
|
|
release:prod:
|
|
cmds:
|
|
- goreleaser |