Skip to content

Commit

Permalink
update scripts to allow release (copied from smmap)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jan 2, 2025
1 parent 104138c commit 775cfe8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 35 deletions.
42 changes: 7 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,40 +1,12 @@
PYTHON = python3
SETUP = $(PYTHON) setup.py
TESTFLAGS =
.PHONY: all clean release force_release

all::
all:
@grep -Ee '^[a-z].*:' Makefile | cut -d: -f1 | grep -vF all

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
clean:
rm -rf build/ dist/ .eggs/ .tox/

force_release:: clean
git push --tags
python3 -m build --sdist --wheel
force_release: clean
./build-release.sh
twine upload dist/*

doc::
make -C doc/ html

build::
$(SETUP) build
$(SETUP) build_ext -i

build_ext::
$(SETUP) build_ext -i

install::
$(SETUP) install

clean::
$(SETUP) clean --all
rm -f *.so

coverage:: build
PYTHONPATH=. $(PYTHON) -m pytest --cov=gitdb gitdb

git push --tags origin master
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

0 comments on commit 775cfe8

Please sign in to comment.