-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yaml
61 lines (54 loc) · 2.25 KB
/
Taskfile.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
---
version: "3"
# Task: https://taskfile.dev/#/
vars:
PROJECT: "go-ginrest"
ENVIRONMENT: "Development"
VERSION: "1.0.1"
GIT_COMMIT:
#sh: if [ -d ".git" ]; then $(git rev-parse --verify HEAD | cut -b 1-8); else echo -n 'none'; fi
sh: if [ -d ".git" ]; then git log -n 1 --format=%h; else echo -n 'none'; fi
DATE_UTC:
sh: date -u
tasks:
# task run
run:
desc: Run the {{.PROJECT}} application
env:
Project: "{{.PROJECT}}"
Environment: "{{.ENVIRONMENT}}"
Version: "{{.VERSION}}"
GitHash: "{{.GIT_COMMIT}}"
DateTime: "{{.DATE_UTC}}"
cmds:
- echo "[Run]"
- echo "----------------------------------------"
- echo "Project, $Project"
- echo "Environment, $Environment"
- echo "Version, $Version"
- echo "GitHash, $GitHash"
- echo "Time, $DateTime"
- echo "----------------------------------------"
- GOFLAGS=-mod=mod go run -ldflags "-X 'main.environment={{.ENVIRONMENT}}' -X 'main.version={{.VERSION}}' -X 'main.githash={{.GIT_COMMIT}}' -X 'main.datetime={{.DATE_UTC}}'" .
silent: true
# task build
build:
desc: Build the {{.PROJECT}} application
cmds:
- GOFLAGS=-mod=mod go build -o 'bin/{{.PROJECT}}' -ldflags "-X 'main.environment={{.ENVIRONMENT}}' -X 'main.version={{.VERSION}}' -X 'main.githash={{.GIT_COMMIT}}' -X 'main.datetime={{.DATE_UTC}}'"
requires:
vars: [PROJECT, VERSION, GIT_COMMIT, DATE_UTC]
# task build-darwin
build-darwin:
desc: Build the {{.PROJECT}} application for darwin/amd64
cmds:
- GOFLAGS=-mod=mod GOOS=darwin GOARCH=amd64 go build -o 'bin/darwin/amd64/{{.PROJECT}}' -ldflags="-s -w -X 'main.environment={{.ENVIRONMENT}}' -X 'main.version={{.VERSION}}' -X 'main.githash={{.GIT_COMMIT}}' -X 'main.datetime={{.DATE_UTC}}'"
requires:
vars: [PROJECT, VERSION, GIT_COMMIT, DATE_UTC]
# task build-linux
build-linux:
desc: Build the {{.PROJECT}} application for linux/amd64
cmds:
- GOFLAGS=-mod=mod GOOS=linux GOARCH=amd64 go build -o 'bin/linux/amd64/{{.PROJECT}}' -ldflags="-s -w -X 'main.environment={{.ENVIRONMENT}}' -X 'main.version={{.VERSION}}' -X 'main.githash={{.GIT_COMMIT}}' -X 'main.datetime={{.DATE_UTC}}'"
requires:
vars: [PROJECT, VERSION, GIT_COMMIT, DATE_UTC]