Skip to content

Commit

Permalink
Merge pull request #1649 from priyanshuone6/sdist
Browse files Browse the repository at this point in the history
Build and publish python sdist on PyPI
  • Loading branch information
tlestang authored Sep 10, 2021
2 parents 3b5adbf + c8e66da commit 6dc1335
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/build_sdist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: "Build and publish python sdist"

on:
push:
branches: main
workflow_dispatch:
inputs:
target:
description: 'Deployment target. Can be "pypi" or "testpypi"'
default: 'pypi'

jobs:
build_sdist:
name: Build sdist
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: pip install wheel

- name: Build sdist
run: python setup.py sdist --formats=gztar,zip

- name: Upload sdist
uses: actions/upload-artifact@v2
with:
name: files
path: |
./dist/*.tar.gz
./dist/*.zip
if-no-files-found: error


publish-pypi:
name: Upload sdist to PyPI
needs: build_sdist
runs-on: ubuntu-latest
steps:
- name: Download sdist
uses: actions/download-artifact@v2
with:
name: files
path: sdist

- name: Publish sdist on PyPI
if: github.event.inputs.target == 'pypi'
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
packages_dir: sdist/

- name: Publish sdist on TestPyPI
if: github.event.inputs.target == 'testpypi'
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.TESTPYPI_TOKEN }}
packages_dir: sdist/
repository_url: https://test.pypi.org/legacy/

0 comments on commit 6dc1335

Please sign in to comment.