diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4cbda2289..0dd0df3a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,42 +99,6 @@ jobs: name: build-${{ matrix.target }} path: target_releases/* - cross-build: - name: Cross-build for other platforms - runs-on: ubuntu-latest - env: - TARGETS: "aarch64-unknown-linux-musl x86_64-unknown-linux-musl" - # TODO: aarch64-unknown-linux-gnu - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@v2 - - name: Install cross - run: | - cargo install cross - # Install latest cross version from git (disabled as it is probably less stable) - # cargo install cross --git https://github.com/cross-rs/cross - cross --version - - name: Build targets - run: | - for target in $TARGETS; do - echo -e "\n----------------------------------------------" - echo "Building $target" - - export "CARGO_TARGET_$(echo $target | tr 'a-z-' 'A-Z_')_RUSTFLAGS"='-C strip=debuginfo' - cross build --release --target $target --package martin-mbtiles - cross build --release --target $target --package martin --features=vendored-openssl - - mkdir -p target_releases/$target - mv target/$target/release/mbtiles target_releases/$target - mv target/$target/release/martin target_releases/$target - done - - name: Save build artifacts to build-${{ matrix.target }} - uses: actions/upload-artifact@v3 - with: - name: cross-build - path: target_releases/* - test: name: Test ${{ matrix.target }} runs-on: ${{ matrix.os }} @@ -336,7 +300,7 @@ jobs: retention-days: 5 docker: - name: Build docker images + name: Build and test docker images runs-on: ubuntu-latest needs: [ cross-build ] env: @@ -345,6 +309,8 @@ jobs: PGHOST: localhost PGUSER: postgres PGPASSWORD: postgres + TARGETS: "aarch64-unknown-linux-musl x86_64-unknown-linux-musl" + # TODO: aarch64-unknown-linux-gnu services: postgres: image: postgis/postgis:15-3.3 @@ -371,6 +337,12 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 + - name: Install cross + run: | + cargo install cross + # Install latest cross version from git (disabled as it is probably less stable) + # cargo install cross --git https://github.com/cross-rs/cross + cross --version - name: Setup database run: tests/fixtures/initdb.sh env: @@ -388,20 +360,32 @@ jobs: install: true platforms: linux/amd64,linux/arm64 - - run: rm -rf target_releases2 - - name: Download cross-build artifacts - uses: actions/download-artifact@v3 + - name: Build targets + run: | + for target in $TARGETS; do + echo -e "\n----------------------------------------------" + echo "Building $target" + + export "CARGO_TARGET_$(echo $target | tr 'a-z-' 'A-Z_')_RUSTFLAGS"='-C strip=debuginfo' + cross build --release --target $target --package martin-mbtiles + cross build --release --target $target --package martin --features=vendored-openssl + + mkdir -p target_releases/$target + mv target/$target/release/mbtiles target_releases/$target + mv target/$target/release/martin target_releases/$target + done + + - name: Save build artifacts to build-${{ matrix.target }} + uses: actions/upload-artifact@v3 with: name: cross-build - path: target_releases_tmp - - name: Reorganize build artifacts + path: target_releases/* + - name: Reorganize artifacts for docker build run: | - chmod -R +x target_releases_tmp/ mkdir -p target_releases/linux/arm64 mv target_releases_tmp/aarch64-unknown-linux-musl/* target_releases/linux/arm64/ mkdir -p target_releases/linux/amd64 mv target_releases_tmp/x86_64-unknown-linux-musl/* target_releases/linux/amd64/ - rm -rf target_releases_tmp - name: Build linux/arm64 Docker image uses: docker/build-push-action@v5 @@ -474,7 +458,7 @@ jobs: package: name: Package ${{ matrix.target }} runs-on: ${{ matrix.os }} - needs: [ test, test-legacy, docker, cross-build ] + needs: [ test, test-legacy, docker ] strategy: fail-fast: true matrix: