-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yaml
117 lines (108 loc) · 2.8 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
version: '3'
tasks:
default:
desc: Show the available tasks
cmds:
- task --list --sort alphanumeric
test:
desc: Run tests
deps:
- build
cmds:
- npm run test
build:
desc: Compile TypeScript to JavaScript
cmds:
- npx tsc
sources:
- src/**/*.ts
generates:
- build/**/*.js
build:watch:
desc: Compile TypeScript to JavaScript and watch for changes
cmds:
- npx tsc -w
sources:
- src/**/*.ts
generates:
- build/**/*.js
build:clean:
desc: Remove build directory
cmds:
- rm -rf build
- git checkout -- build
dev-install:
desc: Local development setup
cmds:
- npm install
- task build
- sudo npm install -g
is-branch-safe:
desc: Check if the current branch is main
vars:
BRANCH:
sh: git rev-parse --abbrev-ref HEAD
cmds:
- |
if [ "{{.BRANCH}}" != "main" ] && [ "{{.BRANCH}}" != "develop" ]; then
echo "Not on main or develop branch"
exit 1
fi
release-*:
desc: Create a new release, task release-[patch|minor|major]
silent: true
preconditions:
- sh: task is-branch-safe
msg: "Not on main or develop branch"
vars:
STEP: '{{index .MATCH 0}}'
BRANCH:
sh: git rev-parse --abbrev-ref HEAD
PRERELEASE:
sh: |
if [ "{{.BRANCH}}" = "develop" ]; then
echo "--prerelease"
fi
cmds:
- |
task build:clean
task test
VERSION=$(gh release list --json tagName | jq -r '.[] | .tagName' | sort -V | tail -n 1)
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"
npm version $VERSION
git push
task build
zip -r build.zip build
gh release create "$VERSION" --generate-notes --target {{.BRANCH}} {{.PRERELEASE}} build.zip
rm build.zip
publish:
desc: publish a release to npm
preconditions:
- task is-branch-safe
cmds:
- npm publish --access public --registry https://registry.npmjs.org
release:publish:*:
desc: Create a new release and publish it to npm, release-[patch|minor|major]-pub
vars:
STEP: '{{index .MATCH 0}}'
cmds:
- task: release-{{.STEP}}
- task: publish