From 8828d6bf790f229b36f574dfdb84f5b66b73d8bd Mon Sep 17 00:00:00 2001 From: Abhinand C <44578852+abhinand-c@users.noreply.github.com> Date: Sat, 9 Dec 2023 15:40:23 +0530 Subject: [PATCH] feat(CI/CD): Add GitHub Action workflow to publish to PyPI (#224) * feat(CI/CD): Add GitHub Action workflow to publish to PyPI * fix: Used isinstance instead of type() to validate type instance * feat: Use PyPI Trusted Publisher --- .github/workflows/publish.yml | 61 +++++++++++++++++++++++++++++++++++ .travis.yml | 13 -------- 2 files changed, 61 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/publish.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..a62b5e15 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,61 @@ +name: Publish to PyPI + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + build: + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python: ["3.7", "3.8", "3.9", "3.10", "3.11"] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python }} + - name: Lint with flake8 + run: | + python -m pip install flake8 + flake8 graphene_mongo --count --show-source --statistics + - name: Install dependencies + run: | + python -m pip install poetry + poetry config virtualenvs.create false + poetry install --with dev + - name: Run Tests + run: make test + - name: Build Package + run: | + poetry build + + publish: + needs: build + runs-on: ubuntu-latest + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install poetry + - name: Build package + run: | + poetry build + - name: Build package + run: | + poetry build + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 72d6825d..00000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: python -python: - - "2.7" - - "3.4" - - "3.5" - - "3.6" - - "3.8" -install: - pip install -r requirements.txt -script: make test -after_success: - - coveralls -