minify-html/.github/workflows/python.yml

78 lines
2.0 KiB
YAML

name: Build and publish Python package
on:
create:
tags:
- 'v*'
repository_dispatch:
types: [wf-python]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python: [3.5, 3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}
architecture: 'x64'
- name: Set up Rust (macOS, Linux)
if: runner.os != 'Windows'
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Set up Rust (Windows)
if: runner.os == 'Windows'
uses: actions-rs/toolchain@v1
with:
toolchain: stable-gnu
profile: minimal
default: true
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '^1.14.0'
- name: Set up GCC (Windows)
if: runner.os == 'Windows'
run: .\.github\workflows\gcc.ps1
- name: Run prebuild steps
shell: bash
run: bash ./prebuild.sh
- name: Build native module
working-directory: ./python
run: cargo build --release
- name: Install Python build tools (macOS, Linux)
if: runner.os != 'Windows'
run: sudo pip install --upgrade maturin setuptools wheel twine
- name: Install Python build tools (Windows)
if: runner.os == 'Windows'
run: pip install --upgrade maturin setuptools wheel twine
- name: Pack and publish package
shell: bash
working-directory: ./python
run: |
cat << 'EOF' > "$HOME/.pypirc"
[pypi]
username = __token__
password = ${{ secrets.PYPI_API_TOKEN }}
EOF
maturin build --release --strip -i "$(which python)"
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
python -m twine upload target/wheels/*
fi