From 0cb7c42d805eeea4e97b9b8c84f2a31180679a2b Mon Sep 17 00:00:00 2001 From: Yoo1tic <137816438+Yoo1tic@users.noreply.github.com> Date: Sat, 9 Aug 2025 17:02:43 +0800 Subject: [PATCH] refactor: update build workflows for Linux and Windows, improve artifact handling --- .github/workflows/dev-build.yml | 60 +++++++++++++++++++++------- .github/workflows/release.yml | 69 ++++++++++++++++++++++++++------- 2 files changed, 102 insertions(+), 27 deletions(-) diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index 70c2103..637f317 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -10,21 +10,22 @@ env: CARGO_TERM_COLOR: always jobs: - build: - name: Build - runs-on: ${{ matrix.os }} + build-linux: + name: Build Linux + runs-on: ${{ matrix.runner }} strategy: matrix: include: - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu + - target: x86_64 + target_triple: x86_64-unknown-linux-gnu + runner: ubuntu-latest artifact_name: gemini-keychecker release_name: gemini-keychecker-linux-x86_64 - - os: windows-latest - target: x86_64-pc-windows-msvc - artifact_name: gemini-keychecker.exe - release_name: gemini-keychecker-windows-x86_64 - + - target: aarch64 + target_triple: aarch64-unknown-linux-gnu + runner: ubuntu-24.04-arm + artifact_name: gemini-keychecker + release_name: gemini-keychecker-linux-aarch64 steps: - name: Checkout code uses: actions/checkout@v4 @@ -32,7 +33,7 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: - targets: ${{ matrix.target }} + targets: ${{ matrix.target_triple }} - name: Cache cargo dependencies uses: actions/cache@v4 @@ -46,11 +47,44 @@ jobs: ${{ runner.os }}-cargo- - name: Build project - run: cargo build --release --target ${{ matrix.target }} + run: cargo build --release --target ${{ matrix.target_triple }} - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: ${{ matrix.release_name }} - path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} + path: target/${{ matrix.target_triple }}/release/${{ matrix.artifact_name }} + retention-days: 30 + + build-windows: + name: Build Windows + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: x86_64-pc-windows-msvc + + - name: Cache cargo dependencies + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Build project + run: cargo build --release --target x86_64-pc-windows-msvc + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: gemini-keychecker-windows-x86_64 + path: target/x86_64-pc-windows-msvc/release/gemini-keychecker.exe retention-days: 30 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index daf773c..415d8ca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,21 +12,22 @@ permissions: contents: write jobs: - build: - name: Build - runs-on: ${{ matrix.os }} + build-linux: + name: Build Linux + runs-on: ${{ matrix.runner }} strategy: matrix: include: - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu + - target: x86_64 + target_triple: x86_64-unknown-linux-gnu + runner: ubuntu-latest artifact_name: gemini-keychecker release_name: gemini-keychecker-linux-x86_64 - - os: windows-latest - target: x86_64-pc-windows-msvc - artifact_name: gemini-keychecker.exe - release_name: gemini-keychecker-windows-x86_64 - + - target: aarch64 + target_triple: aarch64-unknown-linux-gnu + runner: ubuntu-24.04-arm + artifact_name: gemini-keychecker + release_name: gemini-keychecker-linux-aarch64 steps: - name: Checkout code uses: actions/checkout@v4 @@ -34,7 +35,7 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: - targets: ${{ matrix.target }} + targets: ${{ matrix.target_triple }} - name: Cache cargo dependencies uses: actions/cache@v4 @@ -48,12 +49,12 @@ jobs: ${{ runner.os }}-cargo- - name: Build project - run: cargo build --release --target ${{ matrix.target }} + run: cargo build --release --target ${{ matrix.target_triple }} - name: Create release package and zip run: | mkdir -p release-package - cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} release-package/ + cp target/${{ matrix.target_triple }}/release/${{ matrix.artifact_name }} release-package/ cd release-package zip -r ../${{ matrix.release_name }}.zip . @@ -64,9 +65,49 @@ jobs: path: ${{ matrix.release_name }}.zip retention-days: 1 + build-windows: + name: Build Windows + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: x86_64-pc-windows-msvc + + - name: Cache cargo dependencies + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Build project + run: cargo build --release --target x86_64-pc-windows-msvc + + - name: Create release package and zip + run: | + mkdir -p release-package + cp target/x86_64-pc-windows-msvc/release/gemini-keychecker.exe release-package/ + cd release-package + Compress-Archive -Path * -DestinationPath ../gemini-keychecker-windows-x86_64.zip + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: gemini-keychecker-windows-x86_64 + path: gemini-keychecker-windows-x86_64.zip + retention-days: 1 + release: name: Create Release - needs: build + needs: [build-linux, build-windows] runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') steps: