Merge pull request #21 from paveldat/dev/pdat #59
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: Build, Test, Deploy | |
on: [push] | |
jobs: | |
info: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Print node info | |
run: | | |
cat /etc/os-release | |
build: | |
runs-on: ubuntu-latest | |
needs: info | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build package | |
run: | | |
python -m build . | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: built-artifacts | |
path: dist | |
retention-days: 1 | |
test: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
sudo apt install pycodestyle pylint | |
pip install -r py-requirements.txt | |
pip install pytest | |
- name: Analysing the code with pycodestyle | |
run: | | |
pycodestyle src/**/*.py | |
- name: Analysing the code with pylint | |
run: | | |
pylint src/**/*.py | |
- name: Run Module tests | |
run: | | |
python3 -m pytest -sr tests/test_c*.py | |
deploy: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
needs: test | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: built-artifacts | |
path: dist | |
- name: Publish package to Test PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository-url: https://test.pypi.org/legacy/ | |
- name: Publish package to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
release: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
needs: deploy | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: built-artifacts | |
path: dist | |
- name: Set version release | |
run: | | |
VER="$(cat setup.cfg | grep version | cut -d '=' -f 2 | xargs)" | |
{ | |
echo 'COMMIT_MESSAGE<<EOF' | |
git log -1 --pretty=%B | |
echo EOF | |
} | |
echo "RELEASE_VERSION=$VER" >> $GITHUB_ENV | |
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV | |
- name: Create release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: dist/* | |
tag: ${{ env.RELEASE_VERSION }} | |
body: ${{ env.COMMIT_MESSAGE }} | |
release_name: v${{ env.RELEASE_VERSION }} | |
overwrite: true | |
file_glob: true |