|
1 | 1 | ---
|
2 |
| -# This workflow will upload a Python Package using Twine when a release is |
3 |
| -# created |
| 2 | +# This workflow will upload a Python Package using Twine |
4 | 3 | # For more information see:
|
5 | 4 | # https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
|
6 | 5 |
|
|
10 | 9 | release:
|
11 | 10 | types: [created]
|
12 | 11 |
|
| 12 | + |
13 | 13 | jobs:
|
14 |
| - deploy: |
15 | 14 |
|
| 15 | + deploy: |
16 | 16 | runs-on: ubuntu-latest
|
17 | 17 |
|
18 | 18 | steps:
|
19 |
| - - uses: actions/checkout@v2 |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v3 |
| 21 | + with: |
| 22 | + ref: master |
20 | 23 | - name: Set up Python
|
21 |
| - uses: actions/setup-python@v2 |
| 24 | + uses: actions/setup-python@v4 |
22 | 25 | with:
|
23 |
| - python-version: 3.x |
| 26 | + python-version: '3.x' |
| 27 | + cache: pip |
24 | 28 | - name: Install dependencies
|
25 | 29 | run: |
|
26 |
| - python -m pip install --upgrade pip |
27 | 30 | pip install setuptools wheel twine
|
28 |
| - - name: Build and publish |
| 31 | + - name: get infos from Tag |
| 32 | + run: | |
| 33 | + if [[ $GITHUB_REF =~ (([0-9]+)\.([0-9]+)\.([0-9]+))([-./]dev([0-9]+))? ]] |
| 34 | + then |
| 35 | + echo "VERSION=${BASH_REMATCH[0]}" >> $GITHUB_ENV |
| 36 | + echo "VERSION_MAJOR=${BASH_REMATCH[2]}" >> $GITHUB_ENV |
| 37 | + echo "VERSION_MINOR=${BASH_REMATCH[3]}" >> $GITHUB_ENV |
| 38 | + echo "VERSION_PATCH=${BASH_REMATCH[4]}" >> $GITHUB_ENV |
| 39 | + echo "VERSION_DEV=${BASH_REMATCH[6]}" >> $GITHUB_ENV |
| 40 | + else |
| 41 | + echo "INVALID_TAG=True" >> $GITHUB_ENV |
| 42 | + fi |
| 43 | + - name: Fail on invalid Tag |
| 44 | + if: ${{ env.INVALID_TAG }} |
| 45 | + uses: actions/github-script@v6 |
| 46 | + with: |
| 47 | + script: core.setFailed('Invalid Tag name used with this release!') |
| 48 | + |
| 49 | + - name: Write Version to __init__ |
| 50 | + run: | |
| 51 | + sed -i "s/__version__ = .*/__version__ = '$VERSION'/" readchar/__init__.py |
| 52 | + - name: Build sdist and bdist_wheel |
| 53 | + run: | |
| 54 | + python setup.py sdist bdist_wheel |
| 55 | + - name: publish to PyPi |
29 | 56 | env:
|
30 | 57 | TWINE_USERNAME: __token__
|
31 | 58 | TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
32 | 59 | run: |
|
33 |
| - python setup.py sdist bdist_wheel |
34 | 60 | twine upload dist/*
|
| 61 | +
|
| 62 | + - name: increment development version |
| 63 | + if: ${{ env.VERSION_DEV }} |
| 64 | + run: | |
| 65 | + v=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH-dev$((VERSION_DEV+1)) |
| 66 | + sed -i "s/__version__ = .*/__version__ = \"$v\"/" readchar/__init__.py |
| 67 | + - name: increment patch version |
| 68 | + if: ${{ !env.VERSION_DEV }} |
| 69 | + run: | |
| 70 | + v=$VERSION_MAJOR.$VERSION_MINOR.$((VERSION_PATCH+1))-dev0 |
| 71 | + sed -i "s/__version__ = .*/__version__ = \"$v\"/" readchar/__init__.py |
| 72 | + - name: commit new version-number |
| 73 | + uses: stefanzweifel/git-auto-commit-action@v4 |
| 74 | + with: |
| 75 | + commit_message: "increment version after release" |
0 commit comments