Advertisement
Guest User

rust git workflow

a guest
Mar 3rd, 2025
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.90 KB | None | 0 0
  1. name: Release
  2.  
  3. on:
  4.   push:
  5.     tags:
  6.      - "v*"
  7.  
  8. jobs:
  9.   build:
  10.     name: Build ${{ matrix.target }}
  11.     runs-on: ${{ matrix.os }}
  12.     strategy:
  13.       fail-fast: false
  14.       matrix:
  15.         include:
  16.           - os: ubuntu-latest
  17.             target: x86_64-unknown-linux-gnu
  18.             name: linux-x86_64
  19.           - os: ubuntu-latest
  20.             target: x86_64-unknown-linux-musl
  21.             name: linux-musl-x86_64
  22.           - os: macos-latest
  23.             target: x86_64-apple-darwin
  24.             name: darwin-x86_64
  25.           - os: macos-latest
  26.             target: aarch64-apple-darwin
  27.             name: darwin-aarch64
  28.           - os: windows-latest
  29.             target: x86_64-pc-windows-msvc
  30.             name: windows-x86_64
  31.  
  32.     steps:
  33.       - uses: actions/checkout@v4
  34.  
  35.       - name: Install Rust
  36.         uses: dtolnay/rust-toolchain@stable
  37.         with:
  38.           targets: ${{ matrix.target }}
  39.  
  40.       - name: Install dependencies (Linux)
  41.         if: runner.os == 'Linux'
  42.         run: |
  43.          sudo apt-get update
  44.           sudo apt-get install -y libasound2-dev libudev-dev pkg-config libx11-dev libwayland-dev libxkbcommon-dev
  45.  
  46.       - name: Install target (Linux MUSL)
  47.         if: matrix.target == 'x86_64-unknown-linux-musl'
  48.         run: |
  49.          rustup target add x86_64-unknown-linux-musl
  50.  
  51.       - name: Build
  52.         run: cargo build --release --target ${{ matrix.target }}
  53.  
  54.       - name: Package (Windows)
  55.         if: runner.os == 'Windows'
  56.         run: |
  57.          mkdir -p release
  58.           cp target/${{ matrix.target }}/release/pong.exe release/
  59.           cd release
  60.           7z a ../pong-${{ matrix.name }}.zip *
  61.  
  62.       - name: Package (Unix)
  63.         if: runner.os != 'Windows'
  64.         run: |
  65.          mkdir -p release
  66.           cp target/${{ matrix.target }}/release/pong release/
  67.           cd release
  68.           zip -r ../pong-${{ matrix.name }}.zip *
  69.  
  70.       - name: Upload artifacts
  71.         uses: actions/upload-artifact@v3
  72.         with:
  73.           name: pong-${{ matrix.name }}
  74.           path: pong-${{ matrix.name }}.zip
  75.  
  76.   create-release:
  77.     name: Create GitHub Release
  78.     needs: build
  79.     runs-on: ubuntu-latest
  80.     steps:
  81.       - uses: actions/checkout@v4
  82.  
  83.       - name: Download all artifacts
  84.         uses: actions/download-artifact@v3
  85.         with:
  86.           path: artifacts
  87.  
  88.       - name: Create Release
  89.         id: create_release
  90.         uses: softprops/action-gh-release@v1
  91.         with:
  92.           files: |
  93.            artifacts/pong-linux-x86_64/pong-linux-x86_64.zip
  94.             artifacts/pong-linux-musl-x86_64/pong-linux-musl-x86_64.zip
  95.             artifacts/pong-darwin-x86_64/pong-darwin-x86_64.zip
  96.             artifacts/pong-darwin-aarch64/pong-darwin-aarch64.zip
  97.             artifacts/pong-windows-x86_64/pong-windows-x86_64.zip
  98.           draft: false
  99.           prerelease: false
  100.           token: ${{ secrets.GITHUB_TOKEN }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement