|
1 | | -name: Build |
| 1 | +name: Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_dispatch |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + id-token: write |
| 11 | + attestations: write |
| 12 | + |
5 | 13 | jobs: |
6 | 14 | build: |
7 | 15 | runs-on: ${{ matrix.os }} |
@@ -34,68 +42,98 @@ jobs: |
34 | 42 | c_compiler: cl |
35 | 43 |
|
36 | 44 | steps: |
37 | | - - name: Install dependencies (Linux) |
38 | | - if: matrix.os == 'ubuntu-latest' |
39 | | - run: > |
40 | | - sudo apt-get update && sudo apt-get install -y |
41 | | - build-essential cmake clang libx11-dev libxrandr-dev |
42 | | - libxinerama-dev libxcursor-dev libxi-dev libgl1-mesa-dev |
43 | | - libwayland-dev wayland-protocols libxkbcommon-dev pkg-config |
44 | | -
|
45 | | - - name: Checkout source |
46 | | - uses: actions/checkout@v4 |
47 | | - with: |
48 | | - submodules: recursive |
49 | | - |
50 | | - - name: Configure CMake for GLFW |
51 | | - run: > |
52 | | - cmake -S ${{ github.workspace }}/glfw -B ${{ github.workspace }}/glfw/build |
53 | | - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} |
54 | | - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} |
55 | | - -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/glfw/install |
56 | | - -DBUILD_SHARED_LIBS=OFF |
57 | | - -DGLFW_BUILD_EXAMPLES=OFF |
58 | | - -DGLFW_BUILD_TESTS=OFF |
59 | | - -DGLFW_BUILD_DOCS=OFF |
60 | | - -DGLFW_INSTALL=ON |
61 | | - ${{ matrix.generator_args }} |
62 | | -
|
63 | | - - name: Build and install GLFW |
64 | | - run: | |
65 | | - cmake --build ${{ github.workspace }}/glfw/build --config ${{ matrix.build_type }} |
66 | | - cmake --install ${{ github.workspace }}/glfw/build --config ${{ matrix.build_type }} |
67 | | -
|
68 | | - - name: Configure Snake |
69 | | - run: > |
70 | | - cmake -S ${{ github.workspace }}/Snake -B ${{ github.workspace }}/Snake/build |
71 | | - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} |
72 | | - -DGLFW_INCLUDE_DIR=${{ github.workspace }}/glfw/install/include |
73 | | - -DGLFW_LIB_DIR=${{ github.workspace }}/glfw/install/lib |
74 | | - ${{ matrix.generator_args }} |
75 | | -
|
76 | | - - name: Build Snake |
77 | | - run: > |
78 | | - cmake --build ${{ github.workspace }}/Snake/build |
79 | | - --config ${{ matrix.build_type }} |
80 | | - --target Snake |
81 | | -
|
82 | | - - name: Prepare artifact directory |
83 | | - shell: bash |
84 | | - run: | |
85 | | - mkdir -p artifact |
86 | | - # Copy executable (platform-specific) |
87 | | - if [ -f "${{ github.workspace }}/Snake/build/${{ matrix.build_type }}/Snake.exe" ]; then |
88 | | - cp "${{ github.workspace }}/Snake/build/${{ matrix.build_type }}/Snake.exe" artifact/ |
89 | | - elif [ -f "${{ github.workspace }}/Snake/build/Snake" ]; then |
90 | | - cp "${{ github.workspace }}/Snake/build/Snake" artifact/ |
91 | | - fi |
92 | | - # Copy Assets and Shaders directories |
93 | | - cp -r "${{ github.workspace }}/Snake/Assets" artifact/ |
94 | | - cp -r "${{ github.workspace }}/Snake/Shaders" artifact/ |
95 | | -
|
96 | | - - name: Upload artifact |
97 | | - uses: actions/upload-artifact@v4 |
98 | | - with: |
99 | | - name: Snake-${{ matrix.os }} |
100 | | - path: artifact/ |
| 45 | + - name: Install dependencies (Linux) |
| 46 | + if: matrix.os == 'ubuntu-latest' |
| 47 | + run: > |
| 48 | + sudo apt-get update && sudo apt-get install -y |
| 49 | + build-essential cmake clang libx11-dev libxrandr-dev |
| 50 | + libxinerama-dev libxcursor-dev libxi-dev libgl1-mesa-dev |
| 51 | + libwayland-dev wayland-protocols libxkbcommon-dev pkg-config |
| 52 | +
|
| 53 | + - name: Checkout |
| 54 | + uses: actions/checkout@v6 |
| 55 | + with: |
| 56 | + submodules: recursive |
| 57 | + |
| 58 | + - name: Cache GLFW |
| 59 | + id: cache-glfw |
| 60 | + uses: actions/cache@v5 |
| 61 | + with: |
| 62 | + path: | |
| 63 | + ${{ github.workspace }}/glfw/build |
| 64 | + ${{ github.workspace }}/glfw/install |
| 65 | + key: glfw-${{ runner.os }}-${{ matrix.c_compiler }}-${{ hashFiles('glfw/**') }} |
| 66 | + |
| 67 | + - name: Configure CMake for GLFW |
| 68 | + if: steps.cache-glfw.outputs.cache-hit != 'true' |
| 69 | + run: > |
| 70 | + cmake -S ${{ github.workspace }}/glfw -B ${{ github.workspace }}/glfw/build |
| 71 | + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} |
| 72 | + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} |
| 73 | + -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/glfw/install |
| 74 | + -DBUILD_SHARED_LIBS=OFF |
| 75 | + -DGLFW_BUILD_EXAMPLES=OFF |
| 76 | + -DGLFW_BUILD_TESTS=OFF |
| 77 | + -DGLFW_BUILD_DOCS=OFF |
| 78 | + -DGLFW_INSTALL=ON |
| 79 | + ${{ matrix.generator_args }} |
| 80 | +
|
| 81 | + - name: Build and install GLFW |
| 82 | + if: steps.cache-glfw.outputs.cache-hit != 'true' |
| 83 | + run: | |
| 84 | + cmake --build ${{ github.workspace }}/glfw/build --config ${{ matrix.build_type }} |
| 85 | + cmake --install ${{ github.workspace }}/glfw/build --config ${{ matrix.build_type }} |
| 86 | +
|
| 87 | + - name: Configure Snake |
| 88 | + run: > |
| 89 | + cmake -S ${{ github.workspace }}/Snake -B ${{ github.workspace }}/Snake/build |
| 90 | + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} |
| 91 | + -DGLFW_INCLUDE_DIR=${{ github.workspace }}/glfw/install/include |
| 92 | + -DGLFW_LIB_DIR=${{ github.workspace }}/glfw/install/lib |
| 93 | + ${{ matrix.generator_args }} |
| 94 | +
|
| 95 | + - name: Build Snake |
| 96 | + run: > |
| 97 | + cmake --build ${{ github.workspace }}/Snake/build |
| 98 | + --config ${{ matrix.build_type }} |
| 99 | + --target Snake |
| 100 | +
|
| 101 | + - name: Prepare artifact directory |
| 102 | + shell: bash |
| 103 | + run: | |
| 104 | + mkdir -p artifact |
| 105 | + # Copy executable (platform-specific) |
| 106 | + if [ -f "${{ github.workspace }}/Snake/build/${{ matrix.build_type }}/Snake.exe" ]; then |
| 107 | + cp "${{ github.workspace }}/Snake/build/${{ matrix.build_type }}/Snake.exe" artifact/ |
| 108 | + elif [ -f "${{ github.workspace }}/Snake/build/Snake" ]; then |
| 109 | + cp "${{ github.workspace }}/Snake/build/Snake" artifact/ |
| 110 | + fi |
| 111 | + # Copy Assets and Shaders directories |
| 112 | + cp -r "${{ github.workspace }}/Snake/Assets" artifact/ |
| 113 | + cp -r "${{ github.workspace }}/Snake/Shaders" artifact/ |
| 114 | +
|
| 115 | + - name: Attest build provenance |
| 116 | + uses: actions/attest-build-provenance@v3 |
| 117 | + with: |
| 118 | + subject-path: "artifact/*" |
| 119 | + |
| 120 | + - name: Create release archive |
| 121 | + shell: bash |
| 122 | + run: | |
| 123 | + cd artifact |
| 124 | + if [ "${{ matrix.os }}" == "windows-latest" ]; then |
| 125 | + 7z a ../Snake-${{ matrix.os }}.zip * |
| 126 | + else |
| 127 | + tar -czf ../Snake-${{ matrix.os }}.tar.gz * |
| 128 | + fi |
| 129 | +
|
| 130 | + - name: Upload artifact to release |
| 131 | + uses: softprops/action-gh-release@v2 |
| 132 | + if: github.ref_type == 'tag' |
| 133 | + with: |
| 134 | + files: | |
| 135 | + Snake-${{ matrix.os }}.* |
| 136 | + generate_release_notes: true |
| 137 | + env: |
| 138 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
101 | 139 |
|
0 commit comments