diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 2935d961a7..233c7fb51e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -73,7 +73,8 @@ For the full CI gambit, the following repository configuration must be set: If you don't plan on deploying TGS, the following secrets can be omitted: -- Secret `DEV_PUSH_TOKEN`: A GitHub token with read/write access to the repository. Enables doxygen pushes to `gh-pages` branch, and releases creation. +- Secret `DEV_PUSH_TOKEN`: A repo scoped GitHub PAT with read/write access on the repository and the ability to trigger workflows on https://github.com/tgstation/tgstation-ppa. Used to trigger debian repo rebuilds, bypass rate limits, update milestones, and create winget package acceptance PRs. +- Secret `TGS_CI_GITHUB_APP_TOKEN_BASE64` is a base 64 encoded private key for a GitHub App. This app must be installed on the repo and have read/write access to checks and contents. Used to generate CI checks, push changelogs, and create releases. - Secret `DOCKER_USERNAME`: Login username for Docker image push. - Secret `DOCKER_PASSWORD`: Login password for Docker image push. - Secret `NUGET_API_KEY`: Nuget.org API Key for client libraries push. diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index 0a6e1929dc..5b6741e772 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -42,7 +42,6 @@ env: TGS_DOTNET_QUALITY: ga TGS_TEST_GITHUB_TOKEN: ${{ secrets.LIVE_TESTS_TOKEN }} TGS_RELEASE_NOTES_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} - WINGET_PUSH_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} PACKAGING_PRIVATE_KEY_PASSPHRASE: ${{ secrets.PACKAGING_PRIVATE_KEY_PASSPHRASE }} CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} @@ -315,6 +314,12 @@ jobs: mv $HOME/tgsdox/changelog.yml ./ 2>/dev/null dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --generate-full-notes + - name: Generate App Token + run: | + dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --token-output-file ${{ runner.temp }}/installation_secret.txt ${{ secrets.TGS_CI_GITHUB_APP_TOKEN_BASE64 }} + echo "INSTALLATION_TOKEN=$(cat ${{ runner.temp }}/installation_secret.txt)" >> $GITHUB_ENV + rm ${{ runner.temp }}/installation_secret.txt + - name: Patch Doxyfile run: | VERSION=$(cat "build/Version.props" | grep -oPm1 "(?<=)[^<]+") @@ -335,8 +340,8 @@ jobs: echo ./doxout/* | xargs -n 10 sudo mv -t $HOME/tgsdox cd $HOME/tgsdox git config --global push.default simple - git config user.name "tgstation-server" - git config user.email "tgstation-server@tgstation13.org" + git config user.name "tgstation-server-ci[bot]" + git config user.email "847638+tgstation-server-ci[bot]@users.noreply.github.com" echo '# THIS BRANCH IS AUTO GENERATED BY GITHUB ACTIONS' > README.md # Need to create a .nojekyll file to allow filenames starting with an underscore @@ -347,7 +352,7 @@ jobs: echo "Committing..." git diff-index --quiet HEAD || git commit -m "Deploy code docs to GitHub Pages for workflow run ${{ github.run_number }}" -m "Commit: ${{ github.event.head_commit.id }}" echo "Pushing..." - git push -f "https://${{ secrets.DEV_PUSH_TOKEN }}@github.com/tgstation/tgstation-server" 2>&1 + git push -f "https://${{ env.INSTALLATION_TOKEN }}@github.com/tgstation/tgstation-server" 2>&1 docker-build: name: Build Docker Image @@ -1233,7 +1238,7 @@ jobs: - name: Install winget uses: Cyberboss/install-winget@v1 with: - GITHUB_TOKEN: ${{ env.WINGET_PUSH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} - name: Setup dotnet uses: actions/setup-dotnet@v4 @@ -1480,11 +1485,17 @@ jobs: - name: Generate Release Notes run: dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes ${{ env.TGS_API_VERSION }} --httpapi + - name: Generate App Token + run: | + dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --token-output-file ${{ runner.temp }}/installation_secret.txt ${{ secrets.TGS_CI_GITHUB_APP_TOKEN_BASE64 }} + echo "INSTALLATION_TOKEN=$(cat ${{ runner.temp }}/installation_secret.txt)" >> $GITHUB_ENV + rm ${{ runner.temp }}/installation_secret.txt + - name: Create GitHub Release uses: actions/create-release@v1 id: create_release env: - GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} + GITHUB_TOKEN: ${{ env.INSTALLATION_TOKEN }} with: tag_name: api-v${{ env.TGS_API_VERSION }} release_name: tgstation-server API v${{ env.TGS_API_VERSION }} @@ -1494,7 +1505,7 @@ jobs: - name: Upload OpenApi Spec uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} + GITHUB_TOKEN: ${{ env.INSTALLATION_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./swagger/tgs_api.json @@ -1543,11 +1554,17 @@ jobs: - name: Generate Release Notes run: dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes ${{ env.TGS_DM_VERSION }} --dmapi + - name: Generate App Token + run: | + dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --token-output-file ${{ runner.temp }}/installation_secret.txt ${{ secrets.TGS_CI_GITHUB_APP_TOKEN_BASE64 }} + echo "INSTALLATION_TOKEN=$(cat ${{ runner.temp }}/installation_secret.txt)" >> $GITHUB_ENV + rm ${{ runner.temp }}/installation_secret.txt + - name: Create GitHub Release uses: actions/create-release@v1 id: create_release env: - GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} + GITHUB_TOKEN: ${{ env.INSTALLATION_TOKEN }} with: tag_name: dmapi-v${{ env.TGS_DM_VERSION }} release_name: tgstation-server DMAPI v${{ env.TGS_DM_VERSION }} @@ -1557,7 +1574,7 @@ jobs: - name: Upload DMAPI Artifact uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} + GITHUB_TOKEN: ${{ env.INSTALLATION_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./DMAPI.zip @@ -1637,7 +1654,7 @@ jobs: run: dotnet build -c Release -p:TGS_HOST_NO_WEBPANEL=true tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj - name: Run ReleaseNotes with --ensure-release - run: dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --ensure-release + run: dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --ensure-release ${{ secrets.TGS_CI_GITHUB_APP_TOKEN_BASE64 }} deploy-tgs: name: Deploy TGS @@ -1760,11 +1777,17 @@ jobs: - name: Generate Release Notes run: dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes ${{ env.TGS_VERSION }} + - name: Generate App Token + run: | + dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --token-output-file ${{ runner.temp }}/installation_secret.txt ${{ secrets.TGS_CI_GITHUB_APP_TOKEN_BASE64 }} + echo "INSTALLATION_TOKEN=$(cat ${{ runner.temp }}/installation_secret.txt)" >> $GITHUB_ENV + rm ${{ runner.temp }}/installation_secret.txt + - name: Create GitHub Release uses: actions/create-release@v1 id: create_release env: - GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} + GITHUB_TOKEN: ${{ env.INSTALLATION_TOKEN }} with: tag_name: tgstation-server-v${{ env.TGS_VERSION }} release_name: tgstation-server-v${{ env.TGS_VERSION }} @@ -1774,7 +1797,7 @@ jobs: - name: Upload Server Console Artifact uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} + GITHUB_TOKEN: ${{ env.INSTALLATION_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./ServerConsole.zip @@ -1784,7 +1807,7 @@ jobs: - name: Upload Server Service Artifact uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} + GITHUB_TOKEN: ${{ env.INSTALLATION_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./ServerService.zip @@ -1794,7 +1817,7 @@ jobs: - name: Upload DMAPI Artifact uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} + GITHUB_TOKEN: ${{ env.INSTALLATION_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./DMAPI.zip @@ -1804,7 +1827,7 @@ jobs: - name: Upload OpenApi Spec Artifact uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} + GITHUB_TOKEN: ${{ env.INSTALLATION_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./swagger/tgs_api.json @@ -1814,7 +1837,7 @@ jobs: - name: Upload Server Update Package Artifact uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} + GITHUB_TOKEN: ${{ env.INSTALLATION_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./ServerUpdatePackage.zip @@ -1824,7 +1847,7 @@ jobs: - name: Upload Debian Pacakaging Artifact uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} + GITHUB_TOKEN: ${{ env.INSTALLATION_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./packaging-debian/tgstation-server-v${{ env.TGS_VERSION }}.debian.packaging.tar.xz @@ -1834,7 +1857,7 @@ jobs: - name: Upload MariaDB .msi uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} + GITHUB_TOKEN: ${{ env.INSTALLATION_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./build/package/winget/Tgstation.Server.Host.Service.Wix.Bundle/bin/Release/mariadb.msi @@ -1844,7 +1867,7 @@ jobs: - name: Upload Installer .exe uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} + GITHUB_TOKEN: ${{ env.INSTALLATION_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./build/package/winget/tgstation-server-installer.exe @@ -1880,6 +1903,12 @@ jobs: mv $HOME/tgsdox/changelog.yml ./ 2>/dev/null dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --generate-full-notes + - name: Generate App Token + run: | + dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --token-output-file ${{ runner.temp }}/installation_secret.txt ${{ secrets.TGS_CI_GITHUB_APP_TOKEN_BASE64 }} + echo "INSTALLATION_TOKEN=$(cat ${{ runner.temp }}/installation_secret.txt)" >> $GITHUB_ENV + rm ${{ runner.temp }}/installation_secret.txt + - name: gh-pages Push run: | pushd $HOME/tgsdox @@ -1888,13 +1917,13 @@ jobs: sudo mv changelog.yml $HOME/tgsdox/ cd $HOME/tgsdox git config --global push.default simple - git config user.name "tgstation-server" - git config user.email "tgstation-server@tgstation13.org" + git config user.name "tgstation-server-ci[bot]" + git config user.email "847638+tgstation-server-ci[bot]@users.noreply.github.com" git add changelog.yml echo "Committing..." git diff-index --quiet HEAD || git commit -m "Regenerate changelog post deploy for workflow run ${{ github.run_number }}" -m "Commit: ${{ github.event.head_commit.id }}" echo "Pushing..." - git push -f "https://${{ secrets.DEV_PUSH_TOKEN }}@github.com/tgstation/tgstation-server" 2>&1 + git push -f "https://${{ env.INSTALLATION_TOKEN }}@github.com/tgstation/tgstation-server" 2>&1 deploy-docker: name: Deploy TGS (Docker) @@ -1954,7 +1983,7 @@ jobs: - name: Install winget uses: Cyberboss/install-winget@v1 with: - GITHUB_TOKEN: ${{ env.WINGET_PUSH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} - name: Install wingetcreate run: winget install wingetcreate --version 1.2.8.0 --disable-interactivity --accept-source-agreements # Pinned due to breaking every other version diff --git a/.github/workflows/stable-merge.yml b/.github/workflows/stable-merge.yml index 05299e6284..becdb02839 100644 --- a/.github/workflows/stable-merge.yml +++ b/.github/workflows/stable-merge.yml @@ -6,18 +6,38 @@ on: - master workflow_dispatch: -env: - DEV_PUSH_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }} - jobs: master-merge: + name: Master Merge runs-on: ubuntu-latest steps: - - name: Checkout + - name: Build Checkout + uses: actions/checkout@v4 + with: + path: temp_workspace + + - name: Restore + run: | + cd temp_workspace + dotnet restore + + - name: Build ReleaseNotes + run: | + cd temp_workspace + dotnet build -c Release -p:TGS_HOST_NO_WEBPANEL=true tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj + + - name: Generate App Token + run: | + cd temp_workspace + dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --token-output-file ${{ runner.temp }}/installation_secret.txt ${{ secrets.TGS_CI_GITHUB_APP_TOKEN_BASE64 }} + echo "INSTALLATION_TOKEN=$(cat ${{ runner.temp }}/installation_secret.txt)" >> $GITHUB_ENV + rm ${{ runner.temp }}/installation_secret.txt + + - name: Main Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - token: ${{ secrets.DEV_PUSH_TOKEN }} + token: ${{ env.INSTALLATION_TOKEN }} - name: Merge master into dev uses: robotology/gh-action-nightly-merge@14b4a4cf358f7479aa708bee05cf8a794d6a2516 #v1.5.0 @@ -26,8 +46,8 @@ jobs: development_branch: 'dev' allow_ff: true allow_forks: true - user_name: tgstation-server - user_email: tgstation-server@users.noreply.github.com - push_token: DEV_PUSH_TOKEN + user_name: tgstation-server-ci[bot] + user_email: 847638+tgstation-server-ci[bot]@users.noreply.github.com + push_token: INSTALLATION_TOKEN env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build/NewtonsoftJson.props b/build/NewtonsoftJson.props new file mode 100644 index 0000000000..da775538fb --- /dev/null +++ b/build/NewtonsoftJson.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/build/TestCommon.props b/build/TestCommon.props index b7a3d408c0..1864c27e2a 100644 --- a/build/TestCommon.props +++ b/build/TestCommon.props @@ -18,9 +18,9 @@ - + - + diff --git a/src/Tgstation.Server.Api/Models/ErrorCode.cs b/src/Tgstation.Server.Api/Models/ErrorCode.cs index b75c837585..7dc134f905 100644 --- a/src/Tgstation.Server.Api/Models/ErrorCode.cs +++ b/src/Tgstation.Server.Api/Models/ErrorCode.cs @@ -1,5 +1,4 @@ -using System; -using System.ComponentModel; +using System.ComponentModel; using Tgstation.Server.Common; @@ -8,7 +7,7 @@ namespace Tgstation.Server.Api.Models /// /// Types of s that the API may return. /// - /// Entries marked with the are no longer in use but kept for placeholders until they can be recycled in the next major API version. + /// Entries marked Obsolete are no longer in use but kept for placeholders until they can be recycled in the next major API version. public enum ErrorCode : uint { /// diff --git a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj index a9a49e05e1..b55dff5e5f 100644 --- a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj +++ b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj @@ -1,5 +1,6 @@ + $(TgsNugetNetFramework) @@ -27,9 +28,7 @@ - - - + diff --git a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj index ef5a83c7a3..89c048c68f 100644 --- a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj +++ b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj @@ -11,14 +11,15 @@ - + - + - + + diff --git a/src/Tgstation.Server.Host.Common/DotnetHelper.cs b/src/Tgstation.Server.Host.Common/DotnetHelper.cs index b5d80db784..5945eac25d 100644 --- a/src/Tgstation.Server.Host.Common/DotnetHelper.cs +++ b/src/Tgstation.Server.Host.Common/DotnetHelper.cs @@ -21,6 +21,9 @@ namespace Tgstation.Server.Host.Common public static IEnumerable GetPotentialDotnetPaths(bool isWindows) { var enviromentPath = Environment.GetEnvironmentVariable("PATH"); + if (enviromentPath == null) + return Enumerable.Empty(); + var paths = enviromentPath.Split(';'); var exeName = "dotnet"; diff --git a/src/Tgstation.Server.Host.Common/Tgstation.Server.Host.Common.csproj b/src/Tgstation.Server.Host.Common/Tgstation.Server.Host.Common.csproj index a45edbc7c4..484d476684 100644 --- a/src/Tgstation.Server.Host.Common/Tgstation.Server.Host.Common.csproj +++ b/src/Tgstation.Server.Host.Common/Tgstation.Server.Host.Common.csproj @@ -4,6 +4,7 @@ $(TgsFrameworkVersion);net2.0 $(TgsCoreVersion) + enable diff --git a/src/Tgstation.Server.Host/.config/dotnet-tools.json b/src/Tgstation.Server.Host/.config/dotnet-tools.json index 4bb3f8cae9..af52642792 100644 --- a/src/Tgstation.Server.Host/.config/dotnet-tools.json +++ b/src/Tgstation.Server.Host/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "dotnet-ef": { - "version": "8.0.6", + "version": "8.0.7", "commands": [ "dotnet-ef" ] diff --git a/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs b/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs index 7386e85669..edaf3e408e 100644 --- a/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs +++ b/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs @@ -5,6 +5,7 @@ using Newtonsoft.Json.Serialization; using Tgstation.Server.Host.Extensions.Converters; using Tgstation.Server.Host.Properties; +using Tgstation.Server.Shared; namespace Tgstation.Server.Host.Components.Interop { diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs index 9569d2510b..36970000c5 100644 --- a/src/Tgstation.Server.Host/Core/Application.cs +++ b/src/Tgstation.Server.Host/Core/Application.cs @@ -50,7 +50,6 @@ using Tgstation.Server.Host.Controllers; using Tgstation.Server.Host.Controllers.Results; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Extensions; -using Tgstation.Server.Host.Extensions.Converters; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Properties; @@ -61,6 +60,7 @@ using Tgstation.Server.Host.Swarm; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; +using Tgstation.Server.Shared; namespace Tgstation.Server.Host.Core { diff --git a/src/Tgstation.Server.Host/Setup/SetupWizard.cs b/src/Tgstation.Server.Host/Setup/SetupWizard.cs index c8007f16b5..04cc54a3bf 100644 --- a/src/Tgstation.Server.Host/Setup/SetupWizard.cs +++ b/src/Tgstation.Server.Host/Setup/SetupWizard.cs @@ -23,11 +23,11 @@ using Npgsql; using Tgstation.Server.Common; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Database; -using Tgstation.Server.Host.Extensions.Converters; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Properties; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; +using Tgstation.Server.Shared; using YamlDotNet.Serialization; @@ -986,14 +986,15 @@ namespace Tgstation.Server.Host.Setup { SwarmConfiguration.Section, swarmConfiguration }, }; + var versionConverter = new VersionConverter(); var builder = new SerializerBuilder() - .WithTypeConverter(new VersionConverter()); + .WithTypeConverter(versionConverter); if (userConfigFileName.EndsWith(".json", StringComparison.OrdinalIgnoreCase)) builder.JsonCompatible(); var serializer = new SerializerBuilder() - .WithTypeConverter(new VersionConverter()) + .WithTypeConverter(versionConverter) .Build(); var serializedYaml = serializer.Serialize(map); diff --git a/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs b/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs index 988c60243e..834b6718cf 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json.Serialization; using Tgstation.Server.Api; using Tgstation.Server.Host.Extensions.Converters; +using Tgstation.Server.Shared; namespace Tgstation.Server.Host.Swarm { diff --git a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj index 9c5dbd6fef..e29c37faa7 100644 --- a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj +++ b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj @@ -1,4 +1,4 @@ - + @@ -77,24 +77,22 @@ - - - + - + - + - + runtime; build; native; contentfiles; analyzers; buildtransitive - + - + @@ -102,8 +100,6 @@ - - @@ -135,6 +131,7 @@ + diff --git a/src/Tgstation.Server.Shared/Tgstation.Server.Shared.csproj b/src/Tgstation.Server.Shared/Tgstation.Server.Shared.csproj new file mode 100644 index 0000000000..01518a39b0 --- /dev/null +++ b/src/Tgstation.Server.Shared/Tgstation.Server.Shared.csproj @@ -0,0 +1,24 @@ + + + + + + $(TgsFrameworkVersion) + $(TgsCoreVersion) + enable + + + + + + + + + + + + + + + + diff --git a/src/Tgstation.Server.Host/Extensions/Converters/VersionConverter.cs b/src/Tgstation.Server.Shared/VersionConverter.cs similarity index 91% rename from src/Tgstation.Server.Host/Extensions/Converters/VersionConverter.cs rename to src/Tgstation.Server.Shared/VersionConverter.cs index 48c593d72f..ee0a4f3a31 100644 --- a/src/Tgstation.Server.Host/Extensions/Converters/VersionConverter.cs +++ b/src/Tgstation.Server.Shared/VersionConverter.cs @@ -8,7 +8,7 @@ using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Serialization; -namespace Tgstation.Server.Host.Extensions.Converters +namespace Tgstation.Server.Shared { /// /// and for serializing s in semver format. @@ -85,10 +85,10 @@ namespace Tgstation.Server.Host.Extensions.Converters public bool Accepts(Type type) => CheckSupportsType(type, false); /// - public object ReadYaml(IParser parser, Type type) => throw new NotSupportedException("Deserialization not supported!"); // The default implementation is fine at handling this + public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer) => throw new NotSupportedException("Deserialization not supported!"); // The default implementation is fine at handling this /// - public void WriteYaml(IEmitter? emitter, object? value, Type type) + public void WriteYaml(IEmitter? emitter, object? value, Type type, ObjectSerializer serializer) { ArgumentNullException.ThrowIfNull(emitter); diff --git a/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj b/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj index 50fdb38405..326b6f38b2 100644 --- a/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj +++ b/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj @@ -6,6 +6,7 @@ + diff --git a/tests/Tgstation.Server.Host.Tests/Extensions/Converters/TestVersionConverter.cs b/tests/Tgstation.Server.Shared.Tests/TestVersionConverter.cs similarity index 85% rename from tests/Tgstation.Server.Host.Tests/Extensions/Converters/TestVersionConverter.cs rename to tests/Tgstation.Server.Shared.Tests/TestVersionConverter.cs index deb2fc1760..c5f8e26a37 100644 --- a/tests/Tgstation.Server.Host.Tests/Extensions/Converters/TestVersionConverter.cs +++ b/tests/Tgstation.Server.Shared.Tests/TestVersionConverter.cs @@ -1,11 +1,12 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; +using System; + +using Microsoft.VisualStudio.TestTools.UnitTesting; using Tgstation.Server.Common.Extensions; using YamlDotNet.Serialization; -namespace Tgstation.Server.Host.Extensions.Converters.Tests +namespace Tgstation.Server.Shared.Tests { [TestClass] public sealed class TestVersionConverter diff --git a/tests/Tgstation.Server.Shared.Tests/Tgstation.Server.Shared.Tests.csproj b/tests/Tgstation.Server.Shared.Tests/Tgstation.Server.Shared.Tests.csproj new file mode 100644 index 0000000000..a10b4c149e --- /dev/null +++ b/tests/Tgstation.Server.Shared.Tests/Tgstation.Server.Shared.Tests.csproj @@ -0,0 +1,12 @@ + + + + + $(TgsFrameworkVersion) + + + + + + + diff --git a/tgstation-server.sln b/tgstation-server.sln index a8b1f999bf..81bcb0fb81 100644 --- a/tgstation-server.sln +++ b/tgstation-server.sln @@ -29,6 +29,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{6FF654E6 build\Dockerfile = build\Dockerfile build\GenerateMigrations.sh = build\GenerateMigrations.sh build\logo.svg = build\logo.svg + build\NewtonsoftJson.props = build\NewtonsoftJson.props build\NugetCommon.props = build\NugetCommon.props build\OpenApiValidationSettings.json = build\OpenApiValidationSettings.json build\SrcCommon.props = build\SrcCommon.props @@ -261,7 +262,11 @@ Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "Tgstation.Server.Host.Servi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tgstation.Server.ReleaseNotes", "tools\Tgstation.Server.ReleaseNotes\Tgstation.Server.ReleaseNotes.csproj", "{69944039-65C2-40E1-9D86-0608FA0C2D70}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tgstation.Server.LogoGenerator", "tools\Tgstation.Server.LogoGenerator\Tgstation.Server.LogoGenerator.csproj", "{7F7FCFDF-271D-45C2-830C-BCCB19C57077}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tgstation.Server.LogoGenerator", "tools\Tgstation.Server.LogoGenerator\Tgstation.Server.LogoGenerator.csproj", "{7F7FCFDF-271D-45C2-830C-BCCB19C57077}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tgstation.Server.Shared", "src\Tgstation.Server.Shared\Tgstation.Server.Shared.csproj", "{74B9AC97-DEEC-49F4-B3B3-E07126A52B47}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tgstation.Server.Shared.Tests", "tests\Tgstation.Server.Shared.Tests\Tgstation.Server.Shared.Tests.csproj", "{EAB84FD0-5514-4254-B188-7D90ACB7284D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -533,6 +538,30 @@ Global {7F7FCFDF-271D-45C2-830C-BCCB19C57077}.ReleaseNoWindows|Any CPU.Build.0 = Release|Any CPU {7F7FCFDF-271D-45C2-830C-BCCB19C57077}.ReleaseNoWix|Any CPU.ActiveCfg = Release|Any CPU {7F7FCFDF-271D-45C2-830C-BCCB19C57077}.ReleaseNoWix|Any CPU.Build.0 = Release|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.Debug|Any CPU.Build.0 = Debug|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.DebugNoWindows|Any CPU.ActiveCfg = Debug|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.DebugNoWindows|Any CPU.Build.0 = Debug|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.DebugNoWix|Any CPU.ActiveCfg = Debug|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.DebugNoWix|Any CPU.Build.0 = Debug|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.Release|Any CPU.ActiveCfg = Release|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.Release|Any CPU.Build.0 = Release|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.ReleaseNoWindows|Any CPU.ActiveCfg = Release|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.ReleaseNoWindows|Any CPU.Build.0 = Release|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.ReleaseNoWix|Any CPU.ActiveCfg = Release|Any CPU + {74B9AC97-DEEC-49F4-B3B3-E07126A52B47}.ReleaseNoWix|Any CPU.Build.0 = Release|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.DebugNoWindows|Any CPU.ActiveCfg = Debug|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.DebugNoWindows|Any CPU.Build.0 = Debug|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.DebugNoWix|Any CPU.ActiveCfg = Debug|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.DebugNoWix|Any CPU.Build.0 = Debug|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.Release|Any CPU.Build.0 = Release|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.ReleaseNoWindows|Any CPU.ActiveCfg = Release|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.ReleaseNoWindows|Any CPU.Build.0 = Release|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.ReleaseNoWix|Any CPU.ActiveCfg = Release|Any CPU + {EAB84FD0-5514-4254-B188-7D90ACB7284D}.ReleaseNoWix|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -571,6 +600,7 @@ Global {9E66C6F1-E235-4979-83B5-C2B3FDAD6E01} = {506B9092-AF88-4DA2-84FD-C11646B695B0} {69944039-65C2-40E1-9D86-0608FA0C2D70} = {A55C1117-5808-4AB2-BEA6-4D4A3E66A2F2} {7F7FCFDF-271D-45C2-830C-BCCB19C57077} = {A55C1117-5808-4AB2-BEA6-4D4A3E66A2F2} + {EAB84FD0-5514-4254-B188-7D90ACB7284D} = {316141B0-CD21-4769-A013-D53DA9B9EC09} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DFD36C95-3E49-41C7-ACDB-86BAF5B18A79} diff --git a/tools/Tgstation.Server.ReleaseNotes/Program.cs b/tools/Tgstation.Server.ReleaseNotes/Program.cs index 33977ab79f..26b6c55392 100644 --- a/tools/Tgstation.Server.ReleaseNotes/Program.cs +++ b/tools/Tgstation.Server.ReleaseNotes/Program.cs @@ -25,7 +25,7 @@ using Newtonsoft.Json; using Octokit; using Octokit.GraphQL; -using Tgstation.Server.Host.Extensions.Converters; +using Tgstation.Server.Shared; using YamlDotNet.Serialization; @@ -61,6 +61,7 @@ namespace Tgstation.Server.ReleaseNotes var fullNotes = versionString.Equals("--generate-full-notes", StringComparison.OrdinalIgnoreCase); var nuget = versionString.Equals("--nuget", StringComparison.OrdinalIgnoreCase); var ciCompletionCheck = versionString.Equals("--ci-completion-check", StringComparison.OrdinalIgnoreCase); + var genToken = versionString.Equals("--token-output-file", StringComparison.OrdinalIgnoreCase); if ((!Version.TryParse(versionString, out var version) || version.Revision != -1) && !ensureRelease @@ -68,7 +69,8 @@ namespace Tgstation.Server.ReleaseNotes && !shaCheck && !fullNotes && !nuget - && !ciCompletionCheck) + && !ciCompletionCheck + && !genToken) { Console.WriteLine("Invalid version: " + versionString); return 2; @@ -126,7 +128,17 @@ namespace Tgstation.Server.ReleaseNotes try { if (ensureRelease) + { + if (args.Length < 2) + { + Console.WriteLine("Missing PEM Base64 for updating release!"); + return 454233; + } + + await GenerateAppCredentials(client, args[1]); + return await EnsureRelease(client); + } if (linkWinget) { @@ -150,6 +162,22 @@ namespace Tgstation.Server.ReleaseNotes return await CICompletionCheck(client, args[1], args[2]); } + + if (genToken) + { + if (args.Length < 3) + { + Console.WriteLine("Missing output file path or PEM Base64 for app authentication!"); + return 33847; + } + + await GenerateAppCredentials(client, args[2]); + + var token = client.Credentials.GetToken(); + await File.WriteAllTextAsync(args[1], token); + return 0; + } + if (shaCheck) { if(args.Length < 2) diff --git a/tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj b/tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj index 4c87963970..772bc7c717 100644 --- a/tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj +++ b/tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj @@ -12,7 +12,7 @@ - +