build: fix darwin build #28
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, Sign & Publish | |
on: | |
push: | |
pull_request: | |
jobs: | |
build-linux: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: | |
- amd64 | |
- arm64 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt install -y \ | |
build-essential wget m4 xz-utils \ | |
make cmake libeigen3-dev \ | |
liblapack-dev libopenblas-dev | |
- name: Build wheel | |
run: | | |
./build.sh | |
readelf -d flatter-linux | grep 'NEEDED' | |
- name: Test the Package | |
run: | | |
./test.sh | |
- name: Upload wheel artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheel-${{ matrix.arch }}-linux | |
path: dist/*.whl | |
build-darwin: | |
runs-on: macos-latest | |
strategy: | |
matrix: | |
arch: | |
- arm64 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
brew install make wget cmake eigen | |
- name: Build wheel | |
run: | | |
./build.sh | |
- name: Test the package | |
run: | | |
./test.sh | |
- name: Upload wheel artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheel-${{ matrix.arch }}-darwin | |
path: dist/*.whl | |
test-darwin: | |
name: Fresh Install on macOS | |
runs-on: macos-latest | |
strategy: | |
matrix: | |
arch: | |
- arm64 | |
needs: | |
- build-darwin | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Delete everything except tests.py | |
run: | | |
find . -type f -not -name 'tests.py' -delete | |
- name: Download the wheel artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: wheel-${{ matrix.arch }}-darwin | |
- name: Run Tests | |
run: | | |
python3 -m venv venv | |
. venv/bin/activate | |
PYTHONPATH= pip install *.whl | |
python3 tests.py | |
test-linux: | |
name: Fresh Install on Linux | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: | |
- amd64 | |
- arm64 | |
needs: | |
- build-linux | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Delete everything except tests.py | |
run: | | |
find . -type f -not -name 'tests.py' -delete | |
- name: Download the wheel artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: wheel-${{ matrix.arch }}-linux | |
- name: Run Tests | |
run: | | |
python3 -m venv venv | |
. venv/bin/activate | |
PYTHONPATH= pip install *.whl | |
python3 tests.py | |
collect-artifacts: | |
name: Collect Build Artifacts | |
needs: | |
- test-linux | |
- test-darwin | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: wheel-* | |
path: dist/ | |
merge-multiple: true | |
- name: Upload merged artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts | |
path: dist/ | |
publish-to-pypi: | |
name: >- | |
Publish to PyPI | |
needs: | |
- collect-artifacts | |
# only publish on tags | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/flatn | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: artifacts | |
path: dist/ | |
- name: Publish distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
github-release: | |
name: Sign & Create Release | |
needs: | |
- publish-to-pypi | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: artifacts | |
path: dist/ | |
- name: Sign the distribution with SigStore | |
uses: sigstore/gh-action-sigstore-python@v3.0.0 | |
with: | |
inputs: >- | |
./dist/*.whl | |
- name: Create GitHub Release | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: >- | |
gh release create | |
"$GITHUB_REF_NAME" | |
--repo "$GITHUB_REPOSITORY" | |
--notes "" | |
- name: Upload artifact signatures to GitHub Release | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: >- | |
gh release upload | |
"$GITHUB_REF_NAME" dist/** | |
--repo "$GITHUB_REPOSITORY" | |
publish-to-testpypi: | |
name: >- | |
Publish to TestPyPI | |
needs: | |
- collect-artifacts | |
# only test publish on master branch | |
if: github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/flatn | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: artifacts | |
path: dist/ | |
- name: Publish distribution to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ |