From 351fc491542169cd294580e4226c481f2ba640d7 Mon Sep 17 00:00:00 2001 From: mpmxyz Date: Thu, 11 Jan 2024 23:31:57 +0100 Subject: [PATCH] Now Downloading Resonite from Steam (#47) removed secret RESONITE_CLONE_TOKEN added secrets STEAM_USER and STEAM_TOKEN closes #44 --- .github/workflows/build-monkey.yml | 43 ++++++++++++++----- .github/workflows/build-rml.yml | 44 ++++++++++++++----- .github/workflows/check-repository-setup.yml | 45 +++++++++----------- .github/workflows/create-release.yml | 6 ++- .github/workflows/init-template.yml | 4 +- .github/workflows/update-ResoniteFiles.cmd | 6 --- Mod.RML/SampleModRML.cs | 2 +- README.md | 4 +- SampleMod.csproj | 2 +- 9 files changed, 97 insertions(+), 59 deletions(-) delete mode 100644 .github/workflows/update-ResoniteFiles.cmd diff --git a/.github/workflows/build-monkey.yml b/.github/workflows/build-monkey.yml index 0948f3a..0a09b6d 100644 --- a/.github/workflows/build-monkey.yml +++ b/.github/workflows/build-monkey.yml @@ -19,7 +19,9 @@ on: required: false default: "" secrets: - RESONITE_CLONE_TOKEN: + STEAM_USER: + required: true + STEAM_TOKEN: required: true env: ARTIFACT_NAME: "SampleMod" @@ -33,7 +35,6 @@ env: OUTPUT_FOLDER: "bin/MonkeyLoader/Release" TEST_PROJECT_FILE: "Test/Test.csproj" MOD_LOADER_TEST_PROJECT_FILE: "TestMonkey/TestMonkey.csproj" - RESONITE_CLONE_REPO: "${{ github.repository_owner }}/ResoniteFiles" defaults: run: working-directory: "./repo" @@ -41,20 +42,40 @@ jobs: build-MonkeyLoader: runs-on: ubuntu-latest steps: - - name: Fetch repository - uses: actions/checkout@v4 - with: - path: ${{ env.PROJECT_PATH }} - - name: Fetch latest Resonite - uses: actions/checkout@v4 + - name: Ensure working directory exists + run: mkdir -p '${{ env.PROJECT_PATH }}' + working-directory: "${{ github.workspace }}" + - name: Get Resonite Infos + run: | + { + echo "APP_INFO<> "$GITHUB_ENV" + - name: Get Resonite from Cache + id: cache-resonite + uses: actions/cache@v3.3.3 with: - repository: ${{ env.RESONITE_CLONE_REPO }} - token: ${{ secrets.RESONITE_CLONE_TOKEN }} - path: ${{ env.ResonitePath }}/.. + path: "${{ env.ResonitePath }}" + key: "${{ fromJson( env.APP_INFO ).data['2519830'].depots.branches.public.buildid }}" + - name: Download Steam + if: steps.cache-resonite.outputs.cache-hit != 'true' + uses: CyberAndrii/setup-steamcmd@b786e0da44db3d817e66fa3910a9560cb28c9323 + - name: Download Resonite + if: steps.cache-resonite.outputs.cache-hit != 'true' + run: | + steamcmd '+@sSteamCmdForcePlatformType windows' '+force_install_dir "${{ env.ResonitePath }}"' '+login "${{ secrets.STEAM_USER }}" "${{ secrets.STEAM_TOKEN }}"' '+app_license_request 2519830' '+app_update 2519830 validate' '+quit' + #The following line makes the cache much much smaller: + rm -r '${{ env.ResonitePath }}/RuntimeData/PreCache' - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: 8.0.x + - name: Fetch repository + uses: actions/checkout@v4 + with: + path: ${{ env.PROJECT_PATH }} - name: Fetch MonkeyLoader uses: robinraju/release-downloader@efa4cd07bd0195e6cc65e9e30c251b49ce4d3e51 with: diff --git a/.github/workflows/build-rml.yml b/.github/workflows/build-rml.yml index 1095330..ffd8284 100644 --- a/.github/workflows/build-rml.yml +++ b/.github/workflows/build-rml.yml @@ -19,7 +19,9 @@ on: required: false default: "" secrets: - RESONITE_CLONE_TOKEN: + STEAM_USER: + required: true + STEAM_TOKEN: required: true env: ARTIFACT_NAME: "SampleMod" @@ -33,7 +35,6 @@ env: OUTPUT_FOLDER: "bin/RML/Release/net472" TEST_PROJECT_FILE: "Test/Test.csproj" MOD_LOADER_TEST_PROJECT_FILE: "TestRML/TestRML.csproj" - RESONITE_CLONE_REPO: "${{ github.repository_owner }}/ResoniteFiles" defaults: run: working-directory: "./repo" @@ -41,20 +42,40 @@ jobs: build-ResoniteModLoader: runs-on: ubuntu-latest steps: - - name: Fetch repository - uses: actions/checkout@v4 - with: - path: ${{ env.PROJECT_PATH }} - - name: Fetch latest Resonite - uses: actions/checkout@v4 + - name: Ensure working directory exists + run: mkdir -p '${{ env.PROJECT_PATH }}' + working-directory: "${{ github.workspace }}" + - name: Get Resonite Infos + run: | + { + echo "APP_INFO<> "$GITHUB_ENV" + - name: Get Resonite from Cache + id: cache-resonite + uses: actions/cache@v3.3.3 with: - repository: ${{ env.RESONITE_CLONE_REPO }} - token: ${{ secrets.RESONITE_CLONE_TOKEN }} - path: ${{ env.ResonitePath }}/.. + path: "${{ env.ResonitePath }}" + key: "${{ fromJson( env.APP_INFO ).data['2519830'].depots.branches.public.buildid }}" + - name: Download Steam + if: steps.cache-resonite.outputs.cache-hit != 'true' + uses: CyberAndrii/setup-steamcmd@b786e0da44db3d817e66fa3910a9560cb28c9323 + - name: Download Resonite + if: steps.cache-resonite.outputs.cache-hit != 'true' + run: | + steamcmd '+@sSteamCmdForcePlatformType windows' '+force_install_dir "${{ env.ResonitePath }}"' '+login "${{ secrets.STEAM_USER }}" "${{ secrets.STEAM_TOKEN }}"' '+app_license_request 2519830' '+app_update 2519830 validate' '+quit' + #The following line makes the cache much much smaller: + rm -r '${{ env.ResonitePath }}/RuntimeData/PreCache' - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: 8.0.x + - name: Fetch repository + uses: actions/checkout@v4 + with: + path: ${{ env.PROJECT_PATH }} - name: Fetch latest ResoniteModLoader uses: robinraju/release-downloader@efa4cd07bd0195e6cc65e9e30c251b49ce4d3e51 with: @@ -64,6 +85,7 @@ jobs: out-file-path: RML/ - name: Move ResoniteModLoader files run: | + ls -l $ResonitePath mkdir -p "$ResonitePath/rml_mods" mkdir -p "$ResonitePath/rml_libs" mkdir -p "$ResonitePath/Libraries" diff --git a/.github/workflows/check-repository-setup.yml b/.github/workflows/check-repository-setup.yml index 4b48dd5..f41a5d7 100644 --- a/.github/workflows/check-repository-setup.yml +++ b/.github/workflows/check-repository-setup.yml @@ -6,12 +6,13 @@ on: secrets: RML_MANIFEST_TOKEN: required: true - RESONITE_CLONE_TOKEN: + STEAM_USER: + required: true + STEAM_TOKEN: required: true env: RML_MANIFEST_REPO: "${{ github.repository_owner }}/resonite-mod-manifest" - RESONITE_CLONE_REPO: "${{ github.repository_owner }}/ResoniteFiles" permissions: issues: write @@ -20,12 +21,21 @@ jobs: create-todo-issues: runs-on: ubuntu-latest steps: - - name: "Check RESONITE_CLONE_TOKEN exists" + - name: "Check STEAM_USER exists" continue-on-error: true - id: resonite-token + id: steam-user shell: bash run: | - if [ "${{ secrets.RESONITE_CLONE_TOKEN }}" == '' ]; then + if [ "${{ secrets.STEAM_USER }}" == '' ]; then + exit 1; + fi + + - name: "Check STEAM_TOKEN exists" + continue-on-error: true + id: steam-token + shell: bash + run: | + if [ "${{ secrets.STEAM_TOKEN }}" == '' ]; then exit 1; fi @@ -38,16 +48,6 @@ jobs: exit 1; fi - - name: "Check if repository ${{ env.RESONITE_CLONE_REPO }} exists" - if: "${{ steps.resonite-token.outcome == 'success' }}" - continue-on-error: true - id: resonite-repo - uses: actions/checkout@v4 - with: - repository: ${{ env.RESONITE_CLONE_REPO }} - token: ${{ secrets.RESONITE_CLONE_TOKEN }} - path: resonite - - name: "Check if repository ${{ env.RML_MANIFEST_REPO }} exists" id: manifest-repo if: "${{ steps.manifest-token.outcome == 'success' }}" @@ -67,21 +67,18 @@ jobs: fi - name: Create Issue with TODOs - if: "${{ steps.manifest-token.outcome != 'success' || steps.resonite-token.outcome != 'success' || steps.manifest-repo.outcome != 'success' || steps.resonite-repo.outcome != 'success' || steps.github-new.outcome != 'success' }}" + if: "${{ steps.manifest-token.outcome != 'success' || steps.manifest-repo.outcome != 'success' || steps.steam-user.outcome != 'success' || steps.steam-token.outcome != 'success' || steps.github-new.outcome != 'success' }}" uses: dacbd/create-issue-action@ba4d1c45cccf9c483f2720cefb40e437f0ee6f7d with: token: ${{ github.token }} title: Setup repository to support full CI/CD body: | ### Necessary actions: - - [${{ steps.manifest-token.outcome == 'success' && 'X' || ' ' }}] Add RML_MANIFEST_TOKEN + - [${{ steps.manifest-token.outcome == 'success' && 'X' || ' ' }}] [Add secret](https://github.com/${{ github.repository }}/settings/secrets/actions) RML_MANIFEST_TOKEN - [${{ steps.manifest-repo.outcome == 'success' && 'X' || ' ' }}] Make sure a RML manifest repository is set up that is a fork of the [Resonite Mod Manifest](https://github.com/resonite-modding-group/resonite-mod-manifest) - - [${{ steps.resonite-token.outcome == 'success' && 'X' || ' ' }}] Add RESONITE_CLONE_TOKEN - - [${{ steps.resonite-repo.outcome == 'success' && 'X' || ' ' }}] Make sure a repository with Resonite files exists - For licensing reasons this should be a private repository that can only be accessed using the RESONITE_CLONE_TOKEN. - It should contain the directory `Resonite` with all engine dll files in the same hierarchy as they appear in a Resonite install. - You can use the Windows-only script [update-ResoniteFiles.cmd](${{ github.server_url }}/${{ github.repository }}/blob/main/update-ResoniteFiles.cmd) to keep your private Resonite repository up to date with your local install. - Hopefully this will be resolved with official sources in the future. - - [${{ steps.resonite-repo.outcome == 'success' && 'X' || ' ' }}] Update workflows to finish template initialization (overwrite `.github` with `.github_new`) + - [${{ steps.steam-user.outcome == 'success' && 'X' || ' ' }}] [Add secret](https://github.com/${{ github.repository }}/settings/secrets/actions) STEAM_USER + Note: Don't use your regular Steam account as enabled Steam Guard will interfere with automation! + - [${{ steps.steam-token.outcome == 'success' && 'X' || ' ' }}] [Add secret](https://github.com/${{ github.repository }}/settings/secrets/actions) STEAM_TOKEN + - [${{ steps.github-new.outcome == 'success' && 'X' || ' ' }}] Update workflows to finish template initialization (overwrite `.github` with `.github_new`) This step is necessary since for security reasons workflows are not directly allowed to modify workflows. assignees: ${{ github.repository_owner }} diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 2727f87..105108d 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -51,7 +51,8 @@ jobs: RELEASE_VERSION: "${{ inputs.version }}" RELEASE_NOTES: "${{ inputs.description }}" secrets: - RESONITE_CLONE_TOKEN: "${{ secrets.RESONITE_CLONE_TOKEN }}" + STEAM_USER: "${{ secrets.STEAM_USER }}" + STEAM_TOKEN: "${{ secrets.STEAM_TOKEN }}" compile-monkey: if: ${{ inputs.release-monkey }} uses: ./.github/workflows/build-monkey.yml @@ -60,7 +61,8 @@ jobs: RELEASE_VERSION: "${{ inputs.version }}" RELEASE_NOTES: "${{ inputs.description }}" secrets: - RESONITE_CLONE_TOKEN: "${{ secrets.RESONITE_CLONE_TOKEN }}" + STEAM_USER: "${{ secrets.STEAM_USER }}" + STEAM_TOKEN: "${{ secrets.STEAM_TOKEN }}" create-github-release: if: ${{ inputs.release-rml }} diff --git a/.github/workflows/init-template.yml b/.github/workflows/init-template.yml index b1572c5..673aadb 100644 --- a/.github/workflows/init-template.yml +++ b/.github/workflows/init-template.yml @@ -109,6 +109,8 @@ jobs: uses: ./.github/workflows/check-repository-setup.yml secrets: RML_MANIFEST_TOKEN: "${{ secrets.RML_MANIFEST_TOKEN }}" - RESONITE_CLONE_TOKEN: "${{ secrets.RESONITE_CLONE_TOKEN }}" + STEAM_USER: "${{ secrets.STEAM_USER }}" + STEAM_TOKEN: "${{ secrets.STEAM_TOKEN }}" + diff --git a/.github/workflows/update-ResoniteFiles.cmd b/.github/workflows/update-ResoniteFiles.cmd deleted file mode 100644 index ecfa683..0000000 --- a/.github/workflows/update-ResoniteFiles.cmd +++ /dev/null @@ -1,6 +0,0 @@ -:: Note: This command needs the %ResonitePath% to be set! (quick & dirty code: does not check that) -rmdir /S /Q Resonite -mkdir Resonite\Resonite_Data\Managed\ -powershell -Command Copy -Destination 'Resonite' -Path '%ResonitePath%\*.dll' -Exclude 'MonkeyLoader.dll','Mono*','NuGet*','winhttp.dll','Zio.dll','0Harmony.dll' -powershell -Command Copy -Destination 'Resonite\Resonite_Data\Managed\' -Path '%ResonitePath%\Resonite_Data\Managed\*.dll' -:: powershell -Command Compress-Archive -Force -DestinationPath Resonite.zip -Path Resonite \ No newline at end of file diff --git a/Mod.RML/SampleModRML.cs b/Mod.RML/SampleModRML.cs index bb9d830..b0816fc 100644 --- a/Mod.RML/SampleModRML.cs +++ b/Mod.RML/SampleModRML.cs @@ -9,7 +9,7 @@ public class SampleModRML : ResoniteMod, ISampleMod { public override string Name => "SampleMod"; public override string Author => "mpmxyz"; - public override string Version => "2.0.0"; //Version of the mod, should match the AssemblyVersion + public override string Version => "3.0.0"; //Version of the mod, should match the AssemblyVersion public override string Link => "https://github.com/mpmxyz/ResoniteSampleMod"; diff --git a/README.md b/README.md index 58e27d7..13ae6b2 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,14 @@ Additional Notes: If you open multiple variants at a time you may encounter warning messages and cannot save changes to the csproj files! Restarting Visual Studio makes sure that the error messages go away. - You can freely add dependencies to your project. Shared dependencies should be added to the project SampleMod.csproj (without suffix!) to keep dependencies of the variants in sync. -- Unit tests are run on the mod loader independent project. +- There are unit tests using the mod loader independent project. - You can start Resonite directly from Visual Studio. The dll files/NuGet packages will be directly copied into the Resonite install. If you add additional files you have to adjust the scripts in the files SampleModMonkey.csproj and SampleModRML.csproj. The file ```manifest-template.json``` and the step ```Build``` of workflow ```Build & Test (ResoniteModLoader)``` need to be adjusted for proper release automation, too. (TODO: hints for NuGet-based MonkeyLoader mods) ## Publishing a new Mod Version -1. Increment the <Version> number within the file ```SampleMod.csproj``` +1. Increment the <Version> number within the files ```SampleMod.csproj``` and ```Mod.RML/SampleModRML.cs``` 2. Execute the github workflow ```Create Release``` ## Installation (ResoniteModLoader) diff --git a/SampleMod.csproj b/SampleMod.csproj index cf3bedd..8636f29 100644 --- a/SampleMod.csproj +++ b/SampleMod.csproj @@ -10,7 +10,7 @@ SampleMod A sample Resonite Mod CC0 - 2.0.0 + 3.0.0 $(PROJECT_URL) $(RELEASE_NOTES) Resonite