-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve pypi manual pypi deployment script
remove docker deployment (using ghcr)
- Loading branch information
Showing
1 changed file
with
29 additions
and
26 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 |
---|---|---|
@@ -1,31 +1,34 @@ | ||
#!/bin/sh | ||
# This script can be used to bypass github actions | ||
# it deploys to pipy with api credentials | ||
# (username=__token__, password=pypi-***) | ||
|
||
set -e | ||
# extract the version="x.y.z" from setup.py | ||
VER=$(sed -n -e 's/.*version="\(.*\)".*/\1/p' < setup.py) | ||
|
||
function tag_if_not_tagged { | ||
TAG=v$1 | ||
if git rev-parse --verify --quiet "refs/tags/$TAG" >/dev/null; then | ||
echo "tag ${TAG} already exists" | ||
else | ||
git tag $TAG | ||
git push --tags | ||
echo "tagged ${TAG}" | ||
fi | ||
} | ||
|
||
function publish_to_pypi() { | ||
VERSION=$1 | ||
echo "creating sdist.." | ||
python3 setup.py sdist > /dev/null | ||
ARTIFACT="dist/withings-sync-${VERSION}.tar.gz" | ||
# Publish to pypi.org | ||
twine check $ARTIFACT | ||
twine upload $ARTIFACT | ||
} | ||
|
||
tag_if_not_tagged $VER | ||
publish_to_pypi $VER | ||
|
||
DOCKER_REPO=stv0g | ||
DOCKER_IMAGE=${DOCKER_REPO}/withings-sync | ||
DOCKER_PLATFORMS=linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 | ||
|
||
VER=$(sed -n -e 's/.*version='\''\([0-9\.]*\)'\''.*/\1/p' < setup.py) | ||
|
||
git tag v${VER} || true | ||
git push --tags | ||
|
||
# Build Docker image | ||
|
||
docker buildx create \ | ||
--use \ | ||
--platform ${DOCKER_PLATFORMS} \ | ||
--name cross-platform-build | ||
|
||
docker buildx build \ | ||
--platform ${DOCKER_PLATFORMS} \ | ||
--tag ${DOCKER_IMAGE}:${VER} \ | ||
--push . | ||
|
||
exit 0 | ||
|
||
# Publish to pypi.org | ||
python3 setup.py sdist | ||
|
||
twine upload dist/withings-sync-${VER}.tar.gz |