-
Notifications
You must be signed in to change notification settings - Fork 16
/
nut.yml
90 lines (89 loc) · 3.07 KB
/
nut.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
syntax_version: "7"
project_name: nut
docker_image: dockercore/golang-cross:1.13.15
work_in_project_folder_as: /go/src/github.com/matthieudelaro/nut
macros:
setup:
usage: call after pulling the project, to install dependencies
actions:
- govendor fetch +missing
build:
usage: build the project
actions:
- go build -o `pwd | xargs basename`
build-all:
usage: build the project for linux, OSX, and for Windows
actions:
- export dirName=`pwd | xargs basename`
- echo Building for linux...
- env GOOS=linux GOARCH=amd64 go build -o `echo $dirName`Linux
- echo Building for OSX...
- env GOOS=darwin GOARCH=amd64 go build -o `echo $dirName`OSX
- echo Building for Windows...
- env GOOS=windows GOARCH=amd64 go build -o `echo $dirName`Windows.exe
aliases:
- ba
release:
usage: release the project for linux, OSX, and Windows
actions:
# create a build tag
- export RELEASE_TAG="Build from commit `git rev-parse HEAD`, at `env TZ=UTC+7 date '+%Hh%Mmin%Ssec on %Y/%m/%d (PDT)'`"
- echo $RELEASE_TAG
- export RELEASE_TAG=" + \". $RELEASE_TAG\""
# insert the build tag in the description of the program
- sed -i "s#//RELEASE_BUILD_PLACEHOLDER//#$RELEASE_TAG#" main.go
# compile for all architectures
- export dirName=`pwd | xargs basename`
- echo Building for linux...
- env GOOS=linux GOARCH=amd64 go build -o release/linux/`echo $dirName`
- echo Building for OSX...
- env GOOS=darwin GOARCH=amd64 go build -o release/osx/`echo $dirName`
- echo Building for Windows...
- env GOOS=windows GOARCH=amd64 go build -o release/windows/`echo $dirName`.exe
# undo changes from the source code of the program
- sed -i "s#$RELEASE_TAG#//RELEASE_BUILD_PLACEHOLDER//#" main.go
build-linux:
usage: build the project for Linux
actions:
- env GOOS=linux GOARCH=amd64 go build -o `pwd | xargs basename`Linux
aliases:
- bl
build-osx:
usage: build the project for OSX
actions:
- env GOOS=darwin GOARCH=amd64 go build -o `pwd | xargs basename`OSX
aliases:
- bo
description: cross-compile the project to run on OSX, with architecture amd64.
build-windows:
usage: build the project for Windows
actions:
- env GOOS=windows GOARCH=amd64 go build -o `pwd | xargs basename`Windows.exe
aliases:
- bw
run:
usage: run the project in the container
volumes:
dockersock: # mount docker socket run nut in a container
host_path: /var/run/docker.sock
container_path: /var/run/docker.sock
actions:
- ./`pwd | xargs basename`
test:
usage: test the project
actions:
- go test
- cd config
- go test
code:
usage: open this project in vscode
docker_image: ctaggart/golang-vscode
enable_gui: true
volumes:
dockersock: # mount docker socket run nut in a container
host_path: /var/run/docker.sock
container_path: /var/run/docker.sock
security_opts:
- seccomp=unconfined
actions:
- su - vscode -c "export GOPATH=/go; code -w /go/src/github.com/matthieudelaro/nut"