Fix up checks in Makefile and make them portable by EliahKagan · Pull Request #1661 · gitpython-developers/GitPython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitattributes
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.py[co]
*.swp
*~
.env/
env/
.venv/
venv/
/*.egg-info
Expand Down
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@ clean:
rm -rf build/ dist/ .eggs/ .tox/

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)"
./check-version.sh
make force_release

force_release: clean
# IF we're in a virtual environment, add build tools
test -z "$$VIRTUAL_ENV" || pip install -U build twine
python3 -m build --sdist --wheel || echo "Use a virtual-env with 'python -m venv env && source env/bin/activate' instead"
./build-release.sh
twine upload dist/*
git push --tags origin main
26 changes: 26 additions & 0 deletions build-release.sh
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
46 changes: 46 additions & 0 deletions check-version.sh