Additional multi-platform build #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
# Based on https://github.com/tuananh/py-event-ruler/blob/0129d15e17d0023863a4d0e0e25e5256988b5c5b/.github/workflows/publish.yml | |
on: | |
push: | |
branches: | |
- develop | |
- multi-platform-cibuildwheel | |
workflow_dispatch: | |
# on: | |
# # release: | |
# # types: [created] | |
# push: | |
# tags: | |
# - '*' | |
jobs: | |
build_macos: | |
# if: false | |
name: MacOS ${{ matrix.os_version }} 3${{ matrix.python3_version }} ${{ matrix.arch_cibw_go[0] }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os_version: [ 12 ] | |
python3_version: [ 11 ] | |
arch_cibw_go: | |
- [ "x86_64", "amd64" ] | |
- [ "arm64", "arm64" ] | |
runs-on: macos-${{ matrix.os_version }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: "1.22.x" | |
- name: copy setup.py | |
run: cp setup_ci.py setup.py | |
- name: install gopy | |
run: go install github.com/go-python/[email protected] | |
- name: install goimports | |
run: go install golang.org/x/tools/cmd/goimports@latest | |
- name: install python 3.${{ matrix.python3_version }} | |
run: | | |
brew install python@3.${{ matrix.python3_version }} | |
ln -s /usr/local/opt/python@3.${{ matrix.python3_version }}/bin/python3.${{ matrix.python3_version }} /usr/local/bin/python_for_build | |
/usr/local/bin/python_for_build --version | |
- name: install cibuildwheel and pybindgen | |
run: /usr/local/bin/python_for_build -m pip install cibuildwheel==2.19.2 pybindgen | |
- name: build wheels | |
run: /usr/local/bin/python_for_build -m cibuildwheel --output-dir wheelhouse | |
env: | |
CGO_ENABLED: 1 # build fails for arm if unset | |
CIBW_ARCHS: ${{ matrix.arch_cibw_go[0] }} | |
PYTHON_BINARY_PATH: /usr/local/bin/python_for_build | |
CIBW_BUILD: "cp3${{ matrix.python3_version }}-*" | |
CIBW_ENVIRONMENT: > | |
PATH=$PATH:/usr/local/go/bin | |
GOARCH=${{ matrix.arch_cibw_go[1] }} | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-macos${{ matrix.os_version }}-py3${{ matrix.python3_version }}-${{ matrix.arch_cibw_go[0] }} | |
path: ./wheelhouse/*.whl | |
build_linux_x86_64: | |
# if: false | |
name: Linux 311 x86_64 | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: copy setup.py | |
run: cp setup_ci.py setup.py | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_BUILD: "cp3*_x86_64" | |
CIBW_SKIP: "cp36-* cp37-* cp38-* cp39-* cp310-* *-musllinux_x86_64" | |
CIBW_ARCHS: "native" | |
CIBW_ENVIRONMENT: > | |
PATH=$PATH:/usr/local/go/bin | |
CIBW_BEFORE_ALL_LINUX: | | |
curl -o go.tar.gz https://dl.google.com/go/go1.22.5.linux-amd64.tar.gz | |
tar -C /usr/local -xzf go.tar.gz | |
go install github.com/go-python/[email protected] | |
go install golang.org/x/tools/cmd/goimports@latest | |
- name: Upload atifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-linux-amd64 | |
path: ./wheelhouse/*.whl | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-linux-arm | |
path: /tmp/output/*.whl | |
# build_windows: | |
# if: false # not working | |
# name: Windows 310,311 x86_64 | |
# runs-on: windows-2019 | |
# steps: | |
# - uses: actions/checkout@v3 | |
# - name: copy setup.py | |
# run: cp setup_ci.py setup.py | |
# - name: set up Go | |
# uses: actions/setup-go@v3 | |
# with: | |
# go-version: "1.22.x" | |
# - name: install gopy | |
# run: go install github.com/go-python/[email protected] | |
# - name: install goimports | |
# run: go install golang.org/x/tools/cmd/goimports@latest | |
# - name: Build wheels | |
# uses: pypa/[email protected] | |
# env: | |
# # CGO_ENABLED: 1 | |
# CIBW_BUILD: "cp3*" | |
# CIBW_SKIP: "cp36-* cp37-* cp38-* cp39-*" | |
# CIBW_ARCHS: "native" | |
# CIBW_ENVIRONMENT: > | |
# GOARCH=amd64 | |
# - name: Upload artifacts | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: wheels-windows-amd64 | |
# path: ./wheelhouse/*.whl | |
publish_pypi: | |
if: startsWith(github.ref, 'refs/tags/') | |
name: Publish PyPI | |
needs: [ build_linux_x86_64, build_macos ] | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/ohpygossh | |
steps: | |
- uses: actions/download-artifact@v4 | |
- name: Collect all wheels | |
run: | | |
ls -R | |
mkdir dist | |
for f in $(find . -type f -name '*.whl'); do mv ${f} dist; done; | |
ls -R dist | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: ./dist | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
print-hash: true |