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

71 lines
1.8 KiB
YAML
Raw Normal View History

name: Build and publish Python package
on:
2021-08-05 22:22:24 -04:00
push:
tags:
- 'v*'
2021-08-05 22:22:24 -04:00
workflow_dispatch:
jobs:
build:
2021-08-07 11:48:52 -04:00
runs-on: ${{ matrix.os }}
strategy:
matrix:
2021-04-06 04:41:56 -04:00
feature: [core, js]
2021-04-06 05:02:01 -04:00
os: [macos-11.0, ubuntu-18.04, windows-2019]
python: [3.7, 3.8, 3.9, 3.10]
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
- name: Set up Rust
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
- name: Set up GCC (Windows)
if: runner.os == 'Windows'
run: .\.github\workflows\gcc.ps1
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '^1.14.0'
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
2021-04-06 04:41:56 -04:00
run: |
2021-04-07 06:50:05 -04:00
python prepare.py ${{ matrix.feature }}
2021-04-06 04:41:56 -04:00
cargo build --release
2020-07-11 10:47:17 -04:00
- name: Install Python build tools (macOS)
if: runner.os == 'macOS'
run: sudo pip install --upgrade maturin==0.9.4 setuptools wheel twine
- name: Install Python build tools (Linux, Windows)
if: runner.os != 'macOS'
run: pip install --upgrade maturin==0.9.4 setuptools wheel twine
2020-07-11 10:47:17 -04:00
- 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