-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJustfile
105 lines (79 loc) · 3.26 KB
/
Justfile
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
TARGET := "local/hamd-target.pkl"
RESOURCES := "local/hamd.pkl"
GOROOT := `go env GOROOT`
GOPATH := `go env GOPATH`
GO_OPTIONS := "-tags containers_image_openpgp"
PKL_GEN_GO := GOPATH + "/bin/pkl-gen-go"
alias w := watch
watch +WATCH_TARGET='test':
watchexec -rc -w . --ignore *.pkl.go --ignore main --print-events -- just {{WATCH_TARGET}}
setup: install
install: install-pkl install-pkl-gen-go install-cobra-cli install-go-releaser
gen: pkl-gen-go
run: test state actions apply
state:
export PATH=$(pwd)/bin:$PATH && go run main.go state -t {{TARGET}} -r {{RESOURCES}}
actions:
export PATH=$(pwd)/bin:$PATH && go run main.go actions -t {{TARGET}} -r {{RESOURCES}}
apply:
export PATH=$(pwd)/bin:$PATH && go run main.go apply -t {{TARGET}} -r {{RESOURCES}}
test: build
go test {{GO_OPTIONS}} ./...
build:
go build {{GO_OPTIONS}} -o bin/declix
release version: clean dist (build-release version) (gen-pkl version)
dist:
mkdir dist
clean:
rm -rf dist
cut-release VERSION:
# check clean tree
git diff --exit-code
git diff --cached --exit-code
git tag {{VERSION}}
git push origin
git push origin {{VERSION}}
[private]
install-pkl:
mkdir -p bin
wget -O bin/pkl https://github.com/apple/pkl/releases/download/0.26.1/pkl-alpine-linux-amd64
chmod +x bin/pkl
[private]
install-pkl-gen-go:
go install github.com/apple/pkl-go/cmd/pkl-gen-go@latest
[private]
pkl-gen-go:
find . -name "*.pkl.go" -exec rm -f {} +
export PATH=$(pwd)/bin:$PATH && {{PKL_GEN_GO}} resources/apt/Apt.pkl --base-path mikea/declix
export PATH=$(pwd)/bin:$PATH && {{PKL_GEN_GO}} resources/dpkg/Dpkg.pkl --base-path mikea/declix
export PATH=$(pwd)/bin:$PATH && {{PKL_GEN_GO}} resources/users/Users.pkl --base-path mikea/declix
export PATH=$(pwd)/bin:$PATH && {{PKL_GEN_GO}} systemd/systemd.pkl --base-path mikea/declix
export PATH=$(pwd)/bin:$PATH && {{PKL_GEN_GO}} resources/filesystem/FileSystem.pkl --base-path mikea/declix
export PATH=$(pwd)/bin:$PATH && {{PKL_GEN_GO}} content/Content.pkl --base-path mikea/declix
export PATH=$(pwd)/bin:$PATH && {{PKL_GEN_GO}} resources/Resources.pkl --base-path mikea/declix
export PATH=$(pwd)/bin:$PATH && {{PKL_GEN_GO}} target/Target.pkl --base-path mikea/declix
[private]
install-cobra-cli:
go install github.com/spf13/cobra-cli@latest
[private]
install-go-releaser:
go install github.com/goreleaser/goreleaser/v2@latest
[private]
build-release VERSION: (build-archive VERSION "linux" "amd64") (build-archive VERSION "linux" "arm64")
[private]
build-archive VERSION OS ARCH:
GOOS={{OS}} GOARCH={{ARCH}} go build -o dist/declix-{{VERSION}}-{{OS}}-{{ARCH}}
tar \
-cvzf dist/declix-{{VERSION}}-{{OS}}-{{ARCH}}.tgz \
--transform "s/declix-{{VERSION}}-{{OS}}-{{ARCH}}/declix/" \
-C dist declix-{{VERSION}}-{{OS}}-{{ARCH}}
rm dist/declix-{{VERSION}}-{{OS}}-{{ARCH}}
[private]
gen-pkl version:
#!/usr/bin/env bash
set -euxo pipefail
find . -type f -name "*.pkl" -not -path "*/tests/*" | zip dist/pkl@{{version}}.zip -@
cp pkl.json.tpl dist/pkl@{{version}}.json
sed -i "s/VERSION/{{version}}/g" dist/pkl@{{version}}.json
read -r SHA256 _ < <(sha256sum dist/pkl@{{version}}.zip)
sed -i "s/SHA256/$SHA256/g" dist/pkl@{{version}}.json