-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTaskfile.yml
110 lines (103 loc) · 3.57 KB
/
Taskfile.yml
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
108
109
110
# See https://taskfile.dev for more information.
# Based on https://github.com/marco-m/timeit/blob/master/Taskfile.yml
version: '3'
tasks:
default:
deps: [test]
clean:
desc: Delete build artifacts
cmds: [rm -rf bin/*]
terravalet:
desc: Build the terravalet executable
dir: bin
cmds:
- go build -v -ldflags="{{.LDFLAGS}}" ..
vars: &build-vars
FULL_VERSION:
sh: git describe --long --dirty --always
SHORT_VERSION:
sh: git describe --abbrev=0
LDFLAGS: -w -s -X main.fullVersion={{.FULL_VERSION}} -X main.shortVersion={{.SHORT_VERSION}}
test:
desc: Run the integration tests
deps: [terravalet]
cmds:
- "{{.TESTRUNNER}} ./..."
vars:
GOTESTSUM:
sh: which gotestsum 2> /dev/null; true
TESTRUNNER: "{{if .GOTESTSUM}}{{.GOTESTSUM}}{{else}}go test{{end}}"
#
# usage: env RELEASE_TAG=v0.1.0 gopass task release
#
release:
desc: Build a release and upload to GitHub as draft. You need to transition
from draft to published in the web UI.
preconditions:
- sh: test -n "$RELEASE_TAG"
msg: "error: missing environment variable RELEASE_TAG"
- sh: test -z $(git status --porcelain)
msg: "error: git dirty"
- sh: test -z $(git status --branch --porcelain | grep ahead)
msg: "error: git local branch ahead"
cmds:
# - task: unit-test
# We create the (local) git tag now, after having ran the unit tests and
# before building the executables, so that we can embed this information
# in the binaries.
# To recover: delete local tag: git tag --delete tagname
- git tag -a {{.RELEASE_TAG}} -m ''
- task: release-linux
- task: release-darwin
# - task: system-test
- task: test
# We create the release as a draft (that is: not visible to the public).
# The act of "publishing" the release is left to a human from the web UI.
- >
github-release release
--tag {{.RELEASE_TAG}}
--draft
--description
"See the [CHANGELOG](https://github.com/$GITHUB_USER/$GITHUB_REPO/blob/{{.RELEASE_TAG}}/CHANGELOG.md)"
# Upload the artifacts.
- >
github-release upload
--tag {{.RELEASE_TAG}}
--name terravalet-linux-amd64.zip
--file bin/linux/terravalet-linux-amd64.zip
- >
github-release upload
--tag {{.RELEASE_TAG}}
--name terravalet-darwin-amd64.zip
--file bin/darwin/terravalet-darwin-amd64.zip
# We don't push the git tag. Instead, in the web UI, the act of
# transitioning the release from draft to published will create the
# corresponding tag in the remote repository. This is safer, because it
# reduces the situations when one might be tempted to delete a public tag
# due to a mistake in the release.
- cmd: |
echo "Draft release $RELEASE_TAG created successfully."
echo "Remember to publish it in the GitHub web UI https://github.com/$GITHUB_USER/$GITHUB_REPO/releases"
silent: true
env:
GITHUB_USER: pix4d
GITHUB_REPO: terravalet
# GITHUB_TOKEN expected to be set securely via `gopass` or equivalent
release-linux:
dir: bin/linux
cmds: &release-cmds
- go build -v -ldflags="{{.LDFLAGS}}" ../..
- zip terravalet-$GOOS-$GOARCH.zip terravalet
env:
CGO_ENABLED: 0
GOOS: linux
GOARCH: amd64
vars: *build-vars
release-darwin:
dir: bin/darwin
cmds: *release-cmds
env:
CGO_ENABLED: 0
GOOS: darwin
GOARCH: amd64
vars: *build-vars