-
Notifications
You must be signed in to change notification settings - Fork 246
Expand file tree
/
Copy pathMakefile
More file actions
118 lines (95 loc) · 4.17 KB
/
Makefile
File metadata and controls
118 lines (95 loc) · 4.17 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
.PHONY: docs clean clean-dist test binary test-binary check-release check-version \
build tag push-tag upload-pypi publish-binary-upload github-release \
publish publish-all publish-binary docs-init init pep8-test prepare-release
VERSION=$(shell grep -m1 __version__ internetarchive/__version__.py | cut -d\' -f2)
# ============ Development ============
init:
pip install responses==0.5.0 pytest-cov pytest-pep8
pip install -e .
clean:
find . -type f -name '*\.pyc' -delete
find . -type d -name '__pycache__' -delete
clean-dist:
rm -rf dist/ build/ *.egg-info
pep8-test:
py.test --pep8 -m pep8 --cov-report term-missing --cov internetarchive
test:
ruff check
pytest
# ============ Documentation ============
docs-init:
pip install -r docs/requirements.txt
docs:
cd docs && make html
@echo "\033[95m\n\nBuild successful! View the docs homepage at docs/build/html/index.html.\n\033[0m"
# ============ Binary Building ============
binary:
pex . --python-shebang='/usr/bin/env python3' --python python3 -e internetarchive.cli.ia:main -o ia-$(VERSION)-py3-none-any.pex -r pex-requirements.txt --use-pep517
test-binary: binary
@echo "Testing pex binary..."
./ia-$(VERSION)-py3-none-any.pex --version
./ia-$(VERSION)-py3-none-any.pex --help > /dev/null
./ia-$(VERSION)-py3-none-any.pex metadata --help > /dev/null
@echo "Pex binary tests passed!"
# ============ Release Preparation ============
# Usage: make prepare-release RELEASE=5.7.2
prepare-release:
ifndef RELEASE
$(error RELEASE is required. Usage: make prepare-release RELEASE=5.7.2)
endif
@if echo "$(RELEASE)" | grep -q 'dev'; then \
echo "Error: RELEASE should not contain 'dev'"; exit 1; \
fi
sed -i '' "s/__version__ = '.*'/__version__ = '$(RELEASE)'/" internetarchive/__version__.py
sed -i '' "s/^$(RELEASE) (?)$$/$(RELEASE) ($$(date +%Y-%m-%d))/" HISTORY.rst
@echo "Updated to version $(RELEASE) with date $$(date +%Y-%m-%d)"
@echo "Review changes and commit when ready"
# ============ Release Validation ============
check-release:
@if [ "$$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then \
echo "Error: Must be on master branch to release"; exit 1; \
fi
@if [ -n "$$(git status --porcelain)" ]; then \
echo "Error: Working directory is not clean"; exit 1; \
fi
@if git rev-parse v$(VERSION) >/dev/null 2>&1; then \
echo "Error: Tag v$(VERSION) already exists"; exit 1; \
fi
@echo "Release checks passed!"
check-version:
@if echo "$(VERSION)" | grep -q 'dev'; then \
echo "Error: Cannot release dev version $(VERSION)"; exit 1; \
fi
@echo "Version $(VERSION) is valid for release"
# ============ Release Building ============
build: clean-dist
python -m build
# ============ Release Publishing ============
tag:
git tag -a v$(VERSION) -m 'version $(VERSION)'
push-tag:
git push --tags origin master
upload-pypi:
twine upload --repository pypi ./dist/*
publish-binary-upload:
./ia-$(VERSION)-py3-none-any.pex upload ia-pex ia-$(VERSION)-py3-none-any.pex --no-derive
./ia-$(VERSION)-py3-none-any.pex upload ia-pex ia-$(VERSION)-py3-none-any.pex --remote-name=ia --no-derive
# Extract changelog and create GitHub release
github-release:
@echo "Extracting changelog for v$(VERSION)..."
@awk '/^$(VERSION) /{found=1; next} found && /^\++$$/{next} found && /^[0-9]+\.[0-9]+\.[0-9]+ /{exit} found' HISTORY.rst > /tmp/ia-release-notes-$(VERSION).md
gh release create v$(VERSION) \
--title "Version $(VERSION)" \
--notes-file /tmp/ia-release-notes-$(VERSION).md
@rm -f /tmp/ia-release-notes-$(VERSION).md
@echo "GitHub release created!"
# ============ Main Release Targets ============
# PyPI-only release (no binary)
publish: check-version check-release test build tag push-tag upload-pypi github-release
@echo "\n\033[92mRelease v$(VERSION) published to PyPI and GitHub!\033[0m"
# Full release including pex binary
publish-all: check-version check-release test build binary test-binary tag push-tag upload-pypi publish-binary-upload github-release
@echo "\n\033[92mRelease v$(VERSION) published everywhere!\033[0m"
# Binary-only release (for publishing binary after PyPI release)
publish-binary: binary test-binary publish-binary-upload
@echo "\n\033[92mBinary v$(VERSION) published to archive.org!\033[0m"