Release | PyPi Build Test Package and Push #12
Workflow file for this run
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
name: Release | PyPi Build Test Package and Push | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: | | |
"Version to publish (optional): | |
If not given, next patch from latest will be used." | |
default: "" | |
required: false | |
jobs: | |
build_push: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
- name: install_dependencies | |
run: | | |
pip3 install --user --upgrade pipenv && pipenv install --dev --python 3.8 | |
shell: bash | |
- name: bump_version | |
run: | | |
echo "[INFO] Get current version" | |
CURRENT_VERSION=$(cat $INIT_FILE | grep "__version__" | grep -oP "([0-9]*\.[0-9]*\.[0-9]*)") | |
echo "[INFO] Current version: $CURRENT_VERSION" | |
[ -z "$RELEASE_VERSION" ] && \ | |
echo "[INFO] Get latest version from TestPypi." && \ | |
LATEST_VERSION=$(curl -sL "https://test.pypi.org/pypi/leverage/json" | jq -r ".releases | keys | sort | .[-1]") && \ | |
echo "[INFO] Latest version: $LATEST_VERSION" && \ | |
RELEASE_VERSION="$(echo $LATEST_VERSION | awk 'BEGIN{FS="."; OFS="."} {print $1,$2,$3+1}')rc.1" | |
echo "[INFO] Checking Release Version (template 9.9.9-rc9)..." | |
([ $(echo $RELEASE_VERSION | grep -oP "([0-9]*\.[0-9]*\.[0-9]*\-(rc|alpha|beta)[0-9]+)") ] && echo "[INFO] Version ok" ) || (echo "[ERROR] Version is wrong" && exit 1) | |
echo "[INFO] Bump version to $RELEASE_VERSION" | |
sed -i 's/'$CURRENT_VERSION'/'$RELEASE_VERSION'/' $INIT_FILE | |
env: | |
INIT_FILE: leverage/__init__.py | |
RELEASE_VERSION: ${{ github.event.inputs.version }} | |
- name: clean | |
run: | | |
rm -rf ./build/ && rm -rf ./dist/ | |
- name: build | |
run: | | |
pipenv run python setup.py sdist bdist_wheel | |
- name: check | |
run: | |
pipenv run twine check dist/* | |
- name: upload | |
run: | | |
pipenv run twine upload --non-interactive --repository-url https://upload.pypi.org/legacy/ dist/* | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |