Skip to content

Commit 3c0fefe

Browse files
authored
enhance the taskfile (#745)
1 parent 64742a0 commit 3c0fefe

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

Taskfile.yml

+26-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: "3"
22

33
tasks:
44
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml
@@ -30,17 +30,14 @@ tasks:
3030
desc: Build the project, to use a specific version use `task build TAG_VERSION=x.x.x`
3131
dir: "{{.DEFAULT_GO_MODULE_PATH}}"
3232
cmds:
33-
- go build -v -i {{default "" .ADDITIONAL_FLAGS}} -o {{default "arduino-create-agent" .APP_NAME}} -ldflags '-X main.version={{default .TAG_TEST .TAG_VERSION}} -X main.commit={{.COMMIT}} {{default "" .WIN_FLAGS}}'
34-
vars:
35-
COMMIT:
36-
sh: git log -n 1 --format=%h
33+
- go build -v {{.ADDITIONAL_FLAGS}} -o {{.PROJECT_NAME}} {{.LDFLAGS}} {{.WIN_FLAGS}}'
3734

3835
go:build-cli:
3936
desc: Build the project without tray icon support
4037
cmds:
4138
- task: go:build
4239
vars:
43-
APP_NAME: arduino-create-agent_cli
40+
PROJECT_NAME: arduino-create-agent_cli
4441
ADDITIONAL_FLAGS: -tags cli
4542

4643
go:build-win:
@@ -49,16 +46,19 @@ tasks:
4946
- rsrc -arch {{.GOARCH}} -manifest manifest.xml # GOARCH shoud be either amd64 or 386
5047
- task: go:build
5148
vars:
52-
APP_NAME: arduino-create-agent.exe
49+
PROJECT_NAME: arduino-create-agent.exe
5350
WIN_FLAGS: -H=windowsgui
5451
- rm *.syso # rm file to avoid compilation problems on other platforms
52+
vars:
53+
GOARCH:
54+
sh: go env GOARCH
5555

5656
go:build-win-cli:
57-
desc: Build the project fow win without tray icon support
57+
desc: Build the project for win without tray icon support
5858
cmds:
5959
- task: go:build
6060
vars:
61-
APP_NAME: arduino-create-agent_cli.exe
61+
PROJECT_NAME: arduino-create-agent_cli.exe
6262
ADDITIONAL_FLAGS: -tags cli
6363

6464
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-task/Taskfile.yml
@@ -137,17 +137,27 @@ tasks:
137137
cmds:
138138
- task: go:vet
139139
- task: go:lint
140-
- task: python:lint
141-
- task: protoc:check
142140

143141

144142
vars:
143+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/release-go-task/Taskfile.yml
144+
PROJECT_NAME: arduino-create-agent
145+
# build vars
146+
COMMIT:
147+
sh: echo "$(git log --no-show-signature -n 1 --format=%h)"
148+
TIMESTAMP_SHORT:
149+
sh: echo "{{now | date "20060102"}}"
150+
TAG:
151+
sh: echo "$(git tag --points-at=HEAD 2> /dev/null | head -n1)"
145152
TAG_TEST: "0.0.0-dev"
146-
GOARCH:
147-
sh: go env GOARCH
148-
# all modules of this project except for "gen/..." module
149-
DEFAULT_TARGETS:
150-
sh: echo `go list ./... | grep -v 'arduino-create-agent/gen/' | tr '\n' ' '`
153+
VERSION: "{{if .NIGHTLY}}nightly-{{.TIMESTAMP_SHORT}}{{else if .TAG}}{{.TAG}}{{else}}{{.TAG_TEST}}{{end}}"
154+
CONFIGURATION_PACKAGE: main
155+
LDFLAGS: >-
156+
-ldflags
157+
'
158+
-X {{.CONFIGURATION_PACKAGE}}.version={{.VERSION}}
159+
-X {{.CONFIGURATION_PACKAGE}}.commit={{.COMMIT}}
160+
# Path of the project's primary Go module:
151161
DEFAULT_GO_MODULE_PATH: ./
152162
DEFAULT_GO_PACKAGES:
153163
sh: |

0 commit comments

Comments
 (0)