Skip to content

Commit

Permalink
Add publish job to github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mrecachinas committed Aug 29, 2021
1 parent 8d1eed7 commit 68b7299
Showing 1 changed file with 50 additions and 11 deletions.
61 changes: 50 additions & 11 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ on:
- .github/workflows/pythonpackage.yml

jobs:
build:

build-and-test:
runs-on: ${{ matrix.platform }}
strategy:
matrix:
Expand All @@ -21,21 +20,61 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
- name: 🐍 Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Choco Install vcpython27
uses: crazy-max/ghaction-chocolatey@v1
if: matrix.python-version == '2.7' && matrix.platform == 'windows-latest'
with:
args: install vcpython27
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Build Hexhamming Python C extension
- name: 🛠 Build Hexhamming Python C extension
run: python setup.py install
- name: Test with pytest
run: |
pytest
run: pytest
build-wheels:
needs: build-and-test
if: startsWith(github.ref, 'refs/tags')
runs-on: ${{ matrix.platform }}
strategy:
matrix:
python-version: ['3.9']
platform: [ubuntu-latest, macos-latest, windows-latest]

steps:
- name: 🐍 Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install build package
run: python -m pip install build
- name: 🛠 Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/ .
- name: Upload wheels for next job
uses: actions/upload-artifact@master
with:
name: wheels
path: dist

publish-wheels:
needs: build-wheels
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9']

steps:
- name: 🐍 Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Download wheels from previous job
uses: actions/download-artifact@master
with:
name: wheels
path: dist
- name: Install twine
run: python -m pip install twine
- name: 📦 Publish distribution to PyPI
run: twine upload -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} dist/

0 comments on commit 68b7299

Please sign in to comment.