|
1 | | -name: Test, Build, Release, Publish |
| 1 | +name: CI/CD Pipeline |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: |
6 | | - - master |
7 | | - - main |
| 5 | + branches: [main, master] |
| 6 | + tags: ['v*'] |
| 7 | + pull_request: |
| 8 | + branches: [main, master] |
8 | 9 |
|
9 | 10 | jobs: |
10 | | - test_and_build: |
| 11 | + test: |
| 12 | + name: Test Python ${{ matrix.python-version }} |
11 | 13 | runs-on: ubuntu-latest |
12 | 14 | strategy: |
| 15 | + fail-fast: false |
13 | 16 | matrix: |
14 | | - python-version: ["3.x"] |
| 17 | + python-version: ["3.10", "3.11", "3.12", "3.13"] |
15 | 18 | steps: |
16 | | - - uses: actions/checkout@master |
| 19 | + - uses: actions/checkout@v4 |
17 | 20 |
|
18 | 21 | - name: Set up Python ${{ matrix.python-version }} |
19 | | - uses: actions/setup-python@master |
| 22 | + uses: actions/setup-python@v5 |
20 | 23 | with: |
21 | 24 | python-version: ${{ matrix.python-version }} |
| 25 | + cache: 'poetry' |
22 | 26 |
|
23 | 27 | - name: Install Poetry |
24 | | - run: | |
25 | | - python -m pip install --upgrade pip setuptools wheel |
26 | | - python -m pip install poetry |
| 28 | + uses: snok/install-poetry@v1 |
| 29 | + with: |
| 30 | + virtualenvs-create: true |
| 31 | + virtualenvs-in-project: true |
27 | 32 |
|
28 | | - - name: Install poetry dependencies |
29 | | - run: | |
30 | | - python -m poetry update --with test |
| 33 | + - name: Install dependencies |
| 34 | + run: poetry install --with test --no-interaction --no-ansi |
31 | 35 |
|
32 | | - - name: Run tests |
33 | | - run: | |
34 | | - python -m poetry run coverage run --omit=./tests/* -m pytest -v |
| 36 | + - name: Run tests with coverage |
| 37 | + run: poetry run poe tests |
35 | 38 |
|
36 | | - - name: Generate Coverage Report |
37 | | - run: | |
38 | | - python -m poetry run coverage report |
39 | | - python -m poetry run coverage xml |
| 39 | + - name: Upload coverage to Codecov |
| 40 | + if: matrix.python-version == '3.13' |
| 41 | + uses: codecov/codecov-action@v4 |
| 42 | + with: |
| 43 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 44 | + file: ./coverage.xml |
| 45 | + flags: unittests |
| 46 | + name: coverage-py${{ matrix.python-version }} |
40 | 47 |
|
41 | | - - name: Upload coverage reports to Codecov |
42 | | - uses: codecov/codecov-action@v5 |
| 48 | + build: |
| 49 | + name: Build Package |
| 50 | + runs-on: ubuntu-latest |
| 51 | + needs: test |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v4 |
| 54 | + |
| 55 | + - name: Set up Python |
| 56 | + uses: actions/setup-python@v5 |
43 | 57 | with: |
44 | | - token: ${{ secrets.CODECOV_TOKEN }} |
45 | | - slug: ddc/pythonLogs |
| 58 | + python-version: '3.13' |
| 59 | + cache: 'poetry' |
| 60 | + |
| 61 | + - name: Install Poetry |
| 62 | + uses: snok/install-poetry@v1 |
| 63 | + with: |
| 64 | + virtualenvs-create: true |
| 65 | + virtualenvs-in-project: true |
| 66 | + |
| 67 | + - name: Install build dependencies only |
| 68 | + run: poetry install --only main --no-interaction --no-ansi |
46 | 69 |
|
47 | 70 | - name: Build package |
48 | | - run: | |
49 | | - python -m poetry build |
| 71 | + run: poetry build |
50 | 72 |
|
51 | | - - name: Store the distribution packages to publish to pypi |
52 | | - uses: actions/upload-artifact@master |
| 73 | + - name: Upload artifacts |
| 74 | + uses: actions/upload-artifact@v4 |
53 | 75 | with: |
54 | | - name: python-package-distributions |
| 76 | + name: python-package |
55 | 77 | path: dist/ |
| 78 | + retention-days: 7 |
56 | 79 |
|
57 | 80 | release: |
| 81 | + name: Create Release |
58 | 82 | runs-on: ubuntu-latest |
59 | | - needs: |
60 | | - - test_and_build |
61 | | - env: |
62 | | - GITHUB_TOKEN: ${{ github.token }} |
| 83 | + needs: build |
| 84 | + if: startsWith(github.ref, 'refs/tags/v') |
63 | 85 | permissions: |
64 | 86 | contents: write |
65 | | - pull-requests: read |
66 | 87 | steps: |
67 | | - - id: release |
68 | | - uses: rymndhng/release-on-push-action@master |
| 88 | + - uses: actions/checkout@v4 |
| 89 | + |
| 90 | + - name: Download package artifacts |
| 91 | + uses: actions/download-artifact@v4 |
69 | 92 | with: |
70 | | - bump_version_scheme: patch # major | minor | patch |
71 | | - tag_prefix: v |
72 | | - release_name: "Version <RELEASE_VERSION>" |
73 | | - release_body: ${{ steps.release.outputs.tag_name }} |
74 | | - |
75 | | - - name: Check Output Parameters |
76 | | - run: | |
77 | | - echo "Got tag name ${{ steps.release.outputs.tag_name }}" |
78 | | - echo "Got release version ${{ steps.release.outputs.version }}" |
79 | | - echo "Upload release artifacts to ${{ steps.release.outputs.upload_url }}" |
80 | | -
|
81 | | - publish-to-test-pypi: |
| 93 | + name: python-package |
| 94 | + path: dist |
| 95 | + |
| 96 | + - name: Create Release |
| 97 | + uses: softprops/action-gh-release@v2 |
| 98 | + with: |
| 99 | + name: Release ${{ github.ref_name }} |
| 100 | + body: Automated release for version ${{ github.ref_name }} |
| 101 | + draft: false |
| 102 | + prerelease: false |
| 103 | + files: | |
| 104 | + dist/*.whl |
| 105 | + dist/*.tar.gz |
| 106 | +
|
| 107 | + publish: |
| 108 | + name: Publish to PyPI |
82 | 109 | runs-on: ubuntu-latest |
| 110 | + needs: release |
| 111 | + if: startsWith(github.ref, 'refs/tags/v') |
83 | 112 | environment: release |
84 | | - needs: |
85 | | - - release |
86 | 113 | permissions: |
87 | 114 | id-token: write |
88 | 115 | steps: |
89 | | - - name: Download all the dists |
90 | | - uses: actions/download-artifact@master |
| 116 | + - name: Download package artifacts |
| 117 | + uses: actions/download-artifact@v4 |
91 | 118 | with: |
92 | | - name: python-package-distributions |
93 | | - path: dist/ |
94 | | - - name: Publish distribution to TestPyPI |
| 119 | + name: python-package |
| 120 | + path: dist |
| 121 | + |
| 122 | + - name: Install twine |
| 123 | + run: pip install twine |
| 124 | + |
| 125 | + - name: Verify package |
| 126 | + run: twine check dist/* |
| 127 | + |
| 128 | + - name: Publish to TestPyPI |
95 | 129 | uses: pypa/gh-action-pypi-publish@release/v1 |
96 | 130 | with: |
97 | 131 | repository-url: https://test.pypi.org/legacy/ |
| 132 | + skip-existing: true |
| 133 | + verbose: true |
98 | 134 |
|
99 | | - publish-to-pypi: |
100 | | - runs-on: ubuntu-latest |
101 | | - environment: release |
102 | | - needs: |
103 | | - - release |
104 | | - permissions: |
105 | | - id-token: write |
106 | | - steps: |
107 | | - - name: Download all the dists |
108 | | - uses: actions/download-artifact@master |
109 | | - with: |
110 | | - name: python-package-distributions |
111 | | - path: dist/ |
112 | | - - name: Publish distribution to PyPI |
| 135 | + - name: Publish to PyPI |
113 | 136 | uses: pypa/gh-action-pypi-publish@release/v1 |
| 137 | + with: |
| 138 | + skip-existing: true |
| 139 | + verbose: true |
0 commit comments