diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..409053b --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,35 @@ +# This workflow will install Python dependencies and upload a version in the PyPI +name: CD - Upload PyPI + +on: + release: + types: [ released ] + +jobs: + upload: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + # Sets up python + - uses: actions/setup-python@v2 + with: + python-version: 3.7 + + # Install dependencies + - name: "Installs dependencies" + run: | + python3 -m pip install --upgrade pip + python3 -m pip install setuptools wheel twine + python3 setup.py install + + # Build and upload to PyPI + - name: "Builds and uploads to PyPI" + run: | + python3 setup.py sdist bdist_wheel + python3 -m twine check dist/* + python3 -m twine upload dist/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/cd_test_pypi.yml b/.github/workflows/cd_test_pypi.yml new file mode 100644 index 0000000..6ea2175 --- /dev/null +++ b/.github/workflows/cd_test_pypi.yml @@ -0,0 +1,40 @@ +# This workflow will install Python dependencies and upload a version in the PyPI test environment +name: CD - Test PyPI + +on: + push: + branches: [ master ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + # Sets up python + - uses: actions/setup-python@v2 + with: + python-version: 3.7 + + # Install dependencies + - name: "Installs and upgrades pip, installs other dependencies and installs the package from setup.py" + run: | + python3 -m pip install --upgrade pip + python3 -m pip install setuptools wheel twine + python3 setup.py install + + # Upload to TestPyPI + - name: Build and Upload to TestPyPI + run: | + python3 setup.py sdist bdist_wheel + python3 -m twine check dist/* + python3 -m twine upload dist/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} + TWINE_REPOSITORY: testpypi \ No newline at end of file diff --git a/.github/workflows/mercado-pago-package.yml b/.github/workflows/ci.yml similarity index 94% rename from .github/workflows/mercado-pago-package.yml rename to .github/workflows/ci.yml index c737f0b..114b492 100644 --- a/.github/workflows/mercado-pago-package.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,9 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: Python package +name: CI - Lint and Tests on: - push: - branches: - - 'master' pull_request: branches: - 'master' @@ -25,19 +22,23 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install requests + - name: Lint with Pylint run: | pip install pylint pylint mercadopago pylint --rcfile=tests/.pylintrc tests + - name: Lint with Isort run: | pip install isort isort . + - name: Test with unittest run: | python -m unittest discover tests/