-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathTaskfile.yml
More file actions
88 lines (79 loc) · 3.04 KB
/
Copy pathTaskfile.yml
File metadata and controls
88 lines (79 loc) · 3.04 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
version: '3'
vars:
PACKAGE: clad-body
tasks:
test:
desc: "Run measurement regression tests (add -- --view for 4-view renders)"
cmds:
- bash -c 'source ${VENV:-venv}/bin/activate && pytest tests/ -v {{.CLI_ARGS}}'
bump:
desc: "Bump version and create git tag. BUMP=patch|minor|major (default: patch)"
vars:
BUMP: '{{default "patch" .BUMP}}'
cmds:
- |
current=$(cat "{{.TASKFILE_DIR}}/VERSION" | tr -d '[:space:]')
IFS='.' read -r major minor patch <<< "$current"
case "{{.BUMP}}" in
major) major=$((major + 1)); minor=0; patch=0 ;;
minor) minor=$((minor + 1)); patch=0 ;;
patch) patch=$((patch + 1)) ;;
*) echo "Error: BUMP must be patch|minor|major" >&2; exit 1 ;;
esac
new="${major}.${minor}.${patch}"
tag="{{.PACKAGE}}/v${new}"
if git rev-parse "$tag" >/dev/null 2>&1; then
echo "Error: tag $tag already exists. Tags are immutable." >&2
exit 1
fi
echo "$new" > "{{.TASKFILE_DIR}}/VERSION"
git add "{{.TASKFILE_DIR}}/VERSION"
git commit -m "chore: bump {{.PACKAGE}} to $new"
git tag "$tag"
echo "Bumped {{.PACKAGE}}: $current → $new (tag: $tag)"
_check-clean:
internal: true
desc: Fail if there are staged or unstaged changes
cmds:
- |
UNSTAGED=$(git diff --name-only -- "{{.TASKFILE_DIR}}")
STAGED=$(git diff --cached --name-only -- "{{.TASKFILE_DIR}}")
if [ -n "$UNSTAGED" ] || [ -n "$STAGED" ]; then
echo "Error: uncommitted changes — the git tag would not match what is shipped." >&2
[ -n "$STAGED" ] && echo " Staged:$( echo "$STAGED" | sed 's/^/\n /')" >&2
[ -n "$UNSTAGED" ] && echo " Unstaged:$(echo "$UNSTAGED" | sed 's/^/\n /')" >&2
echo "Commit or stash changes, then retry." >&2
exit 1
fi
_build:
internal: true
deps: [test]
dir: "{{.TASKFILE_DIR}}"
cmds:
- rm -rf "{{.TASKFILE_DIR}}/dist"
- uv build --out-dir "{{.TASKFILE_DIR}}/dist"
_publish:
internal: true
desc: "Publish to registry. Set PUBLISH_URL and PUBLISH_TOKEN env vars, or defaults to GCP AR."
dir: "{{.TASKFILE_DIR}}"
cmds:
- |
URL="${PUBLISH_URL:-https://europe-west1-python.pkg.dev/clad-main/clad-python/}"
TOKEN="${PUBLISH_TOKEN:-$(gcloud auth print-access-token)}"
uv publish --publish-url "$URL" --username _token --password "$TOKEN" dist/*
ship:
desc: "check-clean → bump → build → publish → release. BUMP=patch|minor|major (default: patch)"
vars:
BUMP: '{{default "patch" .BUMP}}'
cmds:
- task: _check-clean
- task: bump
vars: {BUMP: "{{.BUMP}}"}
- task: _build
- task: _publish
- |
version=$(cat "{{.TASKFILE_DIR}}/VERSION" | tr -d '[:space:]')
tag="{{.PACKAGE}}/v${version}"
git push origin HEAD "$tag"
echo ""
echo "Shipped {{.PACKAGE}}==${version} — CI will publish to PyPI and create GitHub release"