| 1 | name: Build raylib - Windows |
| 2 | |
| 3 | on: |
| 4 | workflow_dispatch: |
| 5 | push: |
| 6 | paths: |
| 7 | - 'src/**' |
| 8 | - 'examples/**' |
| 9 | - '.github/workflows/windows.yml' |
| 10 | pull_request: |
| 11 | paths: |
| 12 | - 'src/**' |
| 13 | - 'examples/**' |
| 14 | - '.github/workflows/windows.yml' |
| 15 | release: |
| 16 | types: [published] |
| 17 | |
| 18 | permissions: |
| 19 | contents: read |
| 20 | |
| 21 | jobs: |
| 22 | build: |
| 23 | permissions: |
| 24 | contents: write # for actions/upload-release-asset to upload release asset |
| 25 | runs-on: windows-latest |
| 26 | strategy: |
| 27 | fail-fast: false |
| 28 | max-parallel: 1 |
| 29 | matrix: |
| 30 | compiler: [mingw-w64, msvc16] |
| 31 | ziptarget: [ win32, win64, winarm64 ] |
| 32 | include: |
| 33 | - compiler: mingw-w64 |
| 34 | ARCH: "i686" |
| 35 | WINDRES_ARCH: pe-i386 |
| 36 | ziptarget: "win32" |
| 37 | - compiler: mingw-w64 |
| 38 | ARCH: "x86_64" |
| 39 | WINDRES_ARCH: pe-x86-64 |
| 40 | ziptarget: "win64" |
| 41 | - compiler: msvc16 |
| 42 | ARCH: "x86" |
| 43 | VSARCHPATH: "Win32" |
| 44 | ziptarget: "win32" |
| 45 | - compiler: msvc16 |
| 46 | ARCH: "x64" |
| 47 | VSARCHPATH: "x64" |
| 48 | ziptarget: "win64" |
| 49 | - compiler: msvc16 |
| 50 | ARCH: "ARM64" |
| 51 | VSARCHPATH: "ARM64" |
| 52 | ziptarget: "winarm64" |
| 53 | exclude: |
| 54 | - compiler: mingw-w64 |
| 55 | ziptarget: winarm64 # We don't build arm64 with mingw-w64 yet |
| 56 | |
| 57 | env: |
| 58 | RELEASE_NAME: raylib-dev_${{ matrix.ziptarget }}_${{ matrix.compiler }} |
| 59 | GNUTARGET: default |
| 60 | |
| 61 | steps: |
| 62 | - name: Checkout |
| 63 | uses: actions/checkout@master |
| 64 | |
| 65 | - name: Setup Release Version |
| 66 | run: | |
| 67 | echo "RELEASE_NAME=raylib-${{ github.event.release.tag_name }}_${{ matrix.ziptarget }}_${{ matrix.compiler }}" >> $GITHUB_ENV |
| 68 | shell: bash |
| 69 | if: github.event_name == 'release' && github.event.action == 'published' |
| 70 | |
| 71 | - name: Setup Environment |
| 72 | run: | |
| 73 | dir |
| 74 | mkdir build |
| 75 | cd build |
| 76 | mkdir ${{ env.RELEASE_NAME }} |
| 77 | cd ${{ env.RELEASE_NAME }} |
| 78 | mkdir include |
| 79 | mkdir lib |
| 80 | cd ../../../raylib |
| 81 | |
| 82 | # Setup MSBuild.exe path if required |
| 83 | - name: Setup MSBuild |
| 84 | uses: microsoft/setup-msbuild@v2 |
| 85 | if: matrix.compiler == 'msvc16' |
| 86 | |
| 87 | - name: Build Library (MinGW-w64 32bit) |
| 88 | run: | |
| 89 | cd src |
| 90 | x86_64-w64-mingw32-gcc.exe --version |
| 91 | windres.exe --version |
| 92 | dir C:\msys64\mingw64\bin |
| 93 | make PLATFORM=PLATFORM_DESKTOP CC=x86_64-w64-mingw32-gcc.exe RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CUSTOM_CFLAGS=-m32 |
| 94 | //windres.exe -i raylib.dll.rc -o raylib.dll.rc.data -O coff --target=${{ matrix.WINDRES_ARCH }} |
| 95 | //make PLATFORM=PLATFORM_DESKTOP CC=${{ matrix.ARCH }}-w64-mingw32-gcc.exe RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B |
| 96 | cd .. |
| 97 | shell: cmd |
| 98 | if: | |
| 99 | matrix.compiler == 'mingw-w64' && |
| 100 | matrix.arch == 'i686' |
| 101 | |
| 102 | - name: Build Library (MinGW-w64 64bit) |
| 103 | run: | |
| 104 | cd src |
| 105 | ${{ matrix.ARCH }}-w64-mingw32-gcc.exe --version |
| 106 | windres.exe --version |
| 107 | dir C:\msys64\mingw64\bin |
| 108 | make PLATFORM=PLATFORM_DESKTOP CC=${{ matrix.ARCH }}-w64-mingw32-gcc.exe RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" |
| 109 | windres.exe -i raylib.dll.rc -o raylib.dll.rc.data -O coff --target=${{ matrix.WINDRES_ARCH }} |
| 110 | make PLATFORM=PLATFORM_DESKTOP CC=${{ matrix.ARCH }}-w64-mingw32-gcc.exe RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B |
| 111 | cd .. |
| 112 | shell: cmd |
| 113 | if: | |
| 114 | matrix.compiler == 'mingw-w64' && |
| 115 | matrix.arch == 'x86_64' |
| 116 | |
| 117 | - name: Build Library (MSVC16) |
| 118 | run: | |
| 119 | cd projects/VS2022 |
| 120 | msbuild.exe raylib.sln /target:raylib /property:Configuration=Release /property:Platform=${{ matrix.ARCH }} |
| 121 | copy /Y .\build\raylib\bin\${{ matrix.VSARCHPATH }}\Release\raylib.lib .\..\..\build\${{ env.RELEASE_NAME }}\lib\raylib.lib |
| 122 | msbuild.exe raylib.sln /target:raylib /property:Configuration=Release.DLL /property:Platform=${{ matrix.ARCH }} |
| 123 | copy /Y .\build\raylib\bin\${{ matrix.VSARCHPATH }}\Release.DLL\raylib.dll .\..\..\build\${{ env.RELEASE_NAME }}\lib\raylib.dll |
| 124 | copy /Y .\build\raylib\bin\${{ matrix.VSARCHPATH }}\Release.DLL\raylib.lib .\..\..\build\${{ env.RELEASE_NAME }}\lib\raylibdll.lib |
| 125 | cd ../.. |
| 126 | shell: cmd |
| 127 | if: matrix.compiler == 'msvc16' |
| 128 | |
| 129 | - name: Generate Artifacts |
| 130 | run: | |
| 131 | copy /Y .\src\raylib.h .\build\${{ env.RELEASE_NAME }}\include\raylib.h |
| 132 | copy /Y .\src\raymath.h .\build\${{ env.RELEASE_NAME }}\include\raymath.h |
| 133 | copy /Y .\src\rlgl.h .\build\${{ env.RELEASE_NAME }}\include\rlgl.h |
| 134 | copy /Y .\CHANGELOG .\build\${{ env.RELEASE_NAME }}\CHANGELOG |
| 135 | copy /Y .\README.md .\build\${{ env.RELEASE_NAME }}\README.md |
| 136 | copy /Y .\LICENSE .\build\${{ env.RELEASE_NAME }}\LICENSE |
| 137 | cd build |
| 138 | 7z a ./${{ env.RELEASE_NAME }}.zip ./${{ env.RELEASE_NAME }} |
| 139 | dir |
| 140 | shell: cmd |
| 141 | |
| 142 | - name: Upload Artifacts |
| 143 | uses: actions/upload-artifact@v4 |
| 144 | with: |
| 145 | name: ${{ env.RELEASE_NAME }} |
| 146 | path: | |
| 147 | ./build/${{ env.RELEASE_NAME }} |
| 148 | !./build/${{ env.RELEASE_NAME }}.zip |
| 149 | |
| 150 | - name: Upload Artifact to Release |
| 151 | uses: softprops/action-gh-release@v1 |
| 152 | with: |
| 153 | files: ./build/${{ env.RELEASE_NAME }}.zip |
| 154 | env: |
| 155 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 156 | if: github.event_name == 'release' && github.event.action == 'published' |