diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..de5afd47 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,81 @@ +name: CI +on: + push: + branches: + - master + tags: + - v[0-9]+.[0-9]+.[0-9]+* + pull_request: + branches: + - master +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + python -m build + python -m pip install --upgrade twine + python -m twine check dist/* + + - name: 'Upload Artifact' + uses: actions/upload-artifact@v2 + with: + name: dist + path: dist/ + test: + name: Test Coverage + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install responses + pip install coverage + python ${{ github.workspace }}/setup.py install + - name: Run Tests + run: | + python -m coverage run -m unittest + python -m coverage xml + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + + publish: + if: startsWith(github.ref, 'refs/tags/v') + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Download all workflow run artifacts + uses: actions/download-artifact@v2 + with: + name: dist + path: dist + - name: Set up Python 3 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Publish packages to PyPi + run: | + python -m pip install --upgrade twine + set -ex + export VERSION=$(python3 setup.py --version) + python -m twine upload --verbose dist/razorpay-$VERSION-py3-none-any.whl dist/razorpay-$VERSION.tar.gz + env: + TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} +