From 7fd47811cb017e1fc7abea8bec8628d33829187b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Sun, 28 Jan 2024 16:32:43 +0100 Subject: [PATCH] Add GitHub Actions workflow for NuGet release --- .github/workflows/nuget.yml | 252 ++++++++++++++++++++++++++++++++++++ tools/nuget/build.docker.sh | 27 +++- tools/nuget/build.linux.sh | 4 +- tools/nuget/build.macos.sh | 4 +- tools/nuget/build.win.ps1 | 4 +- 5 files changed, 285 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/nuget.yml diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml new file mode 100644 index 0000000..ec05f99 --- /dev/null +++ b/.github/workflows/nuget.yml @@ -0,0 +1,252 @@ +name: NuGet Release + +on: + push: + branches: + - master + - 2.6.x + workflow_dispatch: {} + +concurrency: + group: nuget-${{github.ref}} + cancel-in-progress: true + +env: + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + +jobs: + windows: + name: Windows VS2022 + runs-on: windows-2022 + + steps: + - name: Checkout CSFML + uses: actions/checkout@v4 + with: + path: CSFML + + - name: Build x86 + shell: pwsh + run: | + cd CSFML/tools/nuget + ./build.win.ps1 "win-x86" + + - name: Build x64 + shell: pwsh + run: | + cd CSFML/tools/nuget + ./build.win.ps1 "win-x64" + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: CSFML-win-x86-x64 + path: CSFML/tools/nuget/CSFML/runtimes + + linux-x64: + name: Linux x64 + runs-on: ubuntu-22.04 + container: + image: ubuntu:22.04 + + steps: + - name: Checkout CSFML + uses: actions/checkout@v4 + with: + path: CSFML + + - name: Build + shell: bash + run: | + cd ./CSFML/tools/nuget + chmod +x ./docker.linux-x64.sh + ./docker.linux-x64.sh + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: CSFML-linux-x64 + path: CSFML/tools/nuget/CSFML/runtimes + + linux-arm: + name: Linux ARM + runs-on: ubuntu-22.04 + + steps: + - name: Checkout CSFML + uses: actions/checkout@v4 + with: + path: CSFML + + - name: Build in an ARM container + uses: uraimo/run-on-arch-action@v2.7.2 + with: + arch: armv7 + distro: ubuntu22.04 + githubToken: ${{ github.token }} + dockerRunArgs: | + --volume "${PWD}/CSFML:/CSFML" + install: | + apt-get update -y + apt-get install -y git libfreetype6-dev xorg-dev libxrandr-dev libxcursor-dev libudev-dev libgl1-mesa-dev libflac-dev libogg-dev libvorbis-dev libopenal-dev cmake g++ + run: | + cd /CSFML/tools/nuget + chmod +x ./build.linux.sh + ./build.linux.sh linux-arm + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: CSFML-linux-arm + path: CSFML/tools/nuget/CSFML/runtimes + + linux-arm64: + name: Linux ARM64 + runs-on: ubuntu-22.04 + + steps: + - name: Checkout CSFML + uses: actions/checkout@v4 + with: + path: CSFML + + - name: Build in an ARM64 container + uses: uraimo/run-on-arch-action@v2.7.2 + with: + arch: aarch64 + distro: ubuntu22.04 + githubToken: ${{ github.token }} + dockerRunArgs: | + --volume "${PWD}/CSFML:/CSFML" + install: | + apt-get update -y + apt-get install -y git libfreetype6-dev xorg-dev libxrandr-dev libxcursor-dev libudev-dev libgl1-mesa-dev libflac-dev libogg-dev libvorbis-dev libopenal-dev cmake g++ + run: | + cd /CSFML/tools/nuget + chmod +x ./build.linux.sh + ./build.linux.sh linux-arm64 + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: CSFML-linux-arm64 + path: CSFML/tools/nuget/CSFML/runtimes + + linux-musl-x64: + name: Linux MUSL x64 + runs-on: ubuntu-22.04 + container: + image: alpine:3.15 + + steps: + - name: Checkout CSFML + uses: actions/checkout@v4 + with: + path: CSFML + + - name: Build + shell: sh + run: | + cd ./CSFML/tools/nuget + chmod +x ./docker.linux-musl-x64.sh + ./docker.linux-musl-x64.sh + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: CSFML-linux-musl-x64 + path: CSFML/tools/nuget/CSFML/runtimes + + fedora-x64: + name: Fedora x64 + runs-on: ubuntu-22.04 + container: + image: fedora:37 + + steps: + - name: Checkout CSFML + uses: actions/checkout@v4 + with: + path: CSFML + + - name: Build + shell: bash + run: | + cd ./CSFML/tools/nuget + chmod +x ./docker.fedora-x64.sh + ./docker.fedora-x64.sh + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: CSFML-fedora-x64 + path: CSFML/tools/nuget/CSFML/runtimes + + macos: + name: macOS + runs-on: macos-14 + + steps: + - name: Checkout CSFML + uses: actions/checkout@v4 + with: + path: CSFML + + - name: Install necessary tooling + run: brew install coreutils + + - name: Build x64 + run: | + cd CSFML/tools/nuget + ./build.macos.sh "osx-x64" + + - name: Build ARM64 + run: | + cd CSFML/tools/nuget + ./build.macos.sh "osx-arm64" + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: CSFML-macOS-x64-arm64 + path: CSFML/tools/nuget/CSFML/runtimes + + package: + name: Package Builds + runs-on: ubuntu-22.04 + needs: + - windows + - linux-x64 + - linux-arm + - linux-arm64 + - linux-musl-x64 + - fedora-x64 + - macos + steps: + - name: Checkout CSFML + uses: actions/checkout@v4 + with: + path: CSFML + - name: Download Artifacts + uses: actions/download-artifact@v4 + with: + path: CSFML/tools/nuget/CSFML/runtimes + merge-multiple: true + - name: Setup .NET 8 SDK + id: setup-dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Enforce SDK Version + run: dotnet new globaljson --sdk-version ${{ steps.setup-dotnet.outputs.dotnet-version }} --force + - name: Verify SDK Installation + run: dotnet --info + - name: Build NuGet Package + run: | + cd CSFML/tools/nuget + dotnet build --configuration Release --verbosity detailed + - name: Upload NuGet Package + uses: actions/upload-artifact@v4 + with: + name: CSFML-NuGet-Package + path: CSFML/tools/nuget/CSFML/bin/Release/*.nupkg diff --git a/tools/nuget/build.docker.sh b/tools/nuget/build.docker.sh index c37baa2..3756926 100755 --- a/tools/nuget/build.docker.sh +++ b/tools/nuget/build.docker.sh @@ -5,9 +5,10 @@ set -e if [[ -z "$1" ]]; then echo 'No Runtime Identifier specified, running all known RIDs' - ./build.docker.sh "alpine-x64" - ./build.docker.sh "debian-x64" - ./build.docker.sh "fedora-x64" + ./build.docker.sh "linux-x64" + ./build.docker.sh "linux-musl-x64" + ./build.docker.sh "linux-arm" + ./build.docker.sh "linux-arm64" exit 0 fi @@ -30,6 +31,26 @@ case "$RID" in Shell='/bin/bash' ;; +'linux-x64') + Image='ubuntu:22.04' + Shell='/bin/bash' + ;; + +'linux-musl-x64') + Image='alpine:3.15' + Shell='/bin/sh' + ;; + +'linux-arm') + Image='arm32v7/ubuntu:22.04' + Shell='/bin/bash' + ;; + +'linux-arm64') + Image='arm64v8/ubuntu:22.04' + Shell='/bin/bash' + ;; + *) echo "Unknown Runtime Identifier $RID" exit 1 diff --git a/tools/nuget/build.linux.sh b/tools/nuget/build.linux.sh index 0a8079f..45835e0 100755 --- a/tools/nuget/build.linux.sh +++ b/tools/nuget/build.linux.sh @@ -43,7 +43,7 @@ echo "Please note that all SFML dependencies must be installed and available to RID="$1" SFMLBranch="2.6.1" # The branch or tag of the SFML repository to be cloned -CSFMLDir="$(realpath "$(git rev-parse --show-toplevel)")" # The directory of the source code of CSFML +CSFMLDir="$(realpath ../../)" # The directory of the source code of CSFML OutDir="./CSFML/runtimes/$RID/native" # The base directory of all CSFML modules, used to copy the final libraries mkdir -p "$OutDir" @@ -93,6 +93,7 @@ cmake -E env LDFLAGS="-z origin" \ "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$SFMLLibDir" \ '-DCMAKE_BUILD_WITH_INSTALL_RPATH=1' \ '-DCMAKE_INSTALL_RPATH=$ORIGIN' \ + '-DSFML_BUILD_NETWORK=0' \ "$SFMLDir" cmake --build . --config Release @@ -118,6 +119,7 @@ cmake -E env LDFLAGS="-z origin" \ "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$CSFMLLibDir" \ '-DCMAKE_BUILD_WITH_INSTALL_RPATH=1' \ '-DCMAKE_INSTALL_RPATH=$ORIGIN' \ + '-DCSFML_BUILD_NETWORK=0' \ "$CSFMLDir" cmake --build . --config Release diff --git a/tools/nuget/build.macos.sh b/tools/nuget/build.macos.sh index de7efa2..7ef4ac2 100755 --- a/tools/nuget/build.macos.sh +++ b/tools/nuget/build.macos.sh @@ -113,6 +113,7 @@ cmake -E env \ -D "CMAKE_INSTALL_PREFIX=$SFMLLibDir" \ -D "SFML_DEPENDENCIES_INSTALL_PREFIX=$SFMLLibDir" \ -D "SFML_MISC_INSTALL_PREFIX=$SFMLLibDir" \ + -D "SFML_BUILD_NETWORK=0" \ "$SFMLDir" cmake --build . --config Release --target install @@ -141,6 +142,7 @@ cmake -E env \ -D 'CMAKE_INSTALL_RPATH=@loader_path' \ -D "CMAKE_INSTALL_PREFIX=$CSFMLLibDir" \ -D "INSTALL_MISC_DIR=$CSFMLLibDir" \ + -D "CSFML_BUILD_NETWORK=0" \ "$CSFMLDir" cmake --build . --config Release --target install @@ -211,7 +213,7 @@ copymodule graphics copymodule system copymodule window -cp -R "$SFMLLibDir/"*.framework "$OutDir" +cp -R "$SFMLLibDir/lib/"*.framework "$OutDir" popd # Pop CSFML popd # Pop $RID diff --git a/tools/nuget/build.win.ps1 b/tools/nuget/build.win.ps1 index fa31809..b3263c7 100644 --- a/tools/nuget/build.win.ps1 +++ b/tools/nuget/build.win.ps1 @@ -48,7 +48,7 @@ Ensures that the last command run was a success, checking its exit code. #> function Ensure-Success() { if ($LastExitCode -ne 0) { - exit + exit -1 } } @@ -119,6 +119,7 @@ cmake ` '-DCMAKE_BUILD_TYPE=Release' ` '-DCMAKE_SYSTEM_VERSION=8.1' ` '-DSFML_USE_STATIC_STD_LIBS=1' ` + '-DSFML_BUILD_NETWORK=0' ` "-G$Generator" ` "-A$Architecture" ` $SFMLDir @@ -158,6 +159,7 @@ cmake ` ` "-DBUILD_SHARED_LIBS=1" ` '-DCMAKE_BUILD_TYPE=Release' ` + '-DCSFML_BUILD_NETWORK=0' ` ` "-G$generator" ` "-A$Architecture" `