Skip to content

Commit

Permalink
Github Action workflow to build ans publish packages on PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
flozz committed Jun 11, 2021
1 parent 41c29e5 commit 0fbc8e5
Showing 1 changed file with 123 additions and 0 deletions.
123 changes: 123 additions & 0 deletions .github/workflows/python-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: "Build and Publish Python Packages"

on:
push:
tags: "v[0-9]+.[0-9]+.[0-9]+"

jobs:

build_sdist:

name: "Source distribution"
runs-on: ubuntu-latest

steps:

- name: "Checkout the repository"
uses: actions/checkout@v2
with:
submodules: true

- name: "Set up Python"
uses: actions/setup-python@v1
with:
python-version: 3.9

- name: "Build source distribution"
run: |
python setup.py sdist
- name: "Upload artifacts"
uses: actions/upload-artifact@v2
with:
name: yoga-image-optimizer-sdist
path: dist/
retention-days: 1

build_wheel_linux:

strategy:
matrix:
python-version: [cp37-cp37m, cp38-cp38, cp39-cp39]

name: "Wheel for ${{ matrix.python-version }} manylinux2010"
runs-on: ubuntu-latest

steps:

- name: "Checkout the repository"
uses: actions/checkout@v2

- name: "Build Python Wheel for Linux (manylinux2010)"
uses: RalfG/[email protected]_x86_64
with:
python-versions: ${{ matrix.python-version }}
build-requirements: cffi>=1.0.0

- name: "Upload artifacts"
uses: actions/upload-artifact@v2
with:
name: yoga-image-optimizer-wheel-linux
path: dist/*manylinux*.whl
retention-days: 1

build_wheel_windows:

strategy:
matrix:
python-version: [3.7, 3.8, 3.9]

name: "Wheel for py${{ matrix.python-version }} win amd64"
runs-on: windows-latest

steps:

- name: "Checkout the repository"
uses: actions/checkout@v2
with:
submodules: true

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

- name: "Install Python dependencies"
run: |
pip install wheel
- name: "Build Python Wheel"
run: |
python setup.py bdist_wheel
- name: "Upload artifacts"
uses: actions/upload-artifact@v2
with:
name: yoga-image-optimizer-wheel-windows
path: dist/
retention-days: 1

publish_pypi:

name: "Publish packages on PyPI"
runs-on: ubuntu-latest
needs:
- build_sdist
- build_wheel_linux
- build_wheel_windows

steps:

- name: "Download artifacts"
uses: actions/download-artifact@v2

- name: "Move packages to the dist/ folder"
run: |
mkdir dist/
mv yoga-image-optimizer-sdist/* dist/
mv yoga-image-optimizer-wheel-*/*.whl dist/
- name: "Publish packages on PyPI"
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}

0 comments on commit 0fbc8e5

Please sign in to comment.