From 82895232bca0e898687a63eb4b5df800f8e77119 Mon Sep 17 00:00:00 2001 From: Luis Garcia Date: Wed, 30 Oct 2024 20:36:38 +0000 Subject: [PATCH] CI: Dont build arm on non releases Signed-off-by: Luis Garcia --- .github/workflows/ci.yml | 112 +++++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 53 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90f9f67c..f5e3ffc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -142,41 +142,52 @@ jobs: with: name: tanoshi-web path: crates/tanoshi-web/dist - + build-tauri: - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.runs_on }} needs: - build-web strategy: fail-fast: false matrix: include: - - os: [self-hosted, arm64] - arch: aarch64 - type: linux - os: ubuntu-latest arch: amd64 type: linux + runs_on: ubuntu-latest - os: windows-latest arch: amd64 type: windows + runs_on: windows-latest + - os: ubuntu-latest + arch: aarch64 + type: linux + runs_on: [self-hosted, arm64] + include_arm64: ${{ startsWith(github.ref, 'refs/tags/') }} steps: + - name: Skip arm64 build if not release + if: matrix.arch == 'aarch64' && !matrix.include_arm64 + run: echo "Skipping arm64 build since it's not a release." - uses: actions/checkout@v4 + if: matrix.arch != 'aarch64' || matrix.include_arm64 - name: Download dist uses: actions/download-artifact@v4 with: name: tanoshi-web path: crates/tanoshi-web/dist + if: matrix.arch != 'aarch64' || matrix.include_arm64 - uses: actions-rust-lang/setup-rust-toolchain@v1 + if: matrix.arch != 'aarch64' || matrix.include_arm64 + - uses: Swatinem/rust-cache@v2 with: key: "${{ matrix.type }}-${{ matrix.arch }}" - + if: matrix.arch != 'aarch64' || matrix.include_arm64 - name: Install deps (ubuntu) - if: ${{ matrix.os != 'macos-latest' && matrix.os != 'windows-latest' }} + if: (matrix.os == 'ubuntu-latest' || matrix.os == 'self-hosted') && (matrix.arch != 'aarch64' || matrix.include_arm64) run: sudo apt update && sudo apt upgrade -y && sudo apt install -y ${{ env.UBUNTU_DEPS }} - name: Install deps (macOS) @@ -184,11 +195,13 @@ jobs: run: brew install icu4c libarchive bzip2 lz4 zlib expat libiconv - uses: ilammy/setup-nasm@v1 + if: matrix.arch != 'aarch64' || matrix.include_arm64 - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v2.0.5 with: version: ${{ env.LLVM_VERSION }} + if: matrix.arch != 'aarch64' || matrix.include_arm64 - name: Cache vcpkg uses: actions/cache@v4 @@ -208,12 +221,13 @@ jobs: - name: Install Binstall uses: cargo-bins/cargo-binstall@main + if: matrix.arch != 'aarch64' || matrix.include_arm64 - name: Install tauri-cli run: cargo binstall tauri-cli@2.0 --no-confirm --locked + if: matrix.arch != 'aarch64' || matrix.include_arm64 - - name: Build tauri (ubuntu) - if: ${{ matrix.os != 'macos-latest' && matrix.os != 'windows-latest' }} + - name: Build tauri shell: bash env: RUSTFLAGS: "-Clink-arg=-Wl,--allow-multiple-definition" @@ -224,53 +238,30 @@ jobs: else cargo tauri build --debug fi + if: matrix.arch != 'aarch64' || matrix.include_arm64 - - name: Build tanoshi (macos) - if: ${{ matrix.os == 'macos-latest' }} - shell: bash - env: - PKG_CONFIG_PATH: /usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libarchive/lib/pkgconfig:/usr/local/opt/zlib/lib/pkgconfig:/usr/local/opt/expat/lib/pkgconfig + - name: Move files run: | - cd crates/tanoshi-tauri - if [[ "${GITHUB_REF}" == refs/tags/* ]]; then - cargo tauri build + mkdir -p builds + if [[ "${{ matrix.os }}" != "windows-latest" ]]; then + find target/ -type f \( -name "*.deb" -o -name "*.AppImage" -o -name "*.dmg" \) -print0 | + while IFS= read -r -d '' file; do + mv "$file" ${{ github.workspace }}/builds/ + done else - cargo tauri build --debug + mv target/*/bundle/msi/*.msi ${{ github.workspace }}/builds/ fi - - - name: Build tanoshi (windows) - if: ${{ matrix.os == 'windows-latest' }} - run: | - cd crates/tanoshi-tauri - if ($env:GITHUB_REF -match '^refs/tags/') { - cargo tauri build - } else { - cargo tauri build --debug - } - - - name: Move files (linux/macOS) - if: ${{ matrix.os != 'windows-latest' }} - run: | - mkdir -p builds - find target/ -type f \( -name "*.deb" -o -name "*.AppImage" -o -name "*.dmg" \) -print0 | - while IFS= read -r -d '' file; do - mv "$file" ${{ github.workspace }}/builds/ - done - - - name: Move files (windows) - if: ${{ matrix.os == 'windows-latest' }} - run: | - mkdir -p builds - mv target/*/bundle/msi/*.msi ${{ github.workspace }}/builds/ + if: matrix.arch != 'aarch64' || matrix.include_arm64 - name: Upload dist uses: actions/upload-artifact@v4 with: name: tanoshi-app-${{ matrix.type }}-${{ matrix.arch }} path: ${{ github.workspace }}/builds/ + if: matrix.arch != 'aarch64' || matrix.include_arm64 - name: Upload binaries to GitHub Releases - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/') && (matrix.arch != 'aarch64' || matrix.include_arm64) uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} @@ -280,45 +271,56 @@ jobs: overwrite: true build-tanoshi: - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.runs_on }} needs: - build-web strategy: fail-fast: false matrix: include: - - os: [self-hosted, arm64] - arch: aarch64 - type: linux - os: ubuntu-latest arch: amd64 type: linux + runs_on: ubuntu-latest + - os: ubuntu-latest + arch: aarch64 + type: linux + runs_on: [self-hosted, arm64] + include_arm64: ${{ startsWith(github.ref, 'refs/tags/') }} steps: + - name: Skip arm64 build if not release + if: matrix.arch == 'aarch64' && !matrix.include_arm64 + run: echo "Skipping arm64 build since it's not a release." - uses: actions/checkout@v4 + if: matrix.arch != 'aarch64' || matrix.include_arm64 - name: Download dist uses: actions/download-artifact@v4 with: name: tanoshi-web path: crates/tanoshi-web/dist + if: matrix.arch != 'aarch64' || matrix.include_arm64 - uses: actions-rust-lang/setup-rust-toolchain@v1 + if: matrix.arch != 'aarch64' || matrix.include_arm64 + - uses: Swatinem/rust-cache@v2 with: key: "${{ matrix.type }}-${{ matrix.arch }}" - + if: matrix.arch != 'aarch64' || matrix.include_arm64 - name: Install deps - if: ${{ matrix.os != 'macos-latest' && matrix.os != 'windows-latest' }} run: sudo apt update && sudo apt upgrade -y && sudo apt install -y ${{ env.UBUNTU_DEPS }} - + if: matrix.arch != 'aarch64' || matrix.include_arm64 - uses: ilammy/setup-nasm@v1 + if: matrix.arch != 'aarch64' || matrix.include_arm64 - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v2.0.5 with: version: ${{ env.LLVM_VERSION }} + if: matrix.arch != 'aarch64' || matrix.include_arm64 - name: Build tanoshi shell: bash @@ -332,12 +334,14 @@ jobs: cargo build -p tanoshi echo "build_dir=debug" >> $GITHUB_ENV fi + if: matrix.arch != 'aarch64' || matrix.include_arm64 - name: Upload dist uses: actions/upload-artifact@v4 with: name: tanoshi-${{ matrix.arch }} path: ${{ github.workspace }}/target/${{ env.build_dir }}/tanoshi + if: matrix.arch != 'aarch64' || matrix.include_arm64 docker: runs-on: ubuntu-latest @@ -345,6 +349,7 @@ jobs: - build-tanoshi env: DEFAULT_VARIANT: slim + BUILD_PLATFORMS: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }} strategy: fail-fast: false matrix: @@ -362,6 +367,7 @@ jobs: path: linux/amd64 - name: Download dist (AARCH64) + if: startsWith(github.ref, 'refs/tags/') uses: actions/download-artifact@v4 with: name: tanoshi-aarch64 @@ -425,7 +431,7 @@ jobs: with: context: . file: ${{ matrix.dockerfile }} - platforms: linux/amd64,linux/arm64 + platforms: ${{ env.BUILD_PLATFORMS }} push: false tags: tanoshi:action @@ -436,7 +442,7 @@ jobs: with: context: . file: ${{ matrix.dockerfile }} - platforms: linux/amd64,linux/arm64 + platforms: ${{ env.BUILD_PLATFORMS }} push: true tags: ${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }}