|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' |
| 7 | + |
| 8 | +env: |
| 9 | + add_binaries_to_github_release: true |
| 10 | + use_git_lfs: true |
| 11 | + |
| 12 | +jobs: |
| 13 | + release-linux: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + binary: [client, server] |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: olegtarasov/get-tag@v2.1.2 |
| 21 | + id: get_version |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + lfs: ${{ env.use_git_lfs }} |
| 25 | + - uses: dtolnay/rust-toolchain@stable |
| 26 | + with: |
| 27 | + targets: x86_64-unknown-linux-gnu |
| 28 | + - name: install dependencies |
| 29 | + run: | |
| 30 | + sudo apt-get update; sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev |
| 31 | +
|
| 32 | + - name: Build |
| 33 | + run: | |
| 34 | + cargo build --release --target x86_64-unknown-linux-gnu --bin ${{ matrix.binary }} |
| 35 | +
|
| 36 | + - name: Prepare package |
| 37 | + run: | |
| 38 | + mkdir linux |
| 39 | + cp target/x86_64-unknown-linux-gnu/release/${{ matrix.binary }} linux/ |
| 40 | + cp -r assets linux/ || true # Try to copy, but ignore if it can't copy if source directory does not exist |
| 41 | +
|
| 42 | + - name: Package as a zip |
| 43 | + working-directory: ./linux |
| 44 | + run: | |
| 45 | + zip --recurse-paths ../${{ matrix.binary }}.zip . |
| 46 | +
|
| 47 | + - name: Upload binaries to artifacts |
| 48 | + uses: actions/upload-artifact@v3 |
| 49 | + with: |
| 50 | + path: ${{ matrix.binary }}.zip |
| 51 | + name: linux-${{ matrix.binary }} |
| 52 | + retention-days: 1 |
| 53 | + |
| 54 | + - name: Upload binaries to release |
| 55 | + if: ${{ env.add_binaries_to_github_release == 'true' }} |
| 56 | + uses: svenstaro/upload-release-action@v2 |
| 57 | + with: |
| 58 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + file: ${{ matrix.binary }}.zip |
| 60 | + asset_name: ${{ matrix.binary }}-linux-${{ steps.get_version.outputs.tag }}.zip |
| 61 | + tag: ${{ github.ref }} |
| 62 | + overwrite: true |
| 63 | + |
| 64 | + release-windows: |
| 65 | + runs-on: windows-latest |
| 66 | + strategy: |
| 67 | + matrix: |
| 68 | + binary: [client, server] |
| 69 | + |
| 70 | + steps: |
| 71 | + - uses: olegtarasov/get-tag@v2.1.2 |
| 72 | + id: get_version |
| 73 | + - uses: actions/checkout@v4 |
| 74 | + with: |
| 75 | + lfs: ${{ env.use_git_lfs }} |
| 76 | + - uses: dtolnay/rust-toolchain@stable |
| 77 | + with: |
| 78 | + targets: x86_64-pc-windows-msvc |
| 79 | + |
| 80 | + - name: Build |
| 81 | + run: | |
| 82 | + cargo build --release --target x86_64-pc-windows-msvc --bin ${{ matrix.binary }} |
| 83 | +
|
| 84 | + - name: Prepare package |
| 85 | + run: | |
| 86 | + mkdir windows |
| 87 | + cp target/x86_64-pc-windows-msvc/release/${{ matrix.binary }}.exe windows/ |
| 88 | + mkdir assets -ea 0 # create the assets directory if it does not exist, it will get ignored in the zip if empty |
| 89 | + cp -r assets windows/ |
| 90 | +
|
| 91 | + - name: Package as a zip |
| 92 | + run: | |
| 93 | + Compress-Archive -Path windows/* -DestinationPath ${{ matrix.binary }}.zip |
| 94 | +
|
| 95 | + - name: Upload binaries to artifacts |
| 96 | + uses: actions/upload-artifact@v3 |
| 97 | + with: |
| 98 | + path: ${{ matrix.binary }}.zip |
| 99 | + name: windows-${{ matrix.binary }} |
| 100 | + retention-days: 1 |
| 101 | + |
| 102 | + - name: Upload binaries to release |
| 103 | + if: ${{ env.add_binaries_to_github_release == 'true' }} |
| 104 | + uses: svenstaro/upload-release-action@v2 |
| 105 | + with: |
| 106 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 107 | + file: ${{ matrix.binary }}.zip |
| 108 | + asset_name: ${{ matrix.binary }}-windows-${{ steps.get_version.outputs.tag }}.zip |
| 109 | + tag: ${{ github.ref }} |
| 110 | + overwrite: true |
| 111 | + |
| 112 | + release-macOS-intel: |
| 113 | + runs-on: macOS-latest |
| 114 | + strategy: |
| 115 | + matrix: |
| 116 | + binary: [client, server] |
| 117 | + |
| 118 | + steps: |
| 119 | + - uses: olegtarasov/get-tag@v2.1.2 |
| 120 | + id: get_version |
| 121 | + - uses: actions/checkout@v4 |
| 122 | + with: |
| 123 | + lfs: ${{ env.use_git_lfs }} |
| 124 | + - uses: dtolnay/rust-toolchain@stable |
| 125 | + with: |
| 126 | + targets: x86_64-apple-darwin |
| 127 | + - name: Environment Setup |
| 128 | + run: | |
| 129 | + export CFLAGS="-fno-stack-check" |
| 130 | + export MACOSX_DEPLOYMENT_TARGET="10.9" |
| 131 | +
|
| 132 | + - name: Build |
| 133 | + run: | |
| 134 | + cargo build --release --target x86_64-apple-darwin --bin ${{ matrix.binary }} |
| 135 | +
|
| 136 | + - name: Prepare Package |
| 137 | + run: | |
| 138 | + mkdir -p ${{ matrix.binary }}.app/Contents/MacOS |
| 139 | + cp target/x86_64-apple-darwin/release/${{ matrix.binary }} ${{ matrix.binary }}.app/Contents/MacOS/ |
| 140 | + cp -r assets ${{ matrix.binary }}.app/Contents/MacOS/ || true # Try to copy, but ignore if it can't copy if source directory does not exist |
| 141 | + hdiutil create -fs HFS+ -volname "${{ matrix.binary }}" -srcfolder ${{ matrix.binary }}.app ${{ matrix.binary }}-macOS-intel.dmg |
| 142 | +
|
| 143 | + - name: Upload binaries to artifacts |
| 144 | + uses: actions/upload-artifact@v3 |
| 145 | + with: |
| 146 | + path: ${{ matrix.binary }}-macOS-intel.dmg |
| 147 | + name: macOS-intel-${{ matrix.binary }} |
| 148 | + retention-days: 1 |
| 149 | + |
| 150 | + - name: Upload binaries to release |
| 151 | + if: ${{ env.add_binaries_to_github_release == 'true' }} |
| 152 | + uses: svenstaro/upload-release-action@v2 |
| 153 | + with: |
| 154 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 155 | + file: ${{ matrix.binary }}-macOS-intel.dmg |
| 156 | + asset_name: ${{ matrix.binary }}-macOS-intel-${{ steps.get_version.outputs.tag }}.dmg |
| 157 | + tag: ${{ github.ref }} |
| 158 | + overwrite: true |
| 159 | + |
| 160 | + release-macOS-apple-silicon: |
| 161 | + runs-on: macOS-latest |
| 162 | + strategy: |
| 163 | + matrix: |
| 164 | + binary: [client, server] |
| 165 | + |
| 166 | + steps: |
| 167 | + - uses: olegtarasov/get-tag@v2.1.2 |
| 168 | + id: get_version |
| 169 | + - uses: actions/checkout@v4 |
| 170 | + with: |
| 171 | + lfs: ${{ env.use_git_lfs }} |
| 172 | + - uses: dtolnay/rust-toolchain@stable |
| 173 | + with: |
| 174 | + targets: aarch64-apple-darwin |
| 175 | + - name: Environment |
| 176 | + run: | |
| 177 | + export MACOSX_DEPLOYMENT_TARGET="11" |
| 178 | +
|
| 179 | + - name: Build |
| 180 | + run: | |
| 181 | + cargo build --release --target aarch64-apple-darwin --bin ${{ matrix.binary }} |
| 182 | +
|
| 183 | + - name: Prepare Package |
| 184 | + run: | |
| 185 | + mkdir -p ${{ matrix.binary }}.app/Contents/MacOS |
| 186 | + cp target/aarch64-apple-darwin/release/${{ matrix.binary }} ${{ matrix.binary }}.app/Contents/MacOS/ |
| 187 | + cp -r assets ${{ matrix.binary }}.app/Contents/MacOS/ || true # Try to copy, but ignore if it can't copy if source directory does not exist |
| 188 | + - name: Create DMG |
| 189 | + run: | |
| 190 | + hdiutil create -fs HFS+ -volname "${{ matrix.binary }}-macOS-apple-silicon" -srcfolder ${{ matrix.binary }}.app ${{ matrix.binary }}-macOS-apple-silicon.dmg |
| 191 | +
|
| 192 | + - name: Verify DMG |
| 193 | + run: | |
| 194 | + hdiutil verify ${{ matrix.binary }}-macOS-apple-silicon.dmg |
| 195 | + - name: Upload binaries to artifacts |
| 196 | + uses: actions/upload-artifact@v3 |
| 197 | + with: |
| 198 | + path: ${{ matrix.binary }}-macOS-apple-silicon.dmg |
| 199 | + name: macOS-apple-silicon-${{ matrix.binary }} |
| 200 | + retention-days: 1 |
| 201 | + |
| 202 | + - name: Upload binaries to release |
| 203 | + if: ${{ env.add_binaries_to_github_release == 'true' }} |
| 204 | + uses: svenstaro/upload-release-action@v2 |
| 205 | + with: |
| 206 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 207 | + file: ${{ matrix.binary }}-macOS-apple-silicon.dmg |
| 208 | + asset_name: ${{ matrix.binary }}-macOS-apple-silicon-${{ steps.get_version.outputs.tag }}.dmg |
| 209 | + tag: ${{ github.ref }} |
| 210 | + overwrite: true |
0 commit comments