-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Taskfile.dist.yaml
107 lines (93 loc) · 2.6 KB
/
Taskfile.dist.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# This file can be run with the `task` utility: https://taskfile.dev/
version: '3'
dotenv: ['.env', '.env.local']
vars:
APP_VERSION_FILE: './lib/version/app-version.go'
BUILD_OUTPUT_DIR: './dist'
DIST_TARGET_FILE: '{{.BUILD_OUTPUT_DIR}}/stackup'
ENTRY_FILENAME: './app/main.go'
tasks:
mod:
desc: Downloads and tidy Go modules
cmds:
- go mod download
- go mod tidy
test:
desc: Runs tests
cmds:
- go test -cover ./lib/**
build:
desc: Builds application
preconditions:
- task: prepare-dist-folder
- task: mod
deps:
- task: update-version-file
cmds:
- task: build-stackup
- task: copy-config-files-to-dist
clean:
desc: Cleans up build artifacts
preconditions:
- test -d {{.BUILD_OUTPUT_DIR}}
- test -f {{.DIST_TARGET_FILE}}
cmds:
- rm -f {{.DIST_TARGET_FILE}}
lint:
dir: .
preconditions:
- which golangci-lint
- test -f .golangci.yaml
- which dotenv-linter
- which typos
- which actionlint
- which shellcheck
cmds:
- golangci-lint run
- dotenv-linter --quiet --not-check-updates --recursive --exclude dist/.env
- actionlint
- shellcheck ./.custom-hooks/*
- typos
update-version-file:
cmds:
- go run tools/generate-version-file.go
prepare-dist-folder:
desc: Prepares dist folder
silent: true
cmds:
- mkdir -p {{.BUILD_OUTPUT_DIR}}
build-stackup:
desc: Builds stackup binary
vars:
GIT_COMMIT:
sh: git log -n 1 --format=%h
deps:
- task: prepare-dist-folder
sources:
- '{{.ENTRY_FILENAME}}'
- ./lib/**/*.go
- ./lib/*.go
generates:
- '{{.DIST_TARGET_FILE}}'
cmds:
- go build -trimpath -ldflags="-s -w -X main.Version={{.VERSION}}-{{.GIT_COMMIT}}" -o {{.DIST_TARGET_FILE}} {{.ENTRY_FILENAME}}
copy-config-files-to-dist:
desc: Copies config template to dist folder
deps:
- task: prepare-dist-folder
cmds:
- cp -f ./templates/*.yaml {{.BUILD_OUTPUT_DIR}}
- cp -f ./.env {{.BUILD_OUTPUT_DIR}}
update-checksums:
dir: templates/remote-includes
cmds:
- sha256sum *.yaml > checksums.sha256.txt
- git add checksums.sha256.txt
- git commit -m "update checksum files"
autobuild:
interactive: true
desc: Watches for changes and automatically rebuilds the project binary, displays a minimal system notification on start/finish
preconditions:
- which watchexec
cmds:
- watchexec --exts go --fs-events create,modify,remove -N --debounce 300 -w ./lib -- task build -f