|
| 1 | +name: CI |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + tags: |
| 7 | + - v[0-9]+.[0-9]+.[0-9]+* |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - master |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v3 |
| 17 | + - name: Set up Python 3 |
| 18 | + uses: actions/setup-python@v3 |
| 19 | + with: |
| 20 | + python-version: "3.10" |
| 21 | + - name: Install dependencies |
| 22 | + run: | |
| 23 | + python -m pip install --upgrade pip |
| 24 | + pip install build |
| 25 | + python -m build |
| 26 | + python -m pip install --upgrade twine |
| 27 | + python -m twine check dist/* |
| 28 | + |
| 29 | + - name: 'Upload Artifact' |
| 30 | + uses: actions/upload-artifact@v2 |
| 31 | + with: |
| 32 | + name: dist |
| 33 | + path: dist/ |
| 34 | + test: |
| 35 | + name: Test Coverage |
| 36 | + needs: build |
| 37 | + runs-on: ubuntu-latest |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v3 |
| 40 | + - name: Set up Python 3 |
| 41 | + uses: actions/setup-python@v3 |
| 42 | + with: |
| 43 | + python-version: "3.10" |
| 44 | + - name: Install dependencies |
| 45 | + run: | |
| 46 | + python -m pip install --upgrade pip |
| 47 | + pip install responses |
| 48 | + pip install coverage |
| 49 | + python ${{ github.workspace }}/setup.py install |
| 50 | + - name: Run Tests |
| 51 | + run: | |
| 52 | + python -m coverage run -m unittest |
| 53 | + python -m coverage xml |
| 54 | + - name: Upload coverage to Codecov |
| 55 | + uses: codecov/codecov-action@v3 |
| 56 | + |
| 57 | + publish: |
| 58 | + if: startsWith(github.ref, 'refs/tags/v') |
| 59 | + needs: test |
| 60 | + runs-on: ubuntu-latest |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v2 |
| 63 | + - name: Download all workflow run artifacts |
| 64 | + uses: actions/download-artifact@v2 |
| 65 | + with: |
| 66 | + name: dist |
| 67 | + path: dist |
| 68 | + - name: Set up Python 3 |
| 69 | + uses: actions/setup-python@v3 |
| 70 | + with: |
| 71 | + python-version: "3.10" |
| 72 | + - name: Publish packages to PyPi |
| 73 | + run: | |
| 74 | + python -m pip install --upgrade twine |
| 75 | + set -ex |
| 76 | + export VERSION=$(python3 setup.py --version) |
| 77 | + python -m twine upload --verbose dist/razorpay-$VERSION-py3-none-any.whl dist/razorpay-$VERSION.tar.gz |
| 78 | + env: |
| 79 | + TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} |
| 80 | + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} |
| 81 | + |
0 commit comments