-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
92 lines (81 loc) · 3.44 KB
/
Taskfile.yaml
File metadata and controls
92 lines (81 loc) · 3.44 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
version: "3"
vars:
COMMIT_TOML: "docs: :bookmark: change toml version to "
COMMIT_CHANGELOG: "feat: :memo: Add changelog entry for "
IMAGE_NAME: "typer-cli-starter"
REGISTRY_URL: "ghcr.io/oktapiancaw"
tasks:
build:
desc: "Build docker image"
vars:
# Default to 'latest' if no VERSION is provided
VERSION: '{{.VERSION | default "latest"}}'
cmds:
- echo "Building Docker image {{.IMAGE_NAME}}:{{.VERSION}}..."
- docker build -t {{.IMAGE_NAME}}:{{.VERSION}} .
- echo "Image {{.IMAGE_NAME}}:{{.VERSION}} built."
release:
desc: "Create and push a new git release tag"
vars:
VERSION: "{{.VERSION}}"
preconditions:
- {
sh: "test -n '{{.VERSION}}'",
msg: "VERSION is required. e.g., task release VERSION=1.2.3",
}
cmds:
# This still updates pyproject.toml for version tracking.
# You can change this to any other file where you store the version.
- echo "Changing version in pyproject.toml to {{.VERSION}}..."
- sed -i "s/version = .*/version = \"{{.VERSION}}\"/" pyproject.toml
- git add pyproject.toml
- git commit -m "{{.COMMIT_TOML}}{{.VERSION}}"
- echo "Generating changelog for v{{.VERSION}}..."
- git cliff --tag {{.VERSION}} --output CHANGELOG.md
- git add CHANGELOG.md
- git commit -m "{{.COMMIT_CHANGELOG}}{{.VERSION}}"
- echo "Creating git tag v{{.VERSION}}..."
- git tag -a "v{{.VERSION}}" -m "Release version {{.VERSION}}"
- echo "Pushing commits and tag to origin master..."
- git push origin master
- git push origin v{{.VERSION}}
- echo "Release v{{.VERSION}} pushed."
publish:
desc: "Build and publish docker image to registry"
vars:
VERSION: "{{.VERSION}}"
preconditions:
# A specific version is required to publish
- {
sh: "test -n '{{.VERSION}}'",
msg: "VERSION is required. e.g., task publish VERSION=1.2.3",
}
- task: build
vars:
VERSION: "{{.VERSION}}"
cmds:
- echo "Tagging image for registry {{.REGISTRY_URL}}..."
- docker tag {{.IMAGE_NAME}}:{{.VERSION}} {{.REGISTRY_URL}}/{{.IMAGE_NAME}}:{{.VERSION}}
- docker tag {{.IMAGE_NAME}}:{{.VERSION}} {{.REGISTRY_URL}}/{{.IMAGE_NAME}}:latest
- echo "Pushing images to registry..."
- docker push {{.REGISTRY_URL}}/{{.IMAGE_NAME}}:{{.VERSION}}
- docker push {{.REGISTRY_URL}}/{{.IMAGE_NAME}}:latest
- echo "Images {{.REGISTRY_URL}}/{{.IMAGE_NAME}}:{{.VERSION}} and {{.REGISTRY_URL}}/{{.IMAGE_NAME}}:latest published."
publish-nobuild:
desc: "Publish existing Docker image without rebuilding"
vars:
VERSION: "{{.VERSION}}"
preconditions:
# A specific version is required to publish
- {
sh: "test -n '{{.VERSION}}'",
msg: "VERSION is required. e.g., task publish-nobuild VERSION=1.2.3",
}
cmds:
- echo "Tagging image for registry {{.REGISTRY_URL}}..."
- docker tag {{.IMAGE_NAME}}:{{.VERSION}} {{.REGISTRY_URL}}/{{.IMAGE_NAME}}:{{.VERSION}}
- docker tag {{.IMAGE_NAME}}:{{.VERSION}} {{.REGISTRY_URL}}/{{.IMAGE_NAME}}:latest
- echo "Pushing images to registry..."
- docker push {{.REGISTRY_URL}}/{{.IMAGE_NAME}}:{{.VERSION}}
- docker push {{.REGISTRY_URL}}/{{.IMAGE_NAME}}:latest
- echo "Images {{.REGISTRY_URL}}/{{.IMAGE_NAME}}:{{.VERSION}} and {{.REGISTRY_URL}}/{{.IMAGE_NAME}}:latest published."