-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
187 lines (154 loc) · 4.4 KB
/
Taskfile.yml
File metadata and controls
187 lines (154 loc) · 4.4 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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
version: "1"
name: my-api
description: "CI generation: taskfile ci generate → GitHub, GitLab, Gitea, Drone, Jenkins, Makefile"
variables:
APP_NAME: my-api
IMAGE: ghcr.io/myorg/my-api
TAG: latest
environments:
local:
container_runtime: docker
compose_command: docker compose
staging:
ssh_host: staging.example.com
ssh_user: deploy
ssh_key: ~/.ssh/id_ed25519
container_runtime: docker
variables:
DOMAIN: staging.example.com
prod:
ssh_host: prod.example.com
ssh_user: deploy
ssh_key: ~/.ssh/id_ed25519
container_runtime: podman
service_manager: quadlet
variables:
DOMAIN: api.example.com
# ─── Pipeline ─────────────────────────────────────────
# This section is the SOURCE for `taskfile ci generate`.
# It declares stages, triggers, secrets, and artifacts.
# The CI generators translate this into platform-specific configs.
pipeline:
python_version: "3.12"
runner_image: ubuntu-latest
install_cmd: pip install taskfile
branches: [main, develop]
secrets: [GHCR_TOKEN, SSH_PRIVATE_KEY, DEPLOY_KEY]
cache: [~/.cache/pip]
artifacts: [dist/, coverage/]
stages:
- name: lint
tasks: [lint]
- name: test
tasks: [test]
artifacts: [coverage/]
cache: [~/.cache/pip]
- name: build
tasks: [build, push]
docker_in_docker: true
- name: deploy-staging
tasks: [deploy-staging]
env: staging
when: "branch:develop"
- name: deploy-prod
tasks: [deploy-prod]
env: prod
when: manual
- name: release
tasks: [release]
when: tag
# ─── Tasks ────────────────────────────────────────────
tasks:
lint:
desc: Run linters
stage: lint
cmds:
- ruff check src/
- mypy src/
ignore_errors: true
test:
desc: Run tests with coverage
stage: test
cmds:
- pytest tests/ -v --cov=src/ --cov-report=html:coverage/
build:
desc: Build Docker image
stage: build
deps: [test]
cmds:
- docker build -t ${IMAGE}:${TAG} .
push:
desc: Push to GHCR
stage: build
deps: [build]
cmds:
- docker push ${IMAGE}:${TAG}
deploy-staging:
desc: Deploy to staging
env: [staging]
cmds:
- "@remote docker pull ${IMAGE}:${TAG}"
- "@remote docker compose pull"
- "@remote docker compose up -d"
deploy-prod:
desc: Deploy to production
env: [prod]
cmds:
- "@remote podman pull ${IMAGE}:${TAG}"
- "@remote systemctl --user restart ${APP_NAME}"
release:
desc: Create GitHub release
cmds:
- gh release create ${TAG} dist/* --title "Release ${TAG}"
# ─── CI management tasks ────────────────────────────
ci-generate-github:
desc: "Generate GitHub Actions workflow"
cmds:
- taskfile ci generate --target github
- echo "Generated: .github/workflows/taskfile.yml"
ci-generate-gitlab:
desc: "Generate GitLab CI config"
cmds:
- taskfile ci generate --target gitlab
- echo "Generated: .gitlab-ci.yml"
ci-generate-gitea:
desc: "Generate Gitea Actions workflow"
cmds:
- taskfile ci generate --target gitea
- echo "Generated: .gitea/workflows/taskfile.yml"
ci-generate-drone:
desc: "Generate Drone CI config"
cmds:
- taskfile ci generate --target drone
- echo "Generated: .drone.yml"
ci-generate-jenkins:
desc: "Generate Jenkinsfile"
cmds:
- taskfile ci generate --target jenkins
- echo "Generated: Jenkinsfile"
ci-generate-makefile:
desc: "Generate Makefile wrapper"
cmds:
- taskfile ci generate --target makefile
- echo "Generated: Makefile"
ci-generate-all:
desc: "Generate CI configs for ALL 6 platforms"
cmds:
- taskfile ci generate --all
- echo "Generated configs for 6 CI platforms"
ci-preview:
desc: "Preview GitHub Actions config without writing"
cmds:
- taskfile ci preview --target github
ci-list:
desc: "List pipeline stages"
cmds:
- taskfile ci list
ci-run-local:
desc: "Run full pipeline locally"
cmds:
- taskfile ci run
ci-run-test:
desc: "Run only test stage locally"
cmds:
- taskfile ci run --stage test