diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..7256921 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,39 @@ +name: OpenTK SDL Redistributable + +on: + workflow_dispatch: + inputs: + push: + branches: + - main + - develop +jobs: + build: + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest] + + steps: + - name: Install X11 dependencies + run: | + sudo apt-get update + sudo apt-get install xorg-dev + - uses: actions/checkout@v3 + - name: Setup .NET Core + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + - name: Download dependencies and create Nuget Package + run: ./make_nuget.ps1 "" ${{ github.run_number }} + shell: pwsh + - uses: actions/upload-artifact@v3 + with: + name: NugetPackage + path: ./artifacts/*.nupkg + - name: Deploy Nuget Package + run: dotnet nuget push ./artifacts/*.nupkg -k $NUGET_API_KEY -s https://api.nuget.org/v3/index.json \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3260178 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +/bin +/obj +/docs +/include +/*.nupkg +/artifacts/ +/bin/ +/obj/ +/tmp/ +/desktop.ini \ No newline at end of file diff --git a/_._ b/_._ new file mode 100644 index 0000000..e69de29 diff --git a/download_dependencies.ps1 b/download_dependencies.ps1 new file mode 100644 index 0000000..5422478 --- /dev/null +++ b/download_dependencies.ps1 @@ -0,0 +1,56 @@ +Param([parameter(Mandatory=$true,Position=0)][String]$SDL_VERSION) + +# FIXME: Get out the major version so we can do SDL2 and SDL3 + +New-Item -ItemType Directory -Force -Path tmp + +try{ + Invoke-WebRequest -Uri https://opentk.net/assets/opentk.png -OutFile tmp/opentk.png -Resume +} catch [System.NullReferenceException] { +} + +try{ + Invoke-WebRequest -Uri https://github.com/libsdl-org/SDL/releases/download/release-$SDL_VERSION/SDL2-$SDL_VERSION-win32-x86.zip -OutFile tmp/win32-x86.zip -Resume +} catch [System.NullReferenceException] { +} +try{ + Invoke-WebRequest -Uri https://github.com/libsdl-org/SDL/releases/download/release-$SDL_VERSION/SDL2-$SDL_VERSION-win32-x64.zip -OutFile tmp/win32-x64.zip -Resume +} catch [System.NullReferenceException] { +} + +try{ + + Invoke-WebRequest -Uri https://github.com/libsdl-org/SDL/releases/download/release-$SDL_VERSION/SDL2-$SDL_VERSION.dmg -OutFile tmp/macos.dmg -Resume +} catch [System.NullReferenceException] { +} + +try{ + Invoke-WebRequest -Uri https://github.com/libsdl-org/SDL/releases/download/release-$SDL_VERSION/SDL2-$SDL_VERSION.zip -OutFile tmp/source.zip -Resume +} catch [System.NullReferenceException] { +} + +Expand-Archive -Path tmp/win32-x86.zip -DestinationPath tmp/win32-x86/ -Force +Expand-Archive -Path tmp/win32-x64.zip -DestinationPath tmp/win32-x64/ -Force +Expand-Archive -Path tmp/source.zip -DestinationPath tmp/ -Force +if (Test-Path tmp/src) { + Remove-Item -Recurse -Path tmp/src +} +Rename-Item -Path tmp/SDL2-$SDL_VERSION -NewName src + +mkdir tmp/src/build +pushd tmp/src/ +cmake -S . -B build && cmake --build build && cmake --install build + +#cmake -DCMAKE_BUILD_TYPE=Release -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON .. + +if ($LastExitCode -ne 0) { + throw 'SDL compilation setup failed' +} + +make -j + +if ($LastExitCode -ne 0) { + throw 'SDL compilation failed' +} + +popd \ No newline at end of file diff --git a/make_nuget.ps1 b/make_nuget.ps1 new file mode 100644 index 0000000..894fd63 --- /dev/null +++ b/make_nuget.ps1 @@ -0,0 +1,35 @@ +param([String]$projectDir, [int]$verBuild) + +$ErrorActionPreference = "Stop" +[String]$SDL_VERSION="2.26.5" + +# The built .so file will end in .so.3.3 for a version like 3.3.7, to get the correct file we need to pass "3.3" to the .csproj +# [String]$GLFW_SHORT_VERSION = $GLFW_VERSION.Substring(0, $GLFW_VERSION.LastIndexOf(".")) + +$buildVersionResult = $verBuild.ToString() +$currentBranch=(git branch --show-current) +Write-Output "Current Branch: $currentBranch" + +if($currentBranch -eq "develop") { + $buildVersionResult = "0-pre" + (Get-Date).ToUniversalTime().ToString("yyyyMMddHHmmss") +} + + +./download_dependencies.ps1 $SDL_VERSION + +return +# FIXME! +$header = Get-Content([System.IO.Path]::Combine($projectDir, ".\tmp\src\include\SDL\sdl.h")) | Out-String + +if ($header -match '(?m)^#define\s+GLFW_VERSION_MAJOR\s+(\d+)\s*$') { $verMajor = $Matches[1] } +else { throw "Failed to parse major version number from header." } +if ($header -match '(?m)^#define\s+GLFW_VERSION_MINOR\s+(\d+)\s*$') { $verMinor = $Matches[1] } +else { throw "Failed to parse minor version number from header." } +if ($header -match '(?m)^#define\s+GLFW_VERSION_REVISION\s+(\d+)\s*$') { $verPatch = $Matches[1] } +else { throw "Failed to parse patch version number from header." } + +$version = "$verMajor.$verMinor.$verPatch.$buildVersionResult" + +$nuspec = [System.IO.Path]::Combine($projectDir, ".\sdl-redist.csproj") + +dotnet pack $nuspec -c Release -p:VERSION="$version" -p:GLFW_VERSION="$GLFW_VERSION" -p:GLFW_SHORT_VERSION="$GLFW_SHORT_VERSION" -o ./artifacts \ No newline at end of file diff --git a/sdl-redist.csproj b/sdl-redist.csproj new file mode 100644 index 0000000..58703fa --- /dev/null +++ b/sdl-redist.csproj @@ -0,0 +1,61 @@ + + + netstandard2.0 + true + false + false + win-x86;win-x64;osx-x64;osx-arm64;linux-x64 + false + $(VERSION) + + https://www.libsdl.org/ + COPYING.md + + OpenTK.redist.sdl + Team OpenTK + Team OpenTK + SDL redistributables for OpenTK. + opentk.png + + + + runtimes/win-x64/native/ + true + PreserveNewest + + + runtimes/win-x86/native/ + true + PreserveNewest + + + runtimes/osx-x64/native/ + true + PreserveNewest + + + runtimes/osx-arm64/native/ + true + PreserveNewest + + + runtimes/linux-x64/native/ + true + PreserveNewest + + + + COPYING.md + true + + + + + + lib/netstandard2.0/_._ + + + \ No newline at end of file