This repository was archived by the owner on Jul 2, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
197 lines (176 loc) · 5.08 KB
/
Copy pathTaskfile.yml
File metadata and controls
197 lines (176 loc) · 5.08 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# Taskfile (See https://taskfile.dev)
version: '3'
vars:
# The project version
VERSION: '0.0.3'
# The current short Git commit hash
COMMIT:
sh: git rev-parse --short HEAD
# The current Git branch
BRANCH:
sh: git rev-parse --abbrev-ref HEAD
# The current timestamp
TIMESTAMP:
sh: date --iso-8601=seconds --utc
# Go build OS
GOOS:
sh: go env GOOS
# Go build architecture
GOARCH:
sh: go env GOARCH
# Go build flags
GO_BUILD_FLAGS: -ldflags "-X 'github.com/wakeful-cloud/pam-oauth/internal/common.rawVersion={{ .VERSION }}' -X 'github.com/wakeful-cloud/pam-oauth/internal/common.rawCommit={{ .COMMIT }}' -X 'github.com/wakeful-cloud/pam-oauth/internal/common.rawBranch={{ .BRANCH }}' -X 'github.com/wakeful-cloud/pam-oauth/internal/common.rawTimestamp={{ .TIMESTAMP }}'"
# Multiarch triplet
MULTIARCH_TRIPLET:
sh: gcc -dumpmachine
# C compiler (GCC compatible)
CC: gcc
tasks:
audit:
desc: Run security audits
cmds:
- gosec ./...
sources:
- ./**/*.go
- ./**/*.mod
- ./**/*.sum
build:nss:
desc: Build the NSS module
label: 'Build the NSS module ({{ list .CC | join "|" | sha256sum }})'
cmds:
- mkdir -p ./dist/lib
- '{{ .CC }} -Wall -Werror -fPIC -o ./dist/lib/libnss_oauth.o -c ./lib/nss.c'
- '{{ .CC }} -shared -o ./dist/lib/libnss_oauth.so ./dist/lib/libnss_oauth.o'
- rm -f ./dist/lib/libnss_oauth.o
env:
CC: '{{ .CC }}'
sources:
- ./lib/nss.c
generates:
- ./dist/lib/libnss_oauth.so
build:pam:
desc: Build the PAM module
label: 'Build the PAM module ({{ list .CC | join "|" | sha256sum }})'
cmds:
- mkdir -p ./dist/lib
- '{{ .CC }} -Wall -Werror -fPIC -o ./dist/lib/pam_oauth.o -c ./lib/pam.c'
- '{{ .CC }} -shared -o ./dist/lib/pam_oauth.so ./dist/lib/pam_oauth.o'
- rm -f ./dist/lib/pam_oauth.o
env:
CC: '{{ .CC }}'
sources:
- ./lib/pam.c
generates:
- ./dist/lib/pam_oauth.so
build:client:
desc: Build the client
label: 'Build the client ({{ list .CC .GOARCH .GOOS .GO_BUILD_FLAGS | join "|" | sha256sum }})'
cmds:
- go build {{ .GO_BUILD_FLAGS }} -o ./dist/bin/pam-oauth-client ./cmd/client
env:
CC: '{{ .CC }}'
CGO_ENABLED: '1'
GOARCH: '{{ .GOARCH }}'
GOOS: '{{ .GOOS }}'
sources:
- ./**/*.go
- ./**/*.mod
- ./**/*.sum
generates:
- ./dist/bin/pam-oauth-client
build:login:
desc: Build the login shell
label: 'Build the login shell ({{ list .CC .GOARCH .GOOS .GO_BUILD_FLAGS | join "|" | sha256sum }})'
cmds:
- go build {{ .GO_BUILD_FLAGS }} -o ./dist/bin/pam-oauth-login ./cmd/login
env:
CGO_ENABLED: '1'
GOOS: '{{ .GOOS }}'
GOARCH: '{{ .GOARCH }}'
CC: '{{ .CC }}'
sources:
- ./**/*.go
- ./**/*.mod
- ./**/*.sum
generates:
- ./dist/bin/pam-oauth-login
build:server:
desc: Build the server
label: 'Build the server ({{ list .CC .GOARCH .GOOS .GO_BUILD_FLAGS | join "|" | sha256sum }})'
cmds:
- go build {{ .GO_BUILD_FLAGS }} -o ./dist/bin/pam-oauth-server ./cmd/server
env:
CC: '{{ .CC }}'
CGO_ENABLED: '1'
GOARCH: '{{ .GOARCH }}'
GOOS: '{{ .GOOS }}'
sources:
- ./**/*.go
- ./**/*.mod
- ./**/*.sum
generates:
- ./dist/bin/pam-oauth-server
build:man:
desc: Build the man pages
cmds:
- mkdir -p ./dist/man
- rm -rf ./dist/man
- go run -tags man ./cmd/client man --output ./dist/man
- go run -tags man ./cmd/login man --output ./dist/man
- go run -tags man ./cmd/server man --output ./dist/man
- gzip -r ./dist/man/*
sources:
- ./**/*.go
- ./**/*.mod
- ./**/*.sum
generates:
- ./dist/man/*
build:
desc: Build the project
deps:
- build:client
- build:login
- build:man
- build:nss
- build:pam
- build:server
package:
desc: Package the project
label: 'Package the project ({{ list .GOARCH .GOOS .MULTIARCH_TRIPLET .VERSION | join "|" | sha256sum }})'
cmds:
- mkdir -p ./dist/pkg
- for:
- deb
- rpm
- apk
- archlinux
cmd: nfpm pkg --config build/nfpm-client.yml --packager {{ .ITEM }} --target ./dist/pkg/
- for:
- deb
- rpm
- apk
- archlinux
cmd: nfpm pkg --config build/nfpm-server.yml --packager {{ .ITEM }} --target ./dist/pkg/
env:
GOARCH: '{{ .GOARCH }}'
GOOS: '{{ .GOOS }}'
MULTIARCH_TRIPLET: '{{ .MULTIARCH_TRIPLET }}'
SIGNING_KEY_FILE: ./signing.key
SIGNING_KEY_ID: 0x00000000
VERSION: '{{ .VERSION }}'
deps:
- build
clean:
desc: Clean the project
cmds:
- rm -rf ./dist
sources: []
generate:grpc:
desc: Generate the gRPC code
cmds:
- protoc --go_out=. --go_opt=paths=import --go-grpc_out=. --go-grpc_opt=paths=import ./api/grpc.proto
sources:
- ./api/grpc.proto
generates:
- ./internal/api/grpc.pb.go
- ./internal/api/grpc_grpc.pb.go