forked from pop-os/cosmic-comp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
282 lines (262 loc) · 10 KB
/
Copy pathTaskfile.yml
File metadata and controls
282 lines (262 loc) · 10 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
version: "3"
vars:
NAME:
sh: grep 'name =' Cargo.toml | head -n 1 | cut -d'"' -f2
VERSION:
sh: grep '^version =' Cargo.toml | head -n 1 | cut -d'"' -f2
HOST_OS:
sh: uname
HOST_ARCH:
sh: uname -m
TARGET_ARCH:
sh: "rustc -vV | sed -n 's/host: //p'"
ARCH:
sh: echo "{{.TARGET_ARCH}}" | cut -d'-' -f1
IMAGE_NAME: "{{.NAME}}-builder"
# rust-toolchain.toml is baked into the image (it selects the cross std), so a
# channel bump has to invalidate the cached image just like a Dockerfile edit does.
IMAGE_TAG:
sh: cat Dockerfile rust-toolchain.toml | sha256sum | cut -d' ' -f1
tasks:
default:
aliases:
- help
cmds:
- go-task --list
build:debug:
desc: Build debug build
cmds:
- cargo build {{.ARG | default ""}} --target {{.TARGET_ARCH}}
build:release:
desc: Build release build
aliases:
- build
cmds:
- cargo build --release --target {{.TARGET_ARCH}}
build:all:
desc: Build release and debug builds
deps:
- build:debug
- build:release
run:
deps:
- build:debug
requires:
vars:
- name: LOG_LEVEL
enum: [trace, debug, info]
vars:
LOG_LEVEL: '{{.LOG_LEVEL | default "info"}}'
env:
RUST_LOG: |-
{{- if eq .LOG_LEVEL "trace" }}
error,agentos_panel=trace,icetron=trace
{{- else if eq .LOG_LEVEL "debug" }}
error,agentos_panel=debug,icetron=debug
{{- else }}
error,agentos_panel=info
{{- end }}
cmds:
- ./target/{{.TARGET_ARCH}}/debug/{{.NAME}}
dist:prepare:
desc: Prepare the project for packaging (set PROFILE=debug for a debuggable build)
vars:
PROFILE: '{{.PROFILE | default "release"}}'
BUILD_FLAGS: '{{if eq .PROFILE "debug"}}--features debug{{else}}--release{{end}}'
cmds:
- cargo build {{.BUILD_FLAGS}} --target {{.TARGET_ARCH}}
- rm -rf .cache/{{.NAME}}
- mkdir -p .cache/{{.NAME}}/usr/bin
- install -Dm0755 "target/{{.TARGET_ARCH}}/{{.PROFILE}}/{{.NAME}}" ".cache/{{.NAME}}/usr/bin/{{.NAME}}"
- install -Dm0644 "data/keybindings.ron" ".cache/{{.NAME}}/usr/share/cosmic/com.system76.CosmicSettings.Shortcuts/v1/defaults"
- install -Dm0644 "data/tiling-exceptions.ron" ".cache/{{.NAME}}/usr/share/cosmic/com.system76.CosmicSettings.WindowRules/v1/tiling_exception_defaults"
- install -Dm0644 "LICENSE" ".cache/{{.NAME}}/usr/share/licenses/cosmic-comp/LICENSE"
- install -Dm0644 "data/voice-mode/primary_binding" ".cache/{{.NAME}}/usr/share/cosmic/com.playtron.VoiceMode/v1/primary_binding"
- install -Dm0644 "data/voice-mode/fallback_binding" ".cache/{{.NAME}}/usr/share/cosmic/com.playtron.VoiceMode/v1/fallback_binding"
- install -Dm0644 "data/voice-mode/chat_app_id" ".cache/{{.NAME}}/usr/share/cosmic/com.playtron.VoiceMode/v1/chat_app_id"
- install -Dm0644 "data/voice-mode/enabled" ".cache/{{.NAME}}/usr/share/cosmic/com.playtron.VoiceMode/v1/enabled"
- mkdir -p dist
dist:archive:
desc: Build a tar archive of the project
deps:
- task: dist:prepare
vars:
PROFILE: '{{.PROFILE}}'
vars:
# Debug and release must not share an artifact name: they stage identical paths, so a
# shared name lets the up-to-date check package the other profile's tree.
SUFFIX: '{{if eq .PROFILE "debug"}}-debug{{end}}'
sources:
- .cache/{{.NAME}}/**/*
generates:
- dist/{{.NAME}}-{{.ARCH}}{{.SUFFIX}}.tar.gz
cmds:
- tar cvfz dist/{{.NAME}}-{{.ARCH}}{{.SUFFIX}}.tar.gz -C .cache {{.NAME}}
dist:rpm:
desc: Build an RPM package
aliases:
- rpm
deps:
- task: dist:archive
vars:
PROFILE: '{{.PROFILE}}'
vars:
SUFFIX: '{{if eq .PROFILE "debug"}}-debug{{end}}'
sources:
- dist/{{.NAME}}-{{.ARCH}}{{.SUFFIX}}.tar.gz
- pkg/rpm/{{.NAME}}.spec
generates:
- dist/{{.NAME}}-{{.VERSION}}-*.{{.ARCH}}.rpm
preconditions:
- sh: which rpmbuild
msg: "Prerequisite utility 'rpmbuild' is not installed"
cmds:
- mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
- cp ./pkg/rpm/{{.NAME}}.spec ~/rpmbuild/SPECS
- cp dist/{{.NAME}}-{{.ARCH}}{{.SUFFIX}}.tar.gz ~/rpmbuild/SOURCES/{{.NAME}}.tar.gz
- rpmbuild -bb --target {{.ARCH}} --define '_prefix /usr' ~/rpmbuild/SPECS/{{.NAME}}.spec
- cp ~/rpmbuild/RPMS/{{.ARCH}}/{{.NAME}}-{{.VERSION}}-*.{{.ARCH}}.rpm dist
dist:rpm:debug:
desc: "Build a debug RPM (unoptimized + the debug feature) - much faster to iterate than rpm"
aliases:
- rpm:debug
cmds:
# Same NVR as the release RPM, so it installs straight over one. The binary is far larger
# and slower; rebuild with `rpm` before measuring anything or shipping.
- task: dist:rpm
vars:
PROFILE: debug
dist:all:
desc: Build all supported distributable packages
aliases:
- dist
cmds:
- task: dist:archive
- task: dist:rpm
version:set:
desc: "Set the package version in Cargo.toml and the rpm spec - E.g. go-task version:set VERSION=1.2.3"
requires:
vars:
- VERSION
cmds:
# Only replace the FIRST version match (the package version), not dependency versions
- sed -i '0,/^version = "[0-9]\+\.[0-9]\+\.[0-9]\+"$/s//version = "{{.VERSION}}"/' Cargo.toml
- "sed -i 's/^Version: .*/Version: {{.VERSION}}/' pkg/rpm/cosmic-comp.spec"
# Sync the package's own entry in Cargo.lock (version line follows the name line).
# Without this the release commit ships a stale lock, so the next local build rewrites it.
- sed -i '/^name = "{{.NAME}}"$/{n;s/^version = .*/version = "{{.VERSION}}"/}' Cargo.lock
release:build:
desc: "Build the release RPMs for all arches (skipped when SKIP_BUILD=true; used by the release prepare step)"
cmds:
# SKIP_BUILD=true is set by the CI publish job, which reuses RPMs already
# built by the parallel matrix jobs. Local/standalone runs build normally.
- |
if [ "${SKIP_BUILD:-}" != "true" ]; then
task docker:run TARGET=dist:all ARCH=x86_64 TARGET_ARCH=x86_64-unknown-linux-gnu
task docker:run TARGET=dist:all ARCH=aarch64 TARGET_ARCH=aarch64-unknown-linux-gnu
fi
release:
desc: Publish a new release
preconditions:
- sh: which npx
msg: "Prerequisite utility 'npx' is not installed"
cmds:
# The .releaserc.yaml config contains the build commands and publish config
- npx semantic-release
repo:update:
desc: "Upload the release to the package repository"
vars:
BUCKET: playtron-dev2-global-os-public
BUCKET_PATH: repos/playtron-app/{{.ARCH}}
FILE: "dist/{{.NAME}}-{{.VERSION}}-1.{{.ARCH}}.rpm"
REPO_NAME: playtron
preconditions:
- sh: ls {{.FILE}}
msg: "File to upload does not exist: {{.FILE}}"
- sh: env | grep -q '^PACKAGES_UPLOAD_TOKEN='
msg: "PACKAGES_UPLOAD_TOKEN environment variable is not set"
cmds:
# TODO: Remove S3 uploads after repository switch
- echo "Uploading {{.FILE}} to s3://{{.BUCKET}}/{{.BUCKET_PATH}}/$(basename {{.FILE}})"
- aws s3 cp {{.FILE}} s3://{{.BUCKET}}/{{.BUCKET_PATH}}/$(basename "{{.FILE}}")
- echo "Publishing {{.FILE}} to 'https://packages.playtron.one/rpm/{{.REPO_NAME}}/packages/{{.NAME}}-{{.VERSION}}-1.{{.ARCH}}.rpm'"
- "curl -H 'Authorization: Bearer {{.PACKAGES_UPLOAD_TOKEN}}' -T {{.FILE}} 'https://packages.playtron.one/rpm/{{.REPO_NAME}}/packages/{{.NAME}}-{{.VERSION}}-1.{{.ARCH}}.rpm'"
test:all:
desc: Run all tests
aliases:
- test
cmds:
- cargo test -- --show-output
test:one:
desc: Run a single test - E.g. go-task test:one TEST=<test>
requires:
vars:
- TEST
cmds:
- RUST_BACKTRACE=1 cargo test {{.TEST}} -- --exact --show-output --include-ignored
clean:
desc: Remove build artifacts
cmds:
- rm -rf target .cache dist builder
docker:build:
desc: Build the container image used for the `docker:run` target
preconditions:
- sh: which docker
msg: "Prerequisite utility 'docker' is not installed"
status:
- docker images | grep {{.IMAGE_NAME}} | grep {{.IMAGE_TAG}}
cmds:
- docker build -t {{.IMAGE_NAME}}:{{.IMAGE_TAG}} .
docker:run:
desc: Run tasks inside Docker. E.g. go-task docker:run TARGET=build TARGET_ARCH=x86_64-unknown-linux-gnu
aliases:
- in-docker
deps:
- docker:build
preconditions:
- sh: which docker
msg: "Prerequisite utility 'docker' is not installed"
vars:
UID:
sh: id -u
GID:
sh: id -g
PWD:
sh: pwd
SSH_KEY:
sh: echo "${SSH_KEY}"
requires:
vars:
- TARGET
cmds:
- mkdir -p .cache/home
- mkdir -p .cache/var/lib/rpm
# A /etc/passwd entry is required so the correct ~/.ssh path is used
- echo -e "build:x:{{.UID}}:{{.GID}}::/home/build:/bin/bash" > .cache/passwd
# Use the SSH key from the host
- |
mkdir -p .cache/.ssh
{{ if ne .SSH_KEY "" }}
echo "{{.SSH_KEY}}" > .cache/.ssh/id_ed25519
chmod 600 .cache/.ssh/id_ed25519
{{ else }}
cp ~/.ssh/* .cache/.ssh
{{ end }}
- |
docker run --rm \
-v "{{.PWD}}:{{.PWD}}" \
-v "{{.PWD}}/../smithay:{{.PWD}}/../smithay" \
-v "{{.PWD}}/.cache/home:/home/build" \
-v "{{.PWD}}/.cache/var/lib/rpm:/var/lib/rpm" \
-v "{{.PWD}}/.cache/.ssh:/home/build/.ssh" \
-v "{{.PWD}}/.cache/passwd:/etc/passwd" \
--workdir "{{.PWD}}" \
-e HOME=/home/build \
-e CARGO_HOME=/home/build/.cargo \
-e BUILD_TYPE=${BUILD_TYPE} \
-e PKG_CONFIG_SYSROOT_DIR="/usr/{{.ARCH}}-linux-gnu" \
-e CARGO_NET_GIT_FETCH_WITH_CLI=true \
-e GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" \
--user {{.UID}}:{{.GID}} \
{{.IMAGE_NAME}}:{{.IMAGE_TAG}} \
task {{.TARGET}} ARCH={{.ARCH}} TARGET_ARCH={{.TARGET_ARCH}}