v4.2.0 #19
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
--- | |
# This workflow will upload a Python Package using Twine | |
# For more information see: | |
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries | |
name: Upload Python Package | |
on: | |
release: | |
types: [created] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set env | |
run: | | |
echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" | tee -a $GITHUB_ENV | |
echo "BRANCH=$( \ | |
git branch -r --contains ${GITHUB_REF} \ | |
| grep -v HEAD \ | |
| sed -n 's/ *origin\/\(.*\)/\1/p' \ | |
)" | tee -a $GITHUB_ENV | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
cache: pip | |
- name: Install dependencies | |
run: | | |
pip install build twine | |
- name: get infos from Tag | |
run: | | |
echo "RELEASE_TAG=${RELEASE_TAG}" | |
if [[ $RELEASE_TAG =~ (([0-9]+)\.([0-9]+)\.([0-9]+))([-./]dev([0-9]+))?$ ]] | |
then | |
echo "VERSION=${BASH_REMATCH[0]}" | tee -a $GITHUB_ENV | |
echo "VERSION_MAJOR=${BASH_REMATCH[2]}" | tee -a $GITHUB_ENV | |
echo "VERSION_MINOR=${BASH_REMATCH[3]}" | tee -a $GITHUB_ENV | |
echo "VERSION_PATCH=${BASH_REMATCH[4]}" | tee -a $GITHUB_ENV | |
echo "VERSION_DEV=${BASH_REMATCH[6]}" | tee -a $GITHUB_ENV | |
else | |
echo "INVALID_TAG=True" | tee -a $GITHUB_ENV | |
fi | |
- name: Fail on invalid Tag | |
if: ${{ env.INVALID_TAG }} | |
uses: actions/github-script@v6 | |
with: | |
script: core.setFailed('Invalid Tag name used with this release!') | |
- name: Write Version to pyproject.toml | |
run: | | |
sed -i "s/version = \".*\"$/version = \"$VERSION\"/" pyproject.toml | |
- name: Build sdist and bdist_wheel | |
run: | | |
python -m build | |
- name: publish to PyPi | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: | | |
twine upload dist/* | |
- name: increment development version | |
if: ${{ env.VERSION_DEV }} | |
run: | | |
v=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH-dev$((VERSION_DEV+1)) | |
sed -i "s/version = \".*\"$/version = \"$v\"/" pyproject.toml | |
- name: increment patch version | |
if: ${{ !env.VERSION_DEV }} | |
run: | | |
v=$VERSION_MAJOR.$VERSION_MINOR.$((VERSION_PATCH+1))-dev0 | |
sed -i "s/version = \".*\"$/version = \"$v\"/" pyproject.toml | |
- name: commit new version-number | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
branch: ${{ env.BRANCH }} | |
create_branch: true | |
commit_message: "increment version after release" |