Merge pull request #30 from b-long/feature/add-aarch64-linux-redux #56
Workflow file for this run
This file contains hidden or 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: TestPyPIBuild | ||
| # Based on https://github.com/tuananh/py-event-ruler/blob/0129d15e17d0023863a4d0e0e25e5256988b5c5b/.github/workflows/publish.yml | ||
| on: | ||
| push: | ||
| branches: | ||
| - develop | ||
| workflow_dispatch: | ||
| jobs: | ||
| build_macos: | ||
| # if: false | ||
| name: MacOS ${{ matrix.os_version }} Python 3${{ matrix.python3_version }} ${{ matrix.arch_cibw_go[0] }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os_version: [ 13 ] | ||
| python3_version: [ 11, 12 ] | ||
| arch_cibw_go: | ||
| - [ "x86_64", "amd64" ] | ||
| - [ "arm64", "arm64" ] | ||
| runs-on: macos-${{ matrix.os_version }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: set up Go | ||
| uses: actions/setup-go@v3 | ||
| with: | ||
| go-version: "1.22.x" | ||
| - name: Setup project files | ||
| run: | | ||
| rm -rf poetry.lock pyproject.toml | ||
| 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 --force --overwrite 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 --break-system-packages cibuildwheel==2.21.3 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] }} | ||
| CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" | ||
| PYTHON_BINARY_PATH: /usr/local/bin/python_for_build | ||
| CIBW_BUILD: "cp3${{ matrix.python3_version }}-*" | ||
| CIBW_SKIP: "cp36-* cp37-* cp38-* cp39-* cp310-* cp313-* *-musllinux_x86_64" | ||
| CIBW_ENVIRONMENT: > | ||
| PATH=$PATH:/usr/local/go/bin | ||
| GOARCH=${{ matrix.arch_cibw_go[1] }} | ||
| # FIXME: Test before uploading | ||
| # - name: Test Python wheel | ||
| # run: | | ||
| # # Test wheel installation | ||
| # /usr/local/bin/python_for_build -m pip install wheelhouse/*.whl | ||
| # # Test wheel functionality | ||
| # /usr/local/bin/python_for_build validate_otdf_python.py | ||
| - 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: | ||
| # if: false | ||
| name: Linux Python 3.x | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Setup project files | ||
| run: | | ||
| rm -rf poetry.lock pyproject.toml | ||
| cp setup_ci.py setup.py | ||
| # QEMU is used by cibuildwheel to cross-compile wheels | ||
| # https://cibuildwheel.pypa.io/en/stable/faq/#emulation | ||
| - name: Set up QEMU | ||
| if: runner.os == 'Linux' | ||
| uses: docker/setup-qemu-action@v3 | ||
| with: | ||
| platforms: all | ||
| - name: Build wheels | ||
| uses: pypa/[email protected] | ||
| env: | ||
| CIBW_BUILD: "cp3*_x86_64 cp3*_aarch64" | ||
| CIBW_SKIP: "cp36-* cp37-* cp38-* cp39-* cp310-* cp313-* *-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 | ||
| # FIXME: Test before uploading | ||
| # - name: Test Python wheel | ||
| # run: | | ||
| # # Test wheel installation | ||
| # python3 -m pip install wheelhouse/*.whl | ||
| # # Test wheel functionality | ||
| # python3 validate_otdf_python.py | ||
| - 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@v4 | ||
| # - name: Setup project files | ||
| # run: | | ||
| # rm -rf poetry.lock pyproject.toml | ||
| # 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-* cp310-* cp313-* *-musllinux_x86_64" | ||
| # CIBW_ARCHS: "native" | ||
| # CIBW_ENVIRONMENT: > | ||
| # GOARCH=amd64 | ||
| # - name: Upload artifacts | ||
| # uses: actions/upload-artifact@v4 | ||
| # with: | ||
| # name: wheels-windows-amd64 | ||
| # path: ./wheelhouse/*.whl | ||
| release: | ||
| permissions: | ||
| contents: write | ||
| # This permission is mandatory for PyPI's trusted publishing | ||
| id-token: write | ||
| needs: [build_macos, build_linux_x86_64] | ||
| runs-on: ubuntu-latest | ||
| # if: github.ref == 'refs/heads/main' | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - 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: Store version | ||
| run: | | ||
| pip install poetry | ||
| PROJECT_VESION=$(poetry version -s) | ||
| echo "PROJECT_VESION=$PROJECT_VESION" >> $GITHUB_ENV | ||
| # Publish with "trusted publisher" mechanism: | ||
| # https://docs.pypi.org/trusted-publishers/ | ||
| # | ||
| # Requires GHA token permission (above in YAML) and PyPI magement: | ||
| # https://test.pypi.org/manage/project/otdf-python/settings/publishing/ | ||
| - name: Publish package distributions to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| repository-url: https://test.pypi.org/legacy/ | ||
| packages-dir: dist/ | ||
| - uses: ncipollo/release-action@v1 | ||
| with: | ||
| artifacts: | | ||
| README.md, | ||
| dist/*.whl | ||
| body: otdf_python version ${{ env.PROJECT_VESION }} | ||
| makeLatest: "false" | ||
| tag: "${{ env.PROJECT_VESION }}-dev-${{ github.sha }}" | ||
| # tag: v${{ env.PROJECT_VESION }} | ||