Merge pull request #138 from engineervix/refactor/2024-07 #243
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: Continuous Integration | |
env: | |
TERM: screen-256color | |
on: | |
pull_request: | |
branches: ["master", "main"] | |
paths-ignore: ["docs/**"] | |
push: | |
branches: ["master", "main"] | |
paths-ignore: ["docs/**"] | |
tags: | |
- "v*" | |
jobs: | |
# Runs all steps on the VM | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-22.04, macos-14, windows-2022] | |
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] | |
steps: | |
- name: Checkout Code Repository | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install tox tox-gh-actions | |
pip install codecov | |
- name: "Run tox targets for Python ${{ matrix.python-version }} on ${{ matrix.os }}" | |
run: | | |
tox | |
- name: Upload Coverage to Codecov | |
uses: "codecov/codecov-action@v2" | |
with: | |
fail_ci_if_error: true | |
# Runs all steps on the VM | |
# Deploy to PyPI & create a GitHub Release when the test job succeeds, and only on pushes to tags. | |
deploy: | |
needs: test | |
if: needs.test.result == 'success' && startsWith( github.ref, 'refs/tags/v' ) | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout Code Repository | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements_dev.txt | |
- name: Build Package | |
run: | | |
invoke dist | |
# - name: Publish 🐍 distribution 📦 to Test PyPI | |
# uses: pypa/gh-action-pypi-publish@release/v1 | |
# with: | |
# user: __token__ | |
# password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
# repository_url: https://test.pypi.org/legacy/ | |
- name: Publish 🐍 distribution 📦 to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
verbose: true | |
- name: Get the version | |
id: get_version | |
run: | | |
echo "${{ github.ref }}" | |
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | |
- name: Generate Release Title | |
id: get_release_title | |
shell: bash | |
run: | | |
export TODAY="($(TZ=Africa/Lusaka date --iso))" | |
echo ::set-output name=RELEASE_NAME::"${{ steps.get_version.outputs.VERSION }} $TODAY" | |
- name: Extract Release Notes | |
# This creates a file LATEST_RELEASE_NOTES.md in the parent directory (../) | |
run: | | |
invoke get-release-notes | |
- name: GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: ${{ steps.get_release_title.outputs.RELEASE_NAME }} | |
body_path: ../LATEST_RELEASE_NOTES.md | |
files: dist/* |