From bb8d1c52de972eca9767c8a1a42e51872eac3a36 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 13 Aug 2023 17:08:20 -0400 Subject: [PATCH] Strip unnecessary runtimes from artifacts --- .github/workflows/ci-pipeline.yml | 32 ++++++++++++------- build/Dockerfile | 9 ++++-- build/RemoveUnsupportedRuntimes.sh | 10 ++++++ build/RemoveUnsupportedServiceRuntimes.ps1 | 9 ++++++ build/package/deb/debian/rules | 2 ++ .../prepare_installer_input_artifacts.ps1 | 5 ++- 6 files changed, 52 insertions(+), 15 deletions(-) create mode 100755 build/RemoveUnsupportedRuntimes.sh create mode 100644 build/RemoveUnsupportedServiceRuntimes.ps1 diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index 3ae0b0dee3..3e3b3945da 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -464,17 +464,20 @@ jobs: if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'Basic' }} run: | cd src/Tgstation.Server.Host.Service - dotnet publish -c ${{ matrix.configuration }} -o ../../Artifacts/Service + dotnet publish -c ${{ matrix.configuration }} -o ../../artifacts/Service cd ../Tgstation.Server.Host - dotnet publish -c ${{ matrix.configuration }} --no-build -o ../../Artifacts/Service/lib/Default - mv ../../Artifacts/Service/lib/Default/appsettings.yml ../../Artifacts/Service/appsettings.yml + dotnet publish -c ${{ matrix.configuration }} --no-build -o ../../artifacts/Service/lib/Default + cd ../.. + mv artifacts/Service/lib/Default/appsettings.yml artifacts/Service/appsettings.yml + build/RemoveUnsupportedRuntimes.sh artifacts/Service/lib/Default + build/RemoveUnsupportedServiceRuntimes.ps1 artifacts/Service - name: Store Server Service if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'Basic' }} uses: actions/upload-artifact@v3 with: name: ServerService - path: Artifacts/Service/ + path: artifacts/Service/ - name: Install Code Signing Certificate if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'Basic' }} @@ -489,7 +492,7 @@ jobs: - name: Test Sign Service .exe if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'Basic' }} shell: powershell - run: Set-AuthenticodeSignature Artifacts/Service/Tgstation.Server.Host.Service.exe -Certificate (Get-ChildItem Cert:\CurrentUser\My | Where-Object { $_.Thumbprint -eq "${{ vars.CODE_SIGNING_THUMBPRINT }}" }) -TimestampServer "http://timestamp.digicert.com" + run: Set-AuthenticodeSignature artifacts/Service/Tgstation.Server.Host.Service.exe -Certificate (Get-ChildItem Cert:\CurrentUser\My | Where-Object { $_.Thumbprint -eq "${{ vars.CODE_SIGNING_THUMBPRINT }}" }) -TimestampServer "http://timestamp.digicert.com" linux-integration-tests: name: Linux Live Tests @@ -626,31 +629,36 @@ jobs: if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'System' && matrix.database-type == 'MariaDB' }} run: | cd src/Tgstation.Server.Host.Console - dotnet publish -c ${{ matrix.configuration }} -o ../../Artifacts/Console + dotnet publish -c ${{ matrix.configuration }} -o ../../artifacts/Console cd ../Tgstation.Server.Host - dotnet publish -c ${{ matrix.configuration }}NoWindows --no-build -o ../../Artifacts/Console/lib/Default - mv ../../Artifacts/Console/lib/Default/appsettings.yml ../../Artifacts/Console/appsettings.yml + dotnet publish -c ${{ matrix.configuration }}NoWindows --no-build -o ../../artifacts/Console/lib/Default + cd ../.. + mv artifacts/Console/lib/Default/appsettings.yml artifacts/Console/appsettings.yml + build/RemoveUnsupportedRuntimes.sh artifacts/Console/lib/Default + build/RemoveUnsupportedRuntimes.sh artifacts/Console - name: Package Server Update Package if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'System' && matrix.database-type == 'PostgresSql' }} run: | cd src/Tgstation.Server.Host - dotnet publish -c ${{ matrix.configuration }}NoWindows --no-build -o ../../Artifacts/ServerUpdate - rm ../../Artifacts/ServerUpdate/appsettings.yml + dotnet publish -c ${{ matrix.configuration }}NoWindows --no-build -o ../../artifacts/ServerUpdate + cd ../.. + rm artifacts/ServerUpdate/appsettings.yml + build/RemoveUnsupportedRuntimes.sh artifacts/ServerUpdate - name: Store Server Console if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'System' && matrix.database-type == 'MariaDB' }} uses: actions/upload-artifact@v3 with: name: ServerConsole - path: Artifacts/Console/ + path: artifacts/Console/ - name: Store Server Update Package if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'System' && matrix.database-type == 'PostgresSql' }} uses: actions/upload-artifact@v3 with: name: ServerUpdatePackage - path: Artifacts/ServerUpdate/ + path: artifacts/ServerUpdate/ validate-openapi-spec: name: OpenAPI Spec Validation diff --git a/build/Dockerfile b/build/Dockerfile index f1f70e95b3..ce96320ad2 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -58,10 +58,15 @@ COPY . . RUN dos2unix build/tgs.docker.sh WORKDIR /repo/src/Tgstation.Server.Host.Console -RUN dotnet publish -c Release -o /app +RUN dotnet publish -c Release -o /app \ + && cd ../.. \ + && build/RemoveUnsupportedRuntimes.sh /app WORKDIR /repo/src/Tgstation.Server.Host -RUN dotnet publish -c Release -o /app/lib/Default && mv /app/lib/Default/appsettings* /app +RUN dotnet publish -c Release -o /app/lib/Default \ + && cd ../.. \ + && build/RemoveUnsupportedRuntimes.sh /app/lib/Default \ + && mv /app/lib/Default/appsettings* /app FROM mcr.microsoft.com/dotnet/aspnet:6.0-bookworm-slim diff --git a/build/RemoveUnsupportedRuntimes.sh b/build/RemoveUnsupportedRuntimes.sh new file mode 100755 index 0000000000..f7b50cfeb1 --- /dev/null +++ b/build/RemoveUnsupportedRuntimes.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Run with publish directory as parameter +rm -rf $1/runtimes/browser* \ + $1/runtimes/osx* \ + $1/runtimes/mac* \ + $1/runtimes/*-arm* \ + $1/runtimes/*-ppc64le \ + $1/runtimes/*-s390x \ + $1/runtimes/*-mips64 diff --git a/build/RemoveUnsupportedServiceRuntimes.ps1 b/build/RemoveUnsupportedServiceRuntimes.ps1 new file mode 100644 index 0000000000..0f6db56a46 --- /dev/null +++ b/build/RemoveUnsupportedServiceRuntimes.ps1 @@ -0,0 +1,9 @@ +param ( + [Parameter(Position=0)] $PublishDirectory +) + +Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$PublishDirectory/runtimes/browser*" +Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$PublishDirectory/runtimes/linux*" +Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$PublishDirectory/runtimes/osx*" +Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$PublishDirectory/runtimes/unix*" +Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$PublishDirectory/runtimes/alpine*" diff --git a/build/package/deb/debian/rules b/build/package/deb/debian/rules index 7fd8d564fa..a68a2cd7d7 100755 --- a/build/package/deb/debian/rules +++ b/build/package/deb/debian/rules @@ -14,6 +14,8 @@ override_dh_auto_build: cd src/Tgstation.Server.Host.Console && dotnet publish -c Release -o ../../artifacts cd src/Tgstation.Server.Host && dotnet publish -c Release -o ../../artifacts/lib/Default rm artifacts/lib/Default/appsettings.yml + build/RemoveUnsupportedRuntimes.sh artifacts/lib/Default + build/RemoveUnsupportedRuntimes.sh artifacts override_dh_auto_install: cp build/package/deb/MakeInstall ./Makefile diff --git a/build/package/winget/prepare_installer_input_artifacts.ps1 b/build/package/winget/prepare_installer_input_artifacts.ps1 index ab075c6e3c..d73f0d3001 100644 --- a/build/package/winget/prepare_installer_input_artifacts.ps1 +++ b/build/package/winget/prepare_installer_input_artifacts.ps1 @@ -39,7 +39,10 @@ try exit $lastexitcode } - mv ../../artifacts/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.exe ../../artifacts/ + cd ../.. + build/RemoveUnsupportedRuntimes.sh artifacts/Tgstation.Server.Host + build/RemoveUnsupportedServiceRuntimes.ps1 artifacts/Tgstation.Server.Host.Service + mv artifacts/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.exe artifacts/ } finally {