-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve release setup based on the one in GitPython
- Loading branch information
Showing
3 changed files
with
34 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ MANIFEST | |
*.egg-info | ||
.noseids | ||
*.sublime-workspace | ||
/env/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,12 @@ | ||
.PHONY: build sdist cover test clean-files clean-docs doc all | ||
.PHONY: all clean release force_release | ||
|
||
all: | ||
$(info Possible targets:) | ||
$(info doc) | ||
$(info clean-docs) | ||
$(info clean-files) | ||
$(info clean) | ||
$(info test) | ||
$(info coverage) | ||
$(info build) | ||
$(info sdist) | ||
@grep -Ee '^[a-z].*:' Makefile | cut -d: -f1 | grep -vF all | ||
|
||
doc: | ||
cd doc && make html | ||
clean: | ||
rm -rf build/ dist/ .eggs/ .tox/ | ||
|
||
clean-docs: | ||
cd doc && make clean | ||
|
||
clean-files: | ||
git clean -fx | ||
rm -rf build/ dist/ | ||
|
||
clean: clean-files clean-docs | ||
|
||
test: | ||
pytest | ||
|
||
coverage: | ||
pytest --cov smmap --cov-report xml | ||
|
||
build: | ||
./setup.py build | ||
|
||
sdist: | ||
./setup.py sdist | ||
|
||
release: clean | ||
# Check if latest tag is the current head we're releasing | ||
echo "Latest tag = $$(git tag | sort -nr | head -n1)" | ||
echo "HEAD SHA = $$(git rev-parse head)" | ||
echo "Latest tag SHA = $$(git tag | sort -nr | head -n1 | xargs git rev-parse)" | ||
@test "$$(git rev-parse head)" = "$$(git tag | sort -nr | head -n1 | xargs git rev-parse)" | ||
make force_release | ||
|
||
force_release:: clean | ||
git push --tags | ||
python3 setup.py sdist bdist_wheel | ||
force_release: clean | ||
./build-release.sh | ||
twine upload dist/* | ||
git push --tags origin main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
# | ||
# This script builds a release. If run in a venv, it auto-installs its tools. | ||
# You may want to run "make release" instead of running this script directly. | ||
|
||
set -eEu | ||
|
||
function release_with() { | ||
$1 -m build --sdist --wheel | ||
} | ||
|
||
if test -n "${VIRTUAL_ENV:-}"; then | ||
deps=(build twine) # Install twine along with build, as we need it later. | ||
echo "Virtual environment detected. Adding packages: ${deps[*]}" | ||
pip install --quiet --upgrade "${deps[@]}" | ||
echo 'Starting the build.' | ||
release_with python | ||
else | ||
function suggest_venv() { | ||
venv_cmd='python -m venv env && source env/bin/activate' | ||
printf "HELP: To avoid this error, use a virtual-env with '%s' instead.\n" "$venv_cmd" | ||
} | ||
trap suggest_venv ERR # This keeps the original exit (error) code. | ||
echo 'Starting the build.' | ||
release_with python3 # Outside a venv, use python3. | ||
fi |