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

78 lines
2.0 KiB
YAML
Raw Normal View History

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