|
| 1 | +name: test_macos |
| 2 | +on: |
| 3 | + push: {} |
| 4 | +jobs: |
| 5 | + build: |
| 6 | + strategy: |
| 7 | + fail-fast: false |
| 8 | + matrix: |
| 9 | + include: |
| 10 | + - runs-on: ubuntu-latest |
| 11 | + target: x86_64-unknown-linux-musl |
| 12 | + image-platform: linux/amd64 |
| 13 | + |
| 14 | + # Cross-compiles from Intel Mac to arm64 |
| 15 | + # We can compile natively for arm64 using macos-14 runner, |
| 16 | + # but M1 processors of macos-14 runner don't support docker. |
| 17 | + # See: https://github.com/marketplace/actions/setup-docker-on-macos#arm64-processors-m1-m2-m3-series-used-on-macos-14-images-are-unsupported |
| 18 | + # See: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources |
| 19 | + - runs-on: macos-12 |
| 20 | + target: aarch64-apple-darwin |
| 21 | + image-platform: linux/arm/v8 |
| 22 | + name: Build |
| 23 | + runs-on: ${{ matrix.runs-on }} |
| 24 | + steps: |
| 25 | + - name: Setup variables |
| 26 | + run: | |
| 27 | + TAG=v0.0.0 |
| 28 | + VERSION=${TAG#v} |
| 29 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 30 | + echo "IMAGE=ghcr.io/kamu-data/engine-datafusion:$VERSION" >> $GITHUB_ENV |
| 31 | +
|
| 32 | + - name: Install docker (macOS) |
| 33 | + if: contains(matrix.runs-on, 'macos-') |
| 34 | + # See: https://blog.netnerds.net/2022/11/docker-macos-github-actions/ |
| 35 | + run: | |
| 36 | + brew install docker docker-buildx |
| 37 | + colima start |
| 38 | +
|
| 39 | + - name: Install musl (linux) |
| 40 | + if: contains(matrix.target, '-musl') |
| 41 | + # See: https://blog.urth.org/2023/03/05/cross-compiling-rust-projects-in-github-actions/ |
| 42 | + run: | |
| 43 | + sudo apt-get update --yes |
| 44 | + sudo apt-get install --yes musl-tools |
| 45 | +
|
| 46 | + - uses: actions/checkout@v4 |
| 47 | + |
| 48 | + - uses: actions-rs/toolchain@v1 |
| 49 | + with: |
| 50 | + target: ${{ matrix.target }} |
| 51 | + override: true |
| 52 | + |
| 53 | + - name: Log in to GitHub Container Registry |
| 54 | + uses: docker/login-action@v3 |
| 55 | + with: |
| 56 | + registry: ghcr.io |
| 57 | + username: ${{ github.actor }} |
| 58 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + |
| 60 | + - name: Build binary |
| 61 | + run: | |
| 62 | + # cargo build --release --target ${{ matrix.target }} |
| 63 | + |
| 64 | + - name: Build image |
| 65 | + run: | |
| 66 | + docker buildx build \ |
| 67 | + --platform ${{ matrix.image-platform }} \ |
| 68 | + --build-arg target_arch=${{ matrix.target }} \ |
| 69 | + --build-arg version=${{ env.VERSION }} \ |
| 70 | + -t ${{ env.IMAGE }} \ |
| 71 | + -f image/Dockerfile \ |
| 72 | + . |
0 commit comments