-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Taskfile.yaml
129 lines (115 loc) · 3.04 KB
/
Taskfile.yaml
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
version: '3'
tasks:
install:
desc: Install dependencies
cmds:
- pnpm install
clean:
desc: Clean
cmds:
- rm public/{sitemap.xml,robots.txt,feed.rss}
- rm -r dist
ignore_error: true
prebuild:
desc: Prebuild
cmds:
- task: clean
- touch public/{sitemap.xml,robots.txt,feed.rss}
ignore_error: true
build:
desc: Build
cmds:
- task: install
- task: prebuild
- pnpm run build
silent: true
posts:
desc: List post files
cmds:
- ls src/pages/posts | grep \.md$ | sed 's/\.md$//' | grep {{.CLI_ARGS}}
silent: true
md2html:
desc: Generate HTML from markdown
cmds:
- mkdir .medium || true
- echo "Generating HTML..."
- md2html -o .medium/{{.CLI_ARGS}}.html src/pages/posts/{{.CLI_ARGS}}.md
- echo "Done."
silent: true
post2md:
desc: Create draft post on Medium
cmds:
- echo "Posting a draft post to Medium..."
- md-publisher publish .medium/{{.CLI_ARGS}}.html
- echo "Done."
silent: true
update_dep:
desc: Check whether the new version of the npm package broke the build.
cmds:
- task: init_dep_branch
vars:
BRANCH_NAME: '{{.CLI_ARGS}}'
- ncu -u -f {{.CLI_ARGS}}
- task: build
- task: commit_dep_changes
vars:
PACKAGE_NAME: '{{.CLI_ARGS}}'
silent: true
update_deps:
desc: Check whether the new version of the npm packages broke the build.
cmds:
- task: init_dep_branch
vars:
BRANCH_NAME: 'upgrade'
- ncu -u -f {{.CLI_ARGS}}
- task: build
- task: commit_dep_changes
vars:
PACKAGE_NAME: '{{.CLI_ARGS}}'
silent: true
init_dep_branch:
desc: Init git branch deps/*
cmds:
- git pull origin main:main
- git switch deps/{{.BRANCH_NAME}} 2>/dev/null || git switch -c deps/{{.BRANCH_NAME}}
- git rebase origin/main
silent: true
commit_dep_changes:
desc: Commit changes after updating package version
vars:
PACKAGE_VERSION:
sh: npm view {{.PACKAGE_NAME}} version
cmds:
- git add package.json pnpm-lock.yaml src/auto-imports.d.ts
- |
git commit -m "build(deps): update {{.PACKAGE_NAME}} to version {{.PACKAGE_VERSION}}"
- task: push_current
- task: create_pr_current
silent: true
push_current:
desc: Push current branch
vars:
BRANCH_NAME:
sh: git branch --show
cmds:
- git push -u origin {{.BRANCH_NAME}}
silent: true
create_pr_current:
desc: Create GitHub pull request for the current git branch
vars:
BRANCH_NAME:
sh: git branch --show
cmds:
- task: create_pr
vars:
BASE: 'main'
HEAD: '{{.BRANCH_NAME}}'
silent: true
create_pr:
desc: Create GitHub pull request
vars:
PR_TITLE:
sh: git log {{.BASE}}..{{.HEAD}} --pretty=format:%s | tail -1
cmds:
- gh pr create --base "{{.BASE}}" --head "{{.HEAD}}" --title "{{.PR_TITLE}}" --fill
silent: true