From 578b4cf3b87f605549074e40a3cb1030d142785a Mon Sep 17 00:00:00 2001 From: Yoo1tic <137816438+Yoo1tic@users.noreply.github.com> Date: Mon, 4 Aug 2025 20:34:40 +0800 Subject: [PATCH] feat: standardize workflows with zip artifacts and improve naming --- .github/workflows/ci.yml | 56 -------------------- .github/workflows/dev-build.yml | 63 ++++++++++++++++++++++ .github/workflows/release.yml | 93 ++++++++++++++++++--------------- 3 files changed, 113 insertions(+), 99 deletions(-) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/dev-build.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 1e2c8ba..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: CI - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - name: Build - 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 artifacts - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.release_name }} - path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} - retention-days: 30 \ No newline at end of file diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml new file mode 100644 index 0000000..c05405a --- /dev/null +++ b/.github/workflows/dev-build.yml @@ -0,0 +1,63 @@ +name: Dev Build + +on: + push: + branches: [main] + pull_request: + branches: [main] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + name: Build + 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: Create release package and zip + run: | + mkdir -p release-package + cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} release-package/ + cd release-package + zip -r ../${{ matrix.release_name }}.zip . + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.release_name }} + path: ${{ matrix.release_name }}.zip + retention-days: 30 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 024101f..95ee595 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release on: push: tags: - - 'v*' + - "v*" env: CARGO_TERM_COLOR: always @@ -28,34 +28,41 @@ jobs: release_name: gemini-keychecker-windows-x86_64.exe steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.target }} + - 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: 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: Build project + run: cargo build --release --target ${{ matrix.target }} - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.release_name }} - path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} - retention-days: 1 + - name: Create release package and zip + run: | + mkdir -p release-package + cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} release-package/ + cd release-package + zip -r ../${{ matrix.release_name }}.zip . + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.release_name }} + path: ${{ matrix.release_name }}.zip + retention-days: 1 release: name: Create Release @@ -63,24 +70,24 @@ jobs: runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 - - name: Download all artifacts - uses: actions/download-artifact@v4 - with: - path: artifacts + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts - - name: List downloaded artifacts - run: ls -R artifacts + - name: List downloaded artifacts + run: ls -R artifacts - - name: Create release - uses: softprops/action-gh-release@v2 - with: - files: artifacts/**/gemini-keychecker* - name: ${{ github.ref_name }} - draft: false - prerelease: false - fail_on_unmatched_files: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + - name: Create release + uses: softprops/action-gh-release@v2 + with: + files: artifacts/**/*.zip + name: ${{ github.ref_name }} + draft: false + prerelease: false + fail_on_unmatched_files: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}