Merge pull request #65 from mosampaio/master #33
This file contains hidden or 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 and Deploy (master) | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| architecture: x64 | |
| - name: Lint code | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements-dev.txt | |
| # stop the build if there are Python syntax errors or undefined names | |
| flake8 . --count --show-source --statistics | |
| mypy semversioner tests | |
| - name: Build and test | |
| run: | | |
| pytest --junitxml=junit/test-results-${{ matrix.python-version }}.xml | |
| - name: Upload pytest test results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pytest-results-${{ matrix.python-version }} | |
| path: junit/test-results-${{ matrix.python-version }}.xml | |
| # Use always() to always run this step to publish test results when there are test failures | |
| if: ${{ always() }} | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.8' | |
| - name: Publish | |
| env: | |
| TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
| TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
| run: | | |
| pip install twine==6.1.0 | |
| pip install wheel==0.45.1 | |
| pip install semversioner==2.0.3 | |
| previous_version=$(semversioner current-version) | |
| semversioner release | |
| new_version=$(semversioner current-version) | |
| semversioner changelog > CHANGELOG.md | |
| echo "Replace version '$previous_version' to '$new_version' in __version__.py ..." | |
| echo "__version__ = '$new_version'" > semversioner/__version__.py | |
| python setup.py sdist bdist_wheel | |
| twine upload dist/* | |
| git config --global user.name 'Semversioner Bot' | |
| git config --global user.email 'semversioner@users.noreply.github.com' | |
| git add . | |
| git commit -m "Update files for new version '${new_version}' [skip ci]" | |
| git push origin master | |
| git tag -a -m "Tagging for release ${new_version}" "${new_version}" | |
| git push origin ${new_version} |