diff --git a/.github/workflows/build-py-packages.yml b/.github/workflows/build-py-packages.yml index f45f26e..e95b201 100644 --- a/.github/workflows/build-py-packages.yml +++ b/.github/workflows/build-py-packages.yml @@ -8,6 +8,26 @@ on: required: false default: false type: boolean + push: + branches: ["main"] + paths: + - 'spatialbench-cli/**' + - '.github/workflows/build-py-packages.yml' + pull_request: + paths: + - 'spatialbench-cli/**' + - '.github/workflows/build-py-packages.yml' + workflow_dispatch: + inputs: + upload-artifacts: + description: "Whether to upload built distributions as artifacts" + required: false + default: false + type: boolean + +concurrency: + group: ${{ github.repository }}-${{ github.ref }}-${{ github.workflow }} + cancel-in-progress: true jobs: wheels: @@ -64,7 +84,7 @@ jobs: os: windows # macOS - - runner: macos-13 + - runner: macos-14 target: x86_64 os: macos - runner: macos-14 @@ -73,6 +93,16 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Set ARM architecture flags for Linux cross-compilation + if: (matrix.target == 'aarch64' || matrix.target == 'armv7') && (matrix.os == 'linux' || matrix.os == 'musllinux') + run: | + if [ "${{ matrix.target }}" = "aarch64" ]; then + echo "CFLAGS_aarch64_unknown_linux_gnu=-D__ARM_ARCH=8" >> $GITHUB_ENV + echo "CFLAGS_aarch64_unknown_linux_musl=-D__ARM_ARCH=8" >> $GITHUB_ENV + elif [ "${{ matrix.target }}" = "armv7" ]; then + echo "CFLAGS_armv7_unknown_linux_gnueabihf=-D__ARM_ARCH=7" >> $GITHUB_ENV + echo "CFLAGS_armv7_unknown_linux_musleabihf=-D__ARM_ARCH=7" >> $GITHUB_ENV + fi - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -81,7 +111,7 @@ jobs: working-directory: spatialbench-cli manylinux: ${{ matrix.manylinux || '' }} - name: Upload wheels - if: ${{ inputs.upload-artifacts }} + if: ${{ inputs.upload-artifacts || github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} uses: actions/upload-artifact@v4 with: name: wheels-${{ matrix.os }}-${{ matrix.target }} @@ -98,7 +128,7 @@ jobs: args: --out dist working-directory: spatialbench-cli - name: Upload sdist - if: ${{ inputs.upload-artifacts }} + if: ${{ inputs.upload-artifacts || github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} uses: actions/upload-artifact@v4 with: name: wheels-sdist