|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + |
| 7 | +env: |
| 8 | + CARGO_TERM_COLOR: always |
| 9 | + |
| 10 | +jobs: |
| 11 | + windows-build: |
| 12 | + runs-on: windows-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + toolchain: |
| 16 | + - stable |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v4 |
| 20 | + - name: Setup Rust toolchain |
| 21 | + run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} |
| 22 | + - name: Build project |
| 23 | + run: cargo build --verbose |
| 24 | + - name: Package release |
| 25 | + if: startsWith(github.ref, 'refs/tags/') |
| 26 | + run: | |
| 27 | + $VERSION = $env:GITHUB_REF -replace 'refs/tags/', '' |
| 28 | + $ARCHIVE_NAME = "multiplayer-game-demo-rust-$VERSION-win64" |
| 29 | + cargo build --release --verbose |
| 30 | + mkdir "$ARCHIVE_NAME" |
| 31 | + Copy-Item LICENSE -Destination "$ARCHIVE_NAME" |
| 32 | + Copy-Item README.md -Destination "$ARCHIVE_NAME" |
| 33 | + Copy-Item doc -Destination "$ARCHIVE_NAME" -Recurse |
| 34 | + Copy-Item target/release/multiplayer-game-demo-rust.exe -Destination "$ARCHIVE_NAME" |
| 35 | + Compress-Archive -Path "$ARCHIVE_NAME" -DestinationPath "$ARCHIVE_NAME.zip" |
| 36 | + - name: Publish release |
| 37 | + if: startsWith(github.ref, 'refs/tags/') |
| 38 | + uses: softprops/action-gh-release@v2 |
| 39 | + with: |
| 40 | + files: | |
| 41 | + multiplayer-game-demo-rust-*.zip |
| 42 | +
|
| 43 | + linux-build: |
| 44 | + runs-on: ubuntu-latest |
| 45 | + strategy: |
| 46 | + matrix: |
| 47 | + toolchain: |
| 48 | + - stable |
| 49 | + steps: |
| 50 | + - name: Checkout |
| 51 | + uses: actions/checkout@v4 |
| 52 | + - name: Setup Rust toolchain |
| 53 | + run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} |
| 54 | + - name: Build project |
| 55 | + run: cargo build --verbose |
| 56 | + - name: Package release |
| 57 | + if: startsWith(github.ref, 'refs/tags/') |
| 58 | + run: | |
| 59 | + VERSION=$(echo ${{ github.ref }} | sed 's/refs\/tags\///') |
| 60 | + ARCHIVE_NAME=multiplayer-game-demo-rust-$VERSION-linux-x86_64 |
| 61 | + cargo build --release --verbose |
| 62 | + mkdir "$ARCHIVE_NAME" |
| 63 | + cp -R doc LICENSE target/release/multiplayer-game-demo-rust README.md "$ARCHIVE_NAME/" |
| 64 | + tar -czvf "$ARCHIVE_NAME.tar.gz" "$ARCHIVE_NAME" |
| 65 | + - name: Publish release |
| 66 | + if: startsWith(github.ref, 'refs/tags/') |
| 67 | + uses: softprops/action-gh-release@v2 |
| 68 | + with: |
| 69 | + files: | |
| 70 | + multiplayer-game-demo-rust-*.tar.gz |
0 commit comments