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