-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yml
executable file
·107 lines (96 loc) · 3.23 KB
/
Taskfile.yml
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
version: '3'
tasks:
default:
cmds:
- task -l
make:
cmds:
- pyinstaller --onefile src/inkwell.py
- chmod +x dist/inkwell
- task: install
install:
cmds:
- cp dist/inkwell /usr/local/bin/inkwell
reqs:
dir: src
cmds:
- pipreqs --force
set-version:
vars:
version: '{{default "0.0.0" .CLI_ARGS}}'
cmds:
- awk '/^__version__/ { print "__version__ = \"{{.version}}\""; next }1' src/inkwell.py > temp && mv temp src/inkwell.py
changelog:
desc: Append the latest version to the changelog
dir: ./
vars:
version: '{{default "0.0.0" .CLI_ARGS}}'
date: '{{now | date "2006-01-02"}}'
cmds:
- |
insert_line() {
local line_number="$1"
local new_line="$2"
sed -i '' "${line_number}a\\
${new_line}\\
\\
" changelog.md
}
insert_line 7 "## [{{.version}}] - {{.date}}"
insert_line 9 "### Added"
insert_line 11 "### Changed"
insert_line 13 "### Fixed"
insert_line 15 "### Removed"
footer_index=$(grep -n '^\[' changelog.md | cut -d: -f1 | head -n2 | tail -n1)
last_version=$(sed -n "${footer_index}p" changelog.md | grep -o '\[.*\]' | head -n1 | tr -d '[]')
existing_footer=$(tail -n +$footer_index changelog.md)
new_version_link="[{{.version}}]: https://github.com/mikegarde/inkwell/compare/$last_version...{{.version}}"
head -n $((footer_index-1)) changelog.md > tmp_changelog.md
echo "$new_version_link" >> tmp_changelog.md
echo "$existing_footer" >> tmp_changelog.md
sed -i '' "/\[unreleased\]:/s/$last_version/{{.version}}/" tmp_changelog.md
mv tmp_changelog.md changelog.md
silent: true
release:*:
desc: Create a new release, task release -- [patch|minor|major]
vars:
STEP: '{{index .MATCH 0}}'
BRANCH:
sh: git rev-parse --abbrev-ref HEAD
PRERELEASE:
sh: |
if [ "{{.BRANCH}}" != "main" ]; then
echo "--prerelease"
fi
cmds:
- |
VERSION=$(gh release list --json tagName | jq -r '.[] | .tagName' | sort -V | tail -n1 | head -n1)
MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f2)
PATCH=$(echo $VERSION | cut -d. -f3)
echo "Current version: $VERSION"
if [ "{{.STEP}}" = "major" ]; then
MAJOR=$((MAJOR+1))
MINOR=0
PATCH=0
elif [ "{{.STEP}}" = "minor" ]; then
MINOR=$((MINOR+1))
PATCH=0
elif [ "{{.STEP}}" = "patch" ]; then
PATCH=$((PATCH+1))
else
echo "Invalid step: {{.STEP}}"
exit 1
fi
VERSION="$MAJOR.$MINOR.$PATCH"
echo "New version: $VERSION"
task set-version -- $VERSION
task make
task set-version
gh release create "$VERSION" -F changelog.md --target {{.BRANCH}} {{.PRERELEASE}} ./dist/inkwell
if [ "{{.BRANCH}}" = "main" ]; then
gh release delete latest --yes
git push origin --delete latest
gh release create latest --generate-notes --target main --latest=false ./dist/inkwell
fi
silent: true