fix: fix ci issue #78
Workflow file for this run
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: Rust Build, Test and Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| env: | |
| BINARY_NAME: proxy-convert | |
| RUST_BACKTRACE: 1 | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux glibc + musl static | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| - os: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-musl | |
| # macOS | |
| - os: macos-14 | |
| target: x86_64-apple-darwin | |
| - os: macos-14 | |
| target: aarch64-apple-darwin | |
| # Windows | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| - os: windows-latest | |
| target: aarch64-pc-windows-msvc | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| targets: ${{ matrix.target }} | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2.8.2 | |
| with: | |
| key: ${{ matrix.target }} | |
| shared-key: release | |
| - name: Install Linux deps (glibc cross) | |
| if: matrix.os == 'ubuntu-latest' && matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross | |
| - name: Set env for Linux aarch64 cross (glibc) | |
| if: matrix.os == 'ubuntu-latest' && matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV | |
| echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV | |
| echo "AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar" >> $GITHUB_ENV | |
| - name: Install musl (Linux static, x86_64 only) | |
| if: matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-musl' | |
| run: sudo apt-get update && sudo apt-get install -y musl-tools | |
| - name: Build | |
| run: cargo build --release --target ${{ matrix.target }} --verbose | |
| - name: Test binary | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
| exe="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}.exe" | |
| else | |
| exe="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}" | |
| fi | |
| if [ -f "$exe" ]; then | |
| "$exe" --version | |
| else | |
| echo "Binary not found: $exe" | |
| exit 1 | |
| fi | |
| - name: Package | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
| exe="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}.exe" | |
| out="${{ env.BINARY_NAME }}-${{ matrix.target }}.zip" | |
| mkdir -p release | |
| cp "$exe" release/ | |
| (cd release && 7z a "$out" "${{ env.BINARY_NAME }}.exe") | |
| else | |
| exe="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}" | |
| out="${{ env.BINARY_NAME }}-${{ matrix.target }}.tar.gz" | |
| mkdir -p release | |
| cp "$exe" release/ | |
| (cd release && tar czvf "$out" "${{ env.BINARY_NAME }}") | |
| fi | |
| echo "PACKAGE_PATH=release/$out" >> $GITHUB_ENV | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.target }} | |
| path: ${{ env.PACKAGE_PATH }} | |
| release: | |
| name: Create Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: Release ${{ github.ref_name }} | |
| draft: false | |
| prerelease: false | |
| files: | | |
| artifacts/*/*.tar.gz | |
| artifacts/*/*.zip |