feat: add initial README_CN.md with project overview and usage instru… #17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | |
| on: | |
| push: | |
| branches: [ main ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| include: | |
| # Linux builds | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| name: linux-x86_64 | |
| # macOS builds | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| name: macos-x86_64 | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| name: macos-aarch64 | |
| # Windows builds | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| name: windows-x86_64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Build | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Prepare artifacts (Unix) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| mkdir -p artifacts | |
| cp target/${{ matrix.target }}/release/afptool-rs artifacts/afptool-rs-${{ matrix.name }} | |
| chmod +x artifacts/afptool-rs-${{ matrix.name }} | |
| - name: Prepare artifacts (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| mkdir artifacts | |
| copy target\${{ matrix.target }}\release\afptool-rs.exe artifacts\afptool-rs-${{ matrix.name }}.exe | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: afptool-rs-${{ matrix.name }} | |
| path: artifacts/ | |
| # Build Linux ARM64 using Ubuntu ARM64 runner | |
| build-linux-arm64: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Build ARM64 binary in Docker | |
| run: | | |
| docker run --rm -v "$PWD":/workspace -w /workspace \ | |
| --platform linux/arm64 \ | |
| rust:1.80 \ | |
| sh -c " | |
| apt-get update && apt-get install -y build-essential && | |
| cargo build --release && | |
| mkdir -p artifacts && | |
| cp target/release/afptool-rs artifacts/afptool-rs-linux-aarch64 && | |
| chmod +x artifacts/afptool-rs-linux-aarch64 | |
| " | |
| - name: Upload ARM64 artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: afptool-rs-linux-aarch64 | |
| path: artifacts/ | |
| # Create universal macOS binary | |
| create-universal-macos: | |
| needs: build | |
| runs-on: macos-latest | |
| steps: | |
| - name: Download macOS x86_64 artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: afptool-rs-macos-x86_64 | |
| path: ./x86_64 | |
| - name: Download macOS aarch64 artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: afptool-rs-macos-aarch64 | |
| path: ./aarch64 | |
| - name: Create universal binary | |
| run: | | |
| mkdir -p artifacts | |
| lipo -create ./x86_64/afptool-rs-macos-x86_64 ./aarch64/afptool-rs-macos-aarch64 -output artifacts/afptool-rs-macos-universal | |
| chmod +x artifacts/afptool-rs-macos-universal | |
| - name: Upload universal macOS binary | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: afptool-rs-macos-universal | |
| path: artifacts/ | |
| # Create release when tagged | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: [build, build-linux-arm64, create-universal-macos] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./artifacts | |
| - name: Create release archives | |
| run: | | |
| cd artifacts | |
| # Linux | |
| tar -czf afptool-rs-linux-x86_64.tar.gz -C afptool-rs-linux-x86_64 . | |
| tar -czf afptool-rs-linux-aarch64.tar.gz -C afptool-rs-linux-aarch64 . | |
| # macOS | |
| tar -czf afptool-rs-macos-x86_64.tar.gz -C afptool-rs-macos-x86_64 . | |
| tar -czf afptool-rs-macos-aarch64.tar.gz -C afptool-rs-macos-aarch64 . | |
| tar -czf afptool-rs-macos-universal.tar.gz -C afptool-rs-macos-universal . | |
| # Windows | |
| cd afptool-rs-windows-x86_64 && zip -r ../afptool-rs-windows-x86_64.zip . && cd .. | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| artifacts/afptool-rs-linux-x86_64.tar.gz | |
| artifacts/afptool-rs-linux-aarch64.tar.gz | |
| artifacts/afptool-rs-macos-x86_64.tar.gz | |
| artifacts/afptool-rs-macos-aarch64.tar.gz | |
| artifacts/afptool-rs-macos-universal.tar.gz | |
| artifacts/afptool-rs-windows-x86_64.zip | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |