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) if: runner.os == 'macOS' run: sudo pip install --upgrade maturin setuptools wheel twine - name: Install Python build tools (Linux, Windows) if: runner.os != 'macOS' 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 twine upload target/wheels/* fi