Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ce03fde

Browse filesBrowse files
committed
improve release setup based on the one in GitPython
1 parent 810ae3a commit ce03fde
Copy full SHA for ce03fde

File tree

3 files changed

+34
-44
lines changed
Filter options

3 files changed

+34
-44
lines changed

‎.gitignore

Copy file name to clipboardExpand all lines: .gitignore
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ MANIFEST
99
*.egg-info
1010
.noseids
1111
*.sublime-workspace
12+
/env/

‎Makefile

Copy file name to clipboard
+7-44Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,12 @@
1-
.PHONY: build sdist cover test clean-files clean-docs doc all
1+
.PHONY: all clean release force_release
22

33
all:
4-
$(info Possible targets:)
5-
$(info doc)
6-
$(info clean-docs)
7-
$(info clean-files)
8-
$(info clean)
9-
$(info test)
10-
$(info coverage)
11-
$(info build)
12-
$(info sdist)
4+
@grep -Ee '^[a-z].*:' Makefile | cut -d: -f1 | grep -vF all
135

14-
doc:
15-
cd doc && make html
6+
clean:
7+
rm -rf build/ dist/ .eggs/ .tox/
168

17-
clean-docs:
18-
cd doc && make clean
19-
20-
clean-files:
21-
git clean -fx
22-
rm -rf build/ dist/
23-
24-
clean: clean-files clean-docs
25-
26-
test:
27-
pytest
28-
29-
coverage:
30-
pytest --cov smmap --cov-report xml
31-
32-
build:
33-
./setup.py build
34-
35-
sdist:
36-
./setup.py sdist
37-
38-
release: clean
39-
# Check if latest tag is the current head we're releasing
40-
echo "Latest tag = $$(git tag | sort -nr | head -n1)"
41-
echo "HEAD SHA = $$(git rev-parse head)"
42-
echo "Latest tag SHA = $$(git tag | sort -nr | head -n1 | xargs git rev-parse)"
43-
@test "$$(git rev-parse head)" = "$$(git tag | sort -nr | head -n1 | xargs git rev-parse)"
44-
make force_release
45-
46-
force_release:: clean
47-
git push --tags
48-
python3 setup.py sdist bdist_wheel
9+
force_release: clean
10+
./build-release.sh
4911
twine upload dist/*
12+
git push --tags origin main

‎build-release.sh

Copy file name to clipboard
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
#
3+
# This script builds a release. If run in a venv, it auto-installs its tools.
4+
# You may want to run "make release" instead of running this script directly.
5+
6+
set -eEu
7+
8+
function release_with() {
9+
$1 -m build --sdist --wheel
10+
}
11+
12+
if test -n "${VIRTUAL_ENV:-}"; then
13+
deps=(build twine) # Install twine along with build, as we need it later.
14+
echo "Virtual environment detected. Adding packages: ${deps[*]}"
15+
pip install --quiet --upgrade "${deps[@]}"
16+
echo 'Starting the build.'
17+
release_with python
18+
else
19+
function suggest_venv() {
20+
venv_cmd='python -m venv env && source env/bin/activate'
21+
printf "HELP: To avoid this error, use a virtual-env with '%s' instead.\n" "$venv_cmd"
22+
}
23+
trap suggest_venv ERR # This keeps the original exit (error) code.
24+
echo 'Starting the build.'
25+
release_with python3 # Outside a venv, use python3.
26+
fi

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.