-
Notifications
You must be signed in to change notification settings - Fork 34
/
Makefile
66 lines (50 loc) · 2.47 KB
/
Makefile
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
# Path Definitions
LANGROID := ~/Git/langroid/examples/
EXAMPLES := ~/Git/langroid-examples/examples/
# Base rsync command
SYNC_CMD := rsync -avc --files-from=-
# Command with itemized changes for rsync
SYNC_CMD_AI := rsync -aivcn --files-from=-
.PHONY: sync sync-dry stage
sync:
@(cd $(LANGROID) && git ls-files) | $(SYNC_CMD) $(LANGROID)/ $(EXAMPLES)/
sync-dry:
@echo "Files that would be added or modified by rsync..."
@(cd $(LANGROID) && git ls-files) | $(SYNC_CMD_AI) $(LANGROID)/ $(EXAMPLES)/ | grep '^>f'
stage-dry:
@echo "Would add the following modified and newly tracked files to stage:"
@cd $(EXAMPLES) && echo "Modified files:" && git ls-files -m --exclude-standard
@cd $(EXAMPLES) && echo "Newly tracked files:" && bash -c "comm -23 <(cd $(LANGROID) && git ls-files | sort) <(cd $(EXAMPLES) && git ls-files | sort)"
stage:
@echo "Staging modified files..."
@cd $(EXAMPLES) && git ls-files -m --exclude-standard | xargs -r git add
@echo "Staging newly tracked files..."
@cd $(EXAMPLES) && bash -c "comm -23 <(cd $(LANGROID) && git ls-files | sort) <(cd $(EXAMPLES) && git ls-files | sort)" | xargs -r git add
.PHONY: patch minor major
current_version := $(shell grep '^version = ' pyproject.toml | cut -d'"' -f2)
patch:
@echo "Current version: ${current_version}"
@new_version=$$(python -c "import semver; print(semver.VersionInfo.parse('${current_version}').bump_patch())") && \
sed -i '' "s/^version = .*/version = \"$$new_version\"/" pyproject.toml && \
git add pyproject.toml && \
git commit -m "Bump version to $$new_version" && \
git tag -a "v$$new_version" -m "Version $$new_version" && \
git push && git push --tags
minor:
@echo "Current version: ${current_version}"
@new_version=$$(python -c "import semver; print(semver.VersionInfo.parse('${current_version}').bump_minor())") && \
sed -i '' "s/^version = .*/version = \"$$new_version\"/" pyproject.toml && \
git add pyproject.toml && \
git commit -m "Bump version to $$new_version" && \
git tag -a "v$$new_version" -m "Version $$new_version" && \
git push && git push --tags
major:
@echo "Current version: ${current_version}"
@new_version=$$(python -c "import semver; print(semver.VersionInfo.parse('${current_version}').bump_major())") && \
sed -i '' "s/^version = .*/version = \"$$new_version\"/" pyproject.toml && \
git add pyproject.toml && \
git commit -m "Bump version to $$new_version" && \
git tag -a "v$$new_version" -m "Version $$new_version" && \
git push && git push --tags
setup:
pip install semver