From da75fdd86d8ec2346fcc3edea3739e468d579679 Mon Sep 17 00:00:00 2001 From: Yoo1tic <137816438+Yoo1tic@users.noreply.github.com> Date: Mon, 4 Aug 2025 19:18:00 +0800 Subject: [PATCH] refactor: split GitHub Actions into separate CI and release workflows --- .github/workflows/{build.yml => ci.yml} | 22 +++------ .github/workflows/release.yml | 59 +++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 17 deletions(-) rename .github/workflows/{build.yml => ci.yml} (70%) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/ci.yml similarity index 70% rename from .github/workflows/build.yml rename to .github/workflows/ci.yml index 0a54151..1e2c8ba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,13 @@ -name: Build and Test +name: CI on: push: branches: [ main ] pull_request: branches: [ main ] - release: - types: [published] + +env: + CARGO_TERM_COLOR: always jobs: build: @@ -47,22 +48,9 @@ jobs: - name: Build project run: cargo build --release --target ${{ matrix.target }} - - name: Run tests - run: cargo test --target ${{ matrix.target }} - - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: ${{ matrix.release_name }} path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} - - - name: Upload release assets - if: github.event_name == 'release' - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} - asset_name: ${{ matrix.release_name }} - asset_content_type: application/octet-stream \ No newline at end of file + retention-days: 30 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b885208 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,59 @@ +name: Release + +on: + release: + types: [published] + push: + tags: + - 'v*' + +env: + CARGO_TERM_COLOR: always + +jobs: + build-and-release: + name: Build and Release + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + 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.exe + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - 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 ${{ matrix.target }} + + - name: Upload release assets + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} + name: ${{ matrix.release_name }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file