|
| 1 | +name: Test, Build, Release, Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - main |
| 8 | + |
| 9 | +jobs: |
| 10 | + test_and_build: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + python-version: ["3.x"] |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@master |
| 17 | + |
| 18 | + - name: Set up Python ${{ matrix.python-version }} |
| 19 | + uses: actions/setup-python@master |
| 20 | + with: |
| 21 | + python-version: ${{ matrix.python-version }} |
| 22 | + |
| 23 | + - name: Install Poetry |
| 24 | + run: | |
| 25 | + python -m pip install --upgrade pip setuptools wheel |
| 26 | + python -m pip install poetry |
| 27 | +
|
| 28 | + - name: Install poetry dependencies |
| 29 | + run: | |
| 30 | + python -m poetry update --with test |
| 31 | +
|
| 32 | + - name: Run tests |
| 33 | + run: | |
| 34 | + python -m poetry run coverage run --omit=./tests/* -m pytest -v |
| 35 | +
|
| 36 | + - name: Generate Coverage Report |
| 37 | + run: | |
| 38 | + python -m poetry run coverage report |
| 39 | + python -m poetry run coverage xml |
| 40 | +
|
| 41 | + - name: Upload coverage reports to Codecov |
| 42 | + uses: codecov/codecov-action@v5 |
| 43 | + with: |
| 44 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 45 | + slug: ddc/pythonLogs |
| 46 | + |
| 47 | + - name: Build package |
| 48 | + run: | |
| 49 | + python -m poetry build |
| 50 | +
|
| 51 | + - name: Store the distribution packages to publish to pypi |
| 52 | + uses: actions/upload-artifact@master |
| 53 | + with: |
| 54 | + name: python-package-distributions |
| 55 | + path: dist/ |
| 56 | + |
| 57 | + release: |
| 58 | + runs-on: ubuntu-latest |
| 59 | + needs: |
| 60 | + - test_and_build |
| 61 | + env: |
| 62 | + GITHUB_TOKEN: ${{ github.token }} |
| 63 | + steps: |
| 64 | + - id: release |
| 65 | + uses: rymndhng/release-on-push-action@master |
| 66 | + with: |
| 67 | + bump_version_scheme: patch # major | minor | patch |
| 68 | + tag_prefix: v |
| 69 | + release_name: "Version <RELEASE_VERSION>" |
| 70 | + release_body: ${{ steps.release.outputs.tag_name }} |
| 71 | + |
| 72 | + - name: Check Output Parameters |
| 73 | + run: | |
| 74 | + echo "Got tag name ${{ steps.release.outputs.tag_name }}" |
| 75 | + echo "Got release version ${{ steps.release.outputs.version }}" |
| 76 | + echo "Upload release artifacts to ${{ steps.release.outputs.upload_url }}" |
| 77 | +
|
| 78 | + publish-to-test-pypi: |
| 79 | + runs-on: ubuntu-latest |
| 80 | + environment: release |
| 81 | + needs: |
| 82 | + - release |
| 83 | + permissions: |
| 84 | + id-token: write |
| 85 | + steps: |
| 86 | + - name: Download all the dists |
| 87 | + uses: actions/download-artifact@master |
| 88 | + with: |
| 89 | + name: python-package-distributions |
| 90 | + path: dist/ |
| 91 | + - name: Publish distribution to TestPyPI |
| 92 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 93 | + with: |
| 94 | + repository-url: https://test.pypi.org/legacy/ |
| 95 | + |
| 96 | + publish-to-pypi: |
| 97 | + runs-on: ubuntu-latest |
| 98 | + environment: release |
| 99 | + needs: |
| 100 | + - release |
| 101 | + permissions: |
| 102 | + id-token: write |
| 103 | + steps: |
| 104 | + - name: Download all the dists |
| 105 | + uses: actions/download-artifact@master |
| 106 | + with: |
| 107 | + name: python-package-distributions |
| 108 | + path: dist/ |
| 109 | + - name: Publish distribution to PyPI |
| 110 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments