-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yaml
164 lines (150 loc) · 4.64 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
---
version: 3
vars:
REPOSITORY_NAME: stuttgart-things
PROJECT_NAME:
sh: pwd | grep -o "[^/]*$"
DATE:
sh: date +"%y.%m%d.%H%M"
GIT_COMMIT:
sh: git log -n 1 --format=%h
BRANCH:
sh: if [ $(git rev-parse --abbrev-ref HEAD) != "main" ]; then echo $(git rev-parse --abbrev-ref HEAD); else echo main ; fi
VERSION:
sh: |
[ "$(git branch --show-current)" != "main" ] && echo "previewPost-$(git describe --tags --abbrev=0)" || echo $(git describe --tags --abbrev=0)
GIT_REPO: github.com/stuttgart-things/kaeffken
IMAGE_REPO: scr.cd43.sthings-pve.labul.sva.de/kaeffken
ORGA_NAME: stuttgart-things
MODULE: github.com/{{ .ORGA_NAME }}/{{ .PROJECT_NAME }}
DATE:
sh: date -Ih
GIT_COMMIT:
sh: git log -n 1 --format=%h
tasks:
build-ko:
desc: Build image w/ KO
deps: [lint, test, commit]
env:
KO_DOCKER_REPO: ghcr.io/{{ .ORGA_NAME }}/{{ .PROJECT_NAME }}
cmds:
- ko build {{ .MODULE }} --image-label org.opencontainers.image.source=https://github.com/{{ .ORGA_NAME }}/{{ .PROJECT_NAME }} --push
tests:
desc: Built cli tests
deps:
- build
cmds:
- kaeffken encrypt --source tests/secret.yaml --output stdout
branch:
desc: Create branch from main
cmds:
- git checkout main
- git branch
- git pull
- |
echo "Enter to be created (remote) branch:"
read BRANCH_NAME;
git checkout -b ${BRANCH_NAME}
git push origin ${BRANCH_NAME}
- git branch
- git branch --set-upstream-to=origin/main ${BRANCH_NAME}
pr:
desc: Create pull request into main
cmds:
- task: commit
- gh pr create -t "{{ .BRANCH }}" -b "{{ .BRANCH }} branch into main"
- sleep 20s
- gh pr checks $(gh pr list | grep "^[^#;]" | awk '{print $1}') --watch
- gh pr merge $(gh pr list | grep "^[^#;]" | awk '{print $1}') --auto --rebase --delete-branch
- git checkout main && git pull
run:
desc: Run
deps: [build]
cmds:
- "$GOPATH/bin/{{ .PROJECT_NAME }}"
build:
desc: Install
deps: [lint, test]
cmds:
- go mod tidy
- go install -ldflags="-X {{ .MODULE }}/cmd.version={{ .VERSION }} -X {{ .MODULE }}/cmd.date={{ .DATE }} -X {{ .MODULE }}/cmd.commit={{ .GIT_COMMIT }}"
lint:
desc: Lint code
cmds:
- go mod tidy
- cmd: golangci-lint run
ignore_error: true
test:
desc: Test code
cmds:
- go mod tidy
- cmd: go test ./... -v
# run:
# desc: Build code
# deps:
# - lint
# - test
# cmds:
# - go mod tidy
# - cmd: go install -ldflags="-X {{ .MODULE }}/cmd.date={{ .DATE }} -X {{ .MODULE }}/cmd.version={{ .VERSION }}-{{ .BRANCH }} -X {{ .MODULE }}/cmd.commit={{ .GIT_COMMIT }}"
# - cmd: "{{ .PROJECT_NAME }}"
commit:
desc: Commit + push code into branch
cmds:
- rm -rf dist/
- git branch --set-upstream-to=origin/{{ .BRANCH }}
- git pull
- |
git add *
if [[ -n $(git status --porcelain) ]]; then
echo "committing changes"
echo "ENTER COMMIT MESSAGE"
read COMMIT_MESSAGE;
git commit --allow-empty -a -m "$(echo ${COMMIT_MESSAGE})"
else
echo "no changes"
fi
git push origin -u {{ .BRANCH }}
pr:
desc: Create pull request into main
cmds:
- task: commit
- gh pr create -t "{{ .BRANCH }}" -b "{{ .BRANCH }} branch into main"
- sleep 20s
- gh pr checks $(gh pr list | grep "^[^#;]" | grep "{{ .BRANCH }}" | awk '{print $1}') --watch
- gh pr merge $(gh pr list | grep "^[^#;]" | grep "{{ .BRANCH }}" | awk '{print $1}') --auto --rebase --delete-branch
- git checkout main && git pull
delete-branch:
desc: Delete branch from origin
cmds:
- git checkout main
- git branch
- git pull
- |
echo "Enter to be deleted (remote) branch:"
read BRANCH_NAME;
git branch -d ${BRANCH_NAME}
git push origin -d ${BRANCH_NAME}
build-ko:
desc: Build KO Image
deps: [commit]
cmds:
- |
BUILD_IMAGE=$(ko build --preserve-import-paths --image-label org.opencontainers.image.source={{ .GIT_REPO }})
echo "Built image: ${BUILD_IMAGE}"
env:
KO_DOCKER_REPO: "{{ .IMAGE_REPO }}"
KO_REPO: "{{ .GIT_REPO }}"
release:
desc: Release
cmds:
- git checkout main && git pull
- task: commit
- npx semantic-release --dry-run
- npx semantic-release --debug --no-ci
- rm -rf ./dist
- goreleaser healthcheck
- goreleaser check
- goreleaser release --skip=publish --snapshot --clean
- goreleaser release --clean
- rm -rf ./dist