|
7 | 7 |
|
8 | 8 | permissions: |
9 | 9 | contents: write |
10 | | - |
| 10 | + |
11 | 11 | jobs: |
12 | 12 | release: |
13 | 13 | name: Build and Release |
14 | | - runs-on: ubuntu-latest |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + os: [ubuntu-latest, windows-latest] |
| 19 | + preset: [linux-release, x64-release] |
| 20 | + exclude: |
| 21 | + - os: windows-latest |
| 22 | + preset: linux-release |
| 23 | + - os: ubuntu-latest |
| 24 | + preset: x64-release |
15 | 25 |
|
16 | 26 | steps: |
17 | | - - name: Checkout source code |
| 27 | + - name: Checkout source |
18 | 28 | uses: actions/checkout@v3 |
19 | 29 |
|
20 | 30 | - name: Set up CMake |
21 | 31 | uses: jwlawson/actions-setup-cmake@v1.14 |
22 | 32 | with: |
23 | 33 | cmake-version: '3.25.2' |
24 | 34 |
|
25 | | - - name: Install Ninja |
26 | | - run: sudo apt-get update && sudo apt-get install -y ninja-build |
| 35 | + - name: Install Ninja + Zip tools |
| 36 | + if: matrix.os == 'ubuntu-latest' |
| 37 | + run: sudo apt-get update && sudo apt-get install -y ninja-build zip |
| 38 | + |
| 39 | + - name: Configure with CMake preset |
| 40 | + run: cmake --preset=${{ matrix.preset }} |
| 41 | + shell: bash |
27 | 42 |
|
28 | | - - name: Configure with CMake |
29 | | - run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release |
| 43 | + - name: Determine build config |
| 44 | + id: config |
| 45 | + run: | |
| 46 | + if [[ "${{ matrix.preset }}" == *release* ]]; then |
| 47 | + echo "config=Release" >> $GITHUB_OUTPUT |
| 48 | + else |
| 49 | + echo "config=Debug" >> $GITHUB_OUTPUT |
| 50 | + fi |
| 51 | + shell: bash |
30 | 52 |
|
31 | | - - name: Build Tiny BPE Trainer |
32 | | - run: cmake --build build |
| 53 | + - name: Build project |
| 54 | + run: | |
| 55 | + if [[ "${{ matrix.os }}" == "windows-latest" ]]; then |
| 56 | + cmake --build out/build/${{ matrix.preset }} --config ${{ steps.config.outputs.config }} |
| 57 | + else |
| 58 | + cmake --build out/build/${{ matrix.preset }} |
| 59 | + fi |
| 60 | + shell: bash |
33 | 61 |
|
34 | | - - name: Create GitHub Release |
| 62 | + - name: Rename and zip binary |
| 63 | + run: | |
| 64 | + if [[ "${{ matrix.os }}" == "windows-latest" ]]; then |
| 65 | + cp out/build/${{ matrix.preset }}/${{ steps.config.outputs.config }}/Tiny-BPE-Trainer.exe Tiny-BPE-Trainer-windows.exe |
| 66 | + powershell -Command "Compress-Archive -Path Tiny-BPE-Trainer-windows.exe -DestinationPath Tiny-BPE-Trainer-windows.zip" |
| 67 | + else |
| 68 | + cp out/build/${{ matrix.preset }}/Tiny-BPE-Trainer Tiny-BPE-Trainer-linux |
| 69 | + zip Tiny-BPE-Trainer-linux.zip Tiny-BPE-Trainer-linux |
| 70 | + fi |
| 71 | + shell: bash |
| 72 | + |
| 73 | + - name: Upload zipped binary |
35 | 74 | uses: softprops/action-gh-release@v1 |
36 | 75 | with: |
37 | | - generate_release_notes: true |
| 76 | + files: Tiny-BPE-Trainer-*.zip |
38 | 77 | env: |
39 | 78 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
40 | 79 |
|
41 | | - - name: Upload Release Asset |
| 80 | + - name: Create GitHub Release (only once) |
| 81 | + if: matrix.os == 'ubuntu-latest' |
42 | 82 | uses: softprops/action-gh-release@v1 |
43 | 83 | with: |
44 | | - files: | |
45 | | - build/Tiny-BPE-Trainer |
| 84 | + generate_release_notes: true |
46 | 85 | env: |
47 | 86 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments