-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
117 lines (109 loc) · 3.89 KB
/
Copy pathTaskfile.yml
File metadata and controls
117 lines (109 loc) · 3.89 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
version: '3'
tasks:
next-version:
desc: Print the next version based on unreleased commits
cmds:
- git-cliff --bumped-version
changelog:
desc: "Update CHANGELOG.md for a release (usage: task changelog -- v0.2.0)"
requires:
vars: [CLI_ARGS]
vars:
TAG: '{{.CLI_ARGS}}'
cmds:
- "git-cliff --unreleased --tag {{.TAG}} --prepend CHANGELOG.md"
release-commit:
desc: "Commit staged release changes (usage: task release-commit -- v0.2.0)"
requires:
vars: [CLI_ARGS]
vars:
TAG: '{{.CLI_ARGS}}'
cmds:
- "git commit -am 'chore: release {{.TAG}}'"
tag:
desc: "Tag and push a release (usage: task tag -- v0.2.0)"
requires:
vars: [CLI_ARGS]
vars:
TAG: '{{.CLI_ARGS}}'
cmds:
- "git tag {{.TAG}}"
- git push
- git push --tags
docs:
desc: Regenerate per-command Markdown reference under docs/commands/
cmds:
- go generate ./...
preview-build:
desc: "Trigger the preview workflow build for a PR (usage: task preview-build -- 42)"
requires:
vars: [CLI_ARGS]
vars:
PR: '{{.CLI_ARGS}}'
silent: true
preconditions:
- sh: command -v gh >/dev/null 2>&1
msg: "gh CLI not found; install from https://cli.github.com/"
- sh: gh auth status >/dev/null 2>&1
msg: "gh CLI is not authenticated; run 'gh auth login'"
- sh: '[ "$(gh api "repos/$(gh repo view --json nameWithOwner -q .nameWithOwner)" --jq .permissions.push)" = "true" ]'
msg: "you don't have write access to this repo, which is required to dispatch workflows"
cmds:
- |
set -euo pipefail
echo "Dispatching preview workflow for PR {{.PR}}..."
gh workflow run preview.yml -f pr={{.PR}}
echo ""
echo "Watch progress with: gh run list --workflow=preview.yml --limit 5"
echo "Then fetch the binary: task preview-fetch -- {{.PR}}"
preview-fetch:
desc: "Download the preview binary for the current system from a PR (usage: task preview-fetch -- 42)"
requires:
vars: [CLI_ARGS]
vars:
PR: '{{.CLI_ARGS}}'
silent: true
preconditions:
- sh: command -v gh >/dev/null 2>&1
msg: "gh CLI not found; install from https://cli.github.com/"
- sh: gh auth status >/dev/null 2>&1
msg: "gh CLI is not authenticated; run 'gh auth login'"
- sh: command -v go >/dev/null 2>&1
msg: "go not found; install from https://go.dev/dl/"
cmds:
- |
set -euo pipefail
goos=$(go env GOOS)
goarch=$(go env GOARCH)
ext=""
[ "$goos" = "windows" ] && ext=".exe"
artifact="bight-preview-pr{{.PR}}-${goos}-${goarch}"
repo=$(gh repo view --json nameWithOwner -q .nameWithOwner)
echo "Looking up latest preview artifact: ${artifact}"
run_id=$(gh api "repos/${repo}/actions/artifacts?per_page=100" \
--jq "[.artifacts[] | select(.name == \"${artifact}\" and .expired == false)] | sort_by(.created_at) | reverse | first | .workflow_run.id")
if [ -z "$run_id" ] || [ "$run_id" = "null" ]; then
echo "No active preview artifact found for PR {{.PR}} (${goos}/${goarch})." >&2
echo "Trigger one with: gh workflow run preview.yml -f pr={{.PR}}" >&2
exit 1
fi
dest="dist/preview-pr{{.PR}}"
mkdir -p "$dest"
gh run download "$run_id" -n "$artifact" -D "$dest"
bin="${dest}/bight-${goos}-${goarch}${ext}"
chmod +x "$bin"
echo ""
echo "Downloaded: $bin (run ${run_id})"
echo ""
echo "To install, run:"
if [ "$goos" = "windows" ]; then
echo " move \"$(pwd)/$bin\" \"%USERPROFILE%\\bin\\bight.exe\""
else
echo " install -m 0755 \"$(pwd)/$bin\" \"\$HOME/.local/bin/bight\""
fi
# Help and info
default:
desc: Show available tasks
cmds:
- task --list
silent: true