Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
110 lines (100 loc) · 3.57 KB
/
Copy pathTaskfile.yml
File metadata and controls
110 lines (100 loc) · 3.57 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
# https://taskfile.dev
# yaml-language-server: $schema=https://taskfile.dev/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
version: "3"
tasks:
build:
desc: Build the binary
cmds:
- cargo build
test:
desc: Run the tests
cmds:
- cargo test
lint:
desc: Lint with clippy
cmds:
- cargo clippy --all-targets -- -D warnings
fmt:
desc: Format the code
cmds:
- cargo fmt --all
ci:
desc: Run everything CI runs
cmds:
- cargo fmt --all --check
- task: lint
- task: build
- task: test
screenshot:
desc: Regenerate the README screenshot from fake data, upload it, and link it
preconditions:
- sh: command -v vhs
msg: vhs is not installed (brew install vhs)
cmds:
- cargo build --example demo
- rm -f demo.png
# vhs has been seen to exit 0 without writing the screenshot, so check.
- vhs demo.tape
- test -f demo.png
- |
url=$(curl --fail-with-body -sS -X POST \
https://uploads.github.com/user-attachments/assets \
--url-query "name=demo.png" \
--url-query "content_type=image/png" \
--url-query "repository_id=$(gh api 'repos/{owner}/{repo}' --jq .id)" \
-H "Content-Type: application/octet-stream" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Authorization: token $(gh auth token)" \
--data-binary @demo.png | jq -r .url)
case "$url" in https://*) ;; *) echo "upload failed: $url" >&2; exit 1;; esac
# An uploaded asset stays private until its URL appears in a comment,
# issue or PR body — a commit referencing it does not count, so linking
# it in the README is not enough. Posting it in a commit comment
# publishes it for good; deleting the comment does not take it back.
comment=$(gh api "repos/{owner}/{repo}/commits/$(gh api 'repos/{owner}/{repo}/commits' --jq '.[0].sha')/comments" \
-f body="" --jq .id)
gh api -X DELETE "repos/{owner}/{repo}/comments/$comment" --silent
for _ in $(seq 30); do
code=$(curl -sS -o /dev/null -w '%{http_code}' -L "$url")
[ "$code" = 200 ] && break
sleep 5
done
[ "$code" = 200 ] || { echo "$url is not public ($code)" >&2; exit 1; }
sed -i.bak "s|https://github.com/user-attachments/assets/[0-9a-f-]*|$url|" README.md
rm -f README.md.bak
echo "README.md now points at $url"
default:
cmds:
- task: ci
release:
desc: Bump the version, tag it, and push
vars:
NEXT:
sh: svu next
VERSION: '{{trimPrefix "v" .NEXT}}'
prompt: "This will release {{.NEXT}}. Continue?"
preconditions:
- sh: '[ $(git symbolic-ref --short HEAD) = "main" ]'
msg: Not on the main branch
- sh: "[ $(git status --porcelain=2 | wc -l) = 0 ]"
msg: Git is dirty
cmds:
- sed -i.bak 's/^version = .*/version = "{{.VERSION}}"/' Cargo.toml
- rm -f Cargo.toml.bak
- cargo update --workspace --offline
- git add Cargo.toml Cargo.lock
- 'git commit -s -m "chore(release): {{.NEXT}}"'
- git tag -m {{.NEXT}} {{.NEXT}}
- git push origin main --follow-tags
# Give GitHub a moment to register the run, otherwise we'd watch the
# previous one.
- sleep 5
- task: release:watch
release:watch:
desc: Watch the current release workflow run
vars:
RUN_ID:
sh: gh run list --workflow=release.yml --limit 1 --json databaseId --jq '.[].databaseId'
cmds:
- gh run watch {{.RUN_ID}}