diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74db518..599f59f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,56 +1,53 @@ -name: Release +name: Publish afptool-rs on: push: tags: - - "v*" + - '*' jobs: build: - name: Build and Test on ${{ matrix.os }} + name: Publish binaries runs-on: ${{ matrix.os }} - strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - rust: [stable, beta, nightly] + os: [ubuntu-latest, windows-latest, macos-latest] steps: + # 检出代码 - name: Checkout source code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - - name: Install Rust + # 设置 Rust 工具链 + - name: Set up Rust toolchain uses: actions-rs/toolchain@v1 with: - toolchain: ${{ matrix.rust }} + toolchain: stable override: true - - name: Cache Cargo - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin - target - ~/.cargo/registry - ~/.cargo/git - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- - - - name: Compile the project + # 构建项目 + - name: Build project run: cargo build --release - - name: Run tests - run: cargo test --verbose - # 打包二进制文件 - - name: Package binary (only for release builds) - if: startsWith(github.ref, 'refs/tags/') + - name: Package binary run: | mkdir -p dist - if [ "${{ runner.os }}" = "Windows" ]; then - cp target/release/afptool-rs.exe dist/ + if [ "${{ matrix.os }}" = "windows-latest" ]; then + cp target/release/afptool-rs.exe dist/afptool-rs-${{ matrix.os }}.exe else - cp target/release/afptool-rs dist/ + cp target/release/afptool-rs dist/afptool-rs-${{ matrix.os }} fi - shell: bash + + # 上传二进制文件到 Release + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: dist/afptool-rs-${{ matrix.os }}* + asset_name: afptool-rs-${{ matrix.os }} + tag: ${{ github.ref_name }} + overwrite: true + body: | + This is the cross-platform release for afptool-rs. + - Built for ${{ matrix.os }} using GitHub Actions. \ No newline at end of file