Skip to content

Merge pull request #192 from Luos-io/rc_3.0.0 #96

Merge pull request #192 from Luos-io/rc_3.0.0

Merge pull request #192 from Luos-io/rc_3.0.0 #96

Workflow file for this run

name: Test and Upload Python Package dev mode
on:
# Trigger the workflow on push,
# but only for the master branch
push:
branches:
- master
jobs:
test:
name: run tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.x' ]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools
- name: test execution
run: |
pip install -e ./
pip install -e ./[tests]
pytest
publish:
name: publish a new dev revision
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: upload
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
# Get the online last revision
last_rev=$(pip install pyluos== 2>&1 | grep ')' | awk 'NF{print substr($NF, 1, length($NF)-1)}')
# Get the local last revision
local_rev=$(cat pyluos/version.py | awk 'NF{print substr($NF, 1, length($NF)-1)}')
local_rev="${local_rev:1}"
# if local and remote revision are same increase rev of last_rev
if [[ $last_rev == $local_rev ]]; then
# get bug fix rev and increase it
bugfix_rev=$(expr $(cut -d. -f3 <<< "$last_rev")+1 | bc)
tmp=$(cut -d. -f-2 <<< "$last_rev")
last_rev=${tmp}.${bugfix_rev}
fi
pre_rev_nb=1
if [[ $last_rev == *b* ]]; then
# get pre rev number and increment it
pre_rev_nb=$(expr $(cut -d "b" -f 2 <<< "$last_rev")+1 | bc)
# remove pre rev number
last_rev=$(cut -db -f1 <<< "$last_rev")
fi
# put dev revision after last_rev
revision=${last_rev}.b${pre_rev_nb}
# save it into version file
echo version = \'$revision\' > pyluos/version.py
python setup.py sdist bdist_wheel
twine upload dist/*