-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·63 lines (50 loc) · 1.68 KB
/
release.sh
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
#!/bin/bash
# CHECK FORMATTING AND LINTING
echo "Running black and pylint..."
black src/
# CHECK STATUS OF REPOSISTORY
echo "Checking status of repository..."
if [ -n "$(git status --porcelain)" ]; then \
echo "There are uncommitted changes. Commit them first." && exit 1; \
fi
# RUNNING PYLING
echo "Running pylint..."
if pylint src/; then
echo "Pylint found no problems"
else
echo "Pylint found problems, clean up before continuing"
exit 1
fi
# MAKE SURE VERSION IS INCREMENTED
poetry install
PACKAGE="vezzo"
VERSION="$(python -c "import importlib.metadata; print(importlib.metadata.version('$PACKAGE'))")"
echo $VERSION
echo "Checking version..."
if [ "$(git tag --sort=-v:refname | head -n1)" = "v${VERSION}" ]; then \
echo "Version $VERSION has already been tagged. Increment the version number." && exit 1; \
else \
echo "Version is good to go..."
fi
## BUILD THE PACKAGE ARTIFACTS
rm -rf build dist
python -m build --sdist --wheel
## MAKE THE RELEASE TO GITHUB
echo "Creating release..."
TAG="v${VERSION}"
git tag -a ${TAG} -m "Version ${VERSION}"
git push origin v${VERSION}
RELEASE_BODY=`awk '/## \[Unreleased\]/{flag=1;next}/## \[/{flag=0}flag' CHANGELOG.md`; \
gh release create $TAG --title "Version $VERSION" --notes "$RELEASE_BODY"
gh release upload $TAG dist/${PACKAGE}-${VERSION}.tar.gz
gh release upload $TAG dist/${PACKAGE}-${VERSION}-py3-none-any.whl
## UPDATE PYPI
echo "Uploading to PyPI..."
twine upload dist/*
## UPDATE CHANGELOG
echo "Updating changelog..."
TODAY=`date +'%Y-%m-%d'`; \
sed -i '' 's/## \[Unreleased\]/## [Unreleased]\n\n## ['$VERSION'] - '$TODAY'/' CHANGELOG.md
git add CHANGELOG.md
git commit -m "Update changelog for version $VERSION"
git push