|
| 1 | +name: cicd |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - "*" |
| 9 | + pull_request: |
| 10 | + |
| 11 | +jobs: |
| 12 | + code-scan: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: read |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Set up Python ${{ matrix.python-version }} |
| 24 | + uses: actions/setup-python@v5 |
| 25 | + with: |
| 26 | + python-version: ${{ matrix.python-version }} |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: pip install --no-cache-dir -U pip black flake8 bandit |
| 30 | + |
| 31 | + - name: Lint with flake8 |
| 32 | + run: flake8 pyproxy tests benchmark |
| 33 | + |
| 34 | + - name: Check with black |
| 35 | + run: black --check pyproxy tests benchmark |
| 36 | + |
| 37 | + - name: Check with bandit |
| 38 | + run: bandit -r pyproxy tests benchmark |
| 39 | + |
| 40 | + unittest: |
| 41 | + needs: code-scan |
| 42 | + runs-on: ubuntu-latest |
| 43 | + permissions: |
| 44 | + contents: read |
| 45 | + |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Set up Python |
| 50 | + uses: actions/setup-python@v5 |
| 51 | + with: |
| 52 | + python-version: 3.13 |
| 53 | + |
| 54 | + - name: Install build dependencies |
| 55 | + run: pip install --no-cache-dir -r requirements.txt |
| 56 | + |
| 57 | + - name: Run tests |
| 58 | + run: python -m unittest discover -s tests |
| 59 | + |
| 60 | + build-packages: |
| 61 | + needs: unittest |
| 62 | + if: github.event_name == 'push' |
| 63 | + runs-on: ubuntu-latest |
| 64 | + permissions: |
| 65 | + contents: write |
| 66 | + id-token: write |
| 67 | + |
| 68 | + steps: |
| 69 | + - uses: actions/checkout@v4 |
| 70 | + |
| 71 | + - name: Set up Python |
| 72 | + uses: actions/setup-python@v5 |
| 73 | + with: |
| 74 | + python-version: 3.13 |
| 75 | + |
| 76 | + - name: Get version |
| 77 | + id: get_version |
| 78 | + run: | |
| 79 | + version=$(grep '^__version__' pyproxy_sdk/__init__.py | cut -d'"' -f2) |
| 80 | + echo "version=${version}" >> $GITHUB_OUTPUT |
| 81 | +
|
| 82 | + - name: Create Tag |
| 83 | + run: | |
| 84 | + git config user.name "github-actions[bot]" |
| 85 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 86 | + git tag v${{ steps.get_version.outputs.version }} |
| 87 | + git push origin v${{ steps.get_version.outputs.version }} |
| 88 | +
|
| 89 | + - name: Create GitHub Release |
| 90 | + id: create_release |
| 91 | + uses: actions/create-release@v1 |
| 92 | + with: |
| 93 | + tag_name: v${{ steps.get_version.outputs.version }} |
| 94 | + release_name: Release v${{ steps.get_version.outputs.version }} |
| 95 | + draft: false |
| 96 | + prerelease: false |
| 97 | + env: |
| 98 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 99 | + |
| 100 | + - name: Install build dependencies |
| 101 | + run: pip install --no-cache-dir -U pip . build |
| 102 | + |
| 103 | + - name: Build package |
| 104 | + run: python -m build --sdist --wheel |
| 105 | + - name: Upload built distributions |
| 106 | + uses: actions/upload-artifact@v4 |
| 107 | + with: |
| 108 | + name: dist |
| 109 | + path: dist |
| 110 | + |
| 111 | + - name: Install release dependencies |
| 112 | + run: pip install --no-cache-dir -U pip . twine packaging |
| 113 | + |
| 114 | + - name: Upload to PyPI |
| 115 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments