From 125ed5b2601f0e74ded03b666132e3c37ae8af07 Mon Sep 17 00:00:00 2001 From: Cooper Lees Date: Thu, 1 Apr 2021 09:41:55 -0700 Subject: [PATCH] Add a GitHub Action to build + Upload black to PyPI (#1848) * Add a GitHub Action to build + Upload black to PyPI - Build a wheel + sdist - Upload via twine using token stored in GitHub secrets --- .github/workflows/lint.yml | 7 ++----- .github/workflows/pypi_upload.yml | 31 +++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 2 +- 3 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/pypi_upload.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e01e9ad..c46042d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,17 +12,14 @@ jobs: github.repository runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.7] steps: - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python-version }} + python-version: 3.7 - name: Install dependencies run: | diff --git a/.github/workflows/pypi_upload.yml b/.github/workflows/pypi_upload.yml new file mode 100644 index 0000000..5df91d9 --- /dev/null +++ b/.github/workflows/pypi_upload.yml @@ -0,0 +1,31 @@ +name: pypi_upload + +on: + release: + types: created + +jobs: + build: + name: PyPI Upload + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + + - name: Install latest pip, setuptools, twine + wheel + run: | + python -m pip install --upgrade pip setuptools twine wheel + + - name: Build wheels + run: | + python setup.py bdist_wheel + python setup.py sdist + + - name: Upload to PyPI via Twine + env: + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + run: | + twine upload --verbose -u '__token__' dist/* diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 292ed57..48a7429 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: types_or: [python, pyi] - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.1 + rev: 3.8.4 hooks: - id: flake8 additional_dependencies: [flake8-bugbear] -- 2.39.5