forked from MChambers1992/CopyPasta2
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
96 lines (88 loc) · 3.08 KB
/
Taskfile.yml
File metadata and controls
96 lines (88 loc) · 3.08 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
version: '3'
vars:
TOC_FILE: CopyPasta2.toc
ADDON_NAME: CopyPasta2
tasks:
changelog:
desc: Generate CHANGELOG.md from conventional commits
vars:
CURRENT_VERSION:
sh: "grep '^## Version:' {{.TOC_FILE}} | awk '{print $3}'"
cmds:
- |
tmp_pkg="$(mktemp)"
tmp_release="$(mktemp)"
tmp_existing="$(mktemp)"
trap 'rm -f "$tmp_pkg" "$tmp_release" "$tmp_existing" "$tmp_existing.filtered"' EXIT
printf '{\n "name": "%s",\n "version": "%s"\n}\n' "{{.ADDON_NAME}}" "{{.CURRENT_VERSION}}" > "$tmp_pkg"
conventional-changelog -n changelog.config.cjs -k "$tmp_pkg" -r 1 > "$tmp_release"
awk 'BEGIN {capture = 0} /^## \[/ {capture = 1} capture {print}' CHANGELOG.md > "$tmp_existing"
awk -v version="{{.CURRENT_VERSION}}" '
BEGIN {skip = 0}
$0 ~ ("^## \\[" version "\\]") {skip = 1; next}
/^## \[/ && skip == 1 {skip = 0}
skip == 0 {print}
' "$tmp_existing" > "$tmp_existing.filtered"
{
printf '# {{.ADDON_NAME}} Changelog\n\nAll notable changes to this project will be documented in this file.\n\n'
cat "$tmp_release"
if [ -s "$tmp_existing.filtered" ]; then
printf '\n'
cat "$tmp_existing.filtered"
fi
} > CHANGELOG.md
bump-interface:
desc: Update Interface version in TOC file
cmds:
- "sed -i 's/^## Interface:.*/## Interface: {{.INTERFACE}}/' {{.TOC_FILE}}"
vars:
INTERFACE: '120001'
bump-version:
desc: Update addon version in TOC file
cmds:
- "sed -i 's/^## Version:.*/## Version: {{.VERSION}}/' {{.TOC_FILE}}"
requires:
vars: [VERSION]
release:
desc: Full release process (bump version, changelog, commit, tag)
deps: [bump-interface]
cmds:
- task: bump-version
vars: {VERSION: '{{.VERSION}}'}
- task: changelog
- "git add {{.TOC_FILE}} CHANGELOG.md"
- "git commit -m 'chore(release): {{.VERSION}}'"
- "git tag {{.VERSION}}"
- "echo 'Release {{.VERSION}} created. Push with git push --follow-tags origin main'"
requires:
vars: [VERSION]
release:patch:
desc: Release patch version (auto-increment)
cmds:
- task: release
vars: {VERSION: '{{.NEXT_PATCH}}'}
vars:
CURRENT:
sh: "grep '^## Version:' {{.TOC_FILE}} | awk '{print $3}'"
NEXT_PATCH:
sh: "echo '{{.CURRENT}}' | awk -F. '{print $1\".\"$2\".\"$3+1}'"
release:minor:
desc: Release minor version (auto-increment)
cmds:
- task: release
vars: {VERSION: '{{.NEXT_MINOR}}'}
vars:
CURRENT:
sh: "grep '^## Version:' {{.TOC_FILE}} | awk '{print $3}'"
NEXT_MINOR:
sh: "echo '{{.CURRENT}}' | awk -F. '{print $1\".\"$2+1\".0\"}'"
release:major:
desc: Release major version (auto-increment)
cmds:
- task: release
vars: {VERSION: '{{.NEXT_MAJOR}}'}
vars:
CURRENT:
sh: "grep '^## Version:' {{.TOC_FILE}} | awk '{print $3}'"
NEXT_MAJOR:
sh: "echo '{{.CURRENT}}' | awk -F. '{print $1+1\".0.0\"}'"