From 103e00febe342d904026d5cf1f1df6b65303cb83 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 4 Sep 2024 22:37:40 -0600 Subject: [PATCH] CI updates --- .github/workflows/build.yaml | 90 +++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 885e278..4a1a6a2 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -25,6 +25,19 @@ jobs: sudo apt-get -y install libgtk-3-dev - name: Checkout uses: actions/checkout@v4 + - name: Check git tag against Cargo version + if: startsWith(github.ref, 'refs/tags/') + shell: bash + run: | + set -eou + version=$(grep '^version' Cargo.toml | awk -F' = ' '{print $2}' | tr -d '"') + version="v$version" + tag='${{github.ref}}' + tag="${tag#refs/tags/}" + if [ "$tag" != "$version" ]; then + echo "::error::Git tag doesn't match the Cargo version! ($tag != $version)" + exit 1 + fi - name: Setup Rust toolchain uses: dtolnay/rust-toolchain@stable with: @@ -100,8 +113,75 @@ jobs: SCCACHE_GHA_ENABLED: "true" run: cargo test --release - build: - name: Build + build-cli: + name: Build objdiff-cli + strategy: + matrix: + include: + - platform: ubuntu-latest + target: x86_64-unknown-linux-musl + name: linux-x86_64 + build: zigbuild + features: default + - platform: ubuntu-latest + target: i686-unknown-linux-musl + name: linux-i686 + build: zigbuild + features: default + - platform: ubuntu-latest + target: aarch64-unknown-linux-musl + name: linux-aarch64 + build: zigbuild + features: default + - platform: ubuntu-latest + target: armv7-unknown-linux-musleabi + name: linux-armv7l + build: zigbuild + features: default + - platform: windows-latest + target: x86_64-pc-windows-msvc + name: windows-x86_64 + features: default + - platform: macos-latest + target: x86_64-apple-darwin + name: macos-x86_64 + features: default + - platform: macos-latest + target: aarch64-apple-darwin + name: macos-arm64 + features: default + fail-fast: false + runs-on: ${{ matrix.platform }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install cargo-zigbuild + if: matrix.build == 'zigbuild' + run: pip install ziglang==0.12.0 cargo-zigbuild==0.18.4 + - name: Setup Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + - name: Setup sccache + uses: mozilla-actions/sccache-action@v0.0.4 + - name: Cargo build + env: + RUSTC_WRAPPER: sccache + SCCACHE_GHA_ENABLED: "true" + run: > + cargo build --profile ${{ env.BUILD_PROFILE }} --target ${{ matrix.target }} + --bin objdiff-cli --features ${{ matrix.features }} + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.name }} + path: | + ${{ env.CARGO_TARGET_DIR }}/${{ matrix.target }}/${{ env.BUILD_PROFILE }}/objdiff-cli + ${{ env.CARGO_TARGET_DIR }}/${{ matrix.target }}/${{ env.BUILD_PROFILE }}/objdiff-cli.exe + if-no-files-found: error + + build-gui: + name: Build objdiff-gui strategy: matrix: include: @@ -144,14 +224,12 @@ jobs: SCCACHE_GHA_ENABLED: "true" run: > cargo build --profile ${{ env.BUILD_PROFILE }} --target ${{ matrix.target }} - --bin objdiff-cli --bin objdiff --features ${{ matrix.features }} + --bin objdiff --features ${{ matrix.features }} - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: ${{ matrix.name }} path: | - ${{ env.CARGO_TARGET_DIR }}/${{ matrix.target }}/${{ env.BUILD_PROFILE }}/objdiff-cli - ${{ env.CARGO_TARGET_DIR }}/${{ matrix.target }}/${{ env.BUILD_PROFILE }}/objdiff-cli.exe ${{ env.CARGO_TARGET_DIR }}/${{ matrix.target }}/${{ env.BUILD_PROFILE }}/objdiff ${{ env.CARGO_TARGET_DIR }}/${{ matrix.target }}/${{ env.BUILD_PROFILE }}/objdiff.exe if-no-files-found: error @@ -160,7 +238,7 @@ jobs: name: Release if: startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest - needs: [ build ] + needs: [ check, build ] permissions: contents: write steps: