-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathTaskfile.cli.yml
More file actions
executable file
·148 lines (127 loc) · 4.37 KB
/
Taskfile.cli.yml
File metadata and controls
executable file
·148 lines (127 loc) · 4.37 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
version: '3'
tasks:
all:
desc: Run deps, test, vet, fmt, lint, install
cmds:
- task: deps
- task: test
- task: vet
- task: fmt
- task: lint
- task: install
deps:
desc: Install dependencies
cmds:
- go install github.com/mgechev/revive@v1.3.3
- go mod tidy
test:
desc: Run tests
cmds:
- go test ./...
test:int:
desc: Run integration tests
cmds:
- go test -tags=int_test ./...
vet:
desc: Run go vet
cmds:
- go vet ./...
fmt:
desc: Format code
cmds:
- gofmt -l -w .
lint:
desc: Run linter
cmds:
- revive -config revive.toml -formatter friendly ./...
build:
desc: Build the binary
vars:
GIT_COMMIT:
sh: git rev-parse HEAD
GIT_COMMIT_DATE:
sh: git log -1 --date=format:'%Y-%m-%dT%H:%M:%S' --format=%cd
GIT_VERSION:
sh: git describe --tags 2>/dev/null || echo "{{.GIT_COMMIT}}"
LD_FLAGS: "-s -w -X main.appVersion={{.GIT_VERSION}} -X main.appCommit={{.GIT_COMMIT}} -X main.appCommitDate={{.GIT_COMMIT_DATE}}"
TAGS: timetzdata
cmds:
- go build -tags "{{.TAGS}}" --ldflags "{{.LD_FLAGS}}" -o bin/aem ./cmd/aem
build:other:
desc: Build binaries for other platforms
vars:
GIT_COMMIT:
sh: git rev-parse HEAD
GIT_COMMIT_DATE:
sh: git log -1 --date=format:'%Y-%m-%dT%H:%M:%S' --format=%cd
GIT_VERSION:
sh: git describe --tags 2>/dev/null || echo "{{.GIT_COMMIT}}"
LD_FLAGS: "-s -w -X main.appVersion={{.GIT_VERSION}} -X main.appCommit={{.GIT_COMMIT}} -X main.appCommitDate={{.GIT_COMMIT_DATE}}"
TAGS: timetzdata
cmds:
- GOARCH=amd64 GOOS=darwin go build -tags "{{.TAGS}}" --ldflags "{{.LD_FLAGS}}" -o bin/aem.darwin ./cmd/aem
- GOARCH=amd64 GOOS=linux go build -tags "{{.TAGS}}" --ldflags "{{.LD_FLAGS}}" -o bin/aem.linux ./cmd/aem
- GOARCH=amd64 GOOS=windows go build -tags "{{.TAGS}}" --ldflags "{{.LD_FLAGS}}" -o bin/aem.exe ./cmd/aem
install:
desc: Install the binary
vars:
GIT_COMMIT:
sh: git rev-parse HEAD
GIT_COMMIT_DATE:
sh: git log -1 --date=format:'%Y-%m-%dT%H:%M:%S' --format=%cd
GIT_VERSION:
sh: git describe --tags 2>/dev/null || echo "{{.GIT_COMMIT}}"
LD_FLAGS: "-s -w -X main.appVersion={{.GIT_VERSION}} -X main.appCommit={{.GIT_COMMIT}} -X main.appCommitDate={{.GIT_COMMIT_DATE}}"
TAGS: timetzdata
cmds:
- go install -tags "{{.TAGS}}" --ldflags "{{.LD_FLAGS}}" ./cmd/aem
clean:
desc: Clean build artifacts
cmds:
- go clean
- rm -fr bin
release:
desc: Release a new version
vars:
VERSION: ""
cmds:
- |
set -e
VERSION="{{.CLI_ARGS | default ""}}"
VERSION_TAG="v$VERSION"
VERSION_CURRENT_TAG=$(git describe --tags --abbrev=0 || echo "v0.0.0")
VERSION_CURRENT_TAG="${VERSION_CURRENT_TAG#v}" # remove leading 'v', preserve leading zeros
if [ -z "$VERSION" ]; then
echo "Release version is not specified!"
echo "Last released: ${VERSION_CURRENT_TAG}"
exit 1
fi
GIT_STAT=$(git diff --stat || true)
if [ "$GIT_STAT" != '' ]; then
echo "Unable to release. Uncommitted changes detected!"
exit 1
fi
echo ""
echo "Releasing $VERSION_TAG"
echo ""
echo "Bumping version in files"
bump_version() {
local file="$1"
if [ "$(uname)" = "Darwin" ]; then
sed -i '' 's/AEM_CLI_VERSION:-"[^\"]*"/AEM_CLI_VERSION:-"'"$VERSION"'"/g' "$file"
# shellcheck disable=SC2016
sed -i '' 's/aem\@v[^\`]*\`/aem@v'"$VERSION"\`'/g' "$file"
else
sed -i 's/AEM_CLI_VERSION:-"[^\"]*"/AEM_CLI_VERSION:-"'"$VERSION"'"/g' "$file"
# shellcheck disable=SC2016
sed -i 's/aem\@v[^\`]*\`/aem@v'"$VERSION"\`'/g' "$file"
fi
}
bump_version "README.MD"
bump_version "pkg/project/common/aemw"
echo "Pushing version bump"
git commit -a -m "Release $VERSION_TAG" || echo "No changes to commit"
git push || echo "Nothing to push"
echo "Pushing release tag '$VERSION_TAG'"
git tag "$VERSION_TAG"
git push origin "$VERSION_TAG" || echo "Tag already exists or cannot push"