Skip to content

Commit

Permalink
Now Downloading Resonite from Steam (#47)
Browse files Browse the repository at this point in the history
removed secret RESONITE_CLONE_TOKEN
added secrets STEAM_USER and STEAM_TOKEN
closes #44
  • Loading branch information
mpmxyz authored Jan 11, 2024
1 parent 6ddbc14 commit 351fc49
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 59 deletions.
43 changes: 32 additions & 11 deletions .github/workflows/build-monkey.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ on:
required: false
default: ""
secrets:
RESONITE_CLONE_TOKEN:
STEAM_USER:
required: true
STEAM_TOKEN:
required: true
env:
ARTIFACT_NAME: "SampleMod"
Expand All @@ -33,28 +35,47 @@ 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"
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<<EOFEOF"
curl https://api.steamcmd.net/v1/info/2519830
echo ""
echo "EOFEOF"
} >> "$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:
Expand Down
44 changes: 33 additions & 11 deletions .github/workflows/build-rml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ on:
required: false
default: ""
secrets:
RESONITE_CLONE_TOKEN:
STEAM_USER:
required: true
STEAM_TOKEN:
required: true
env:
ARTIFACT_NAME: "SampleMod"
Expand All @@ -33,28 +35,47 @@ 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"
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<<EOFEOF"
curl https://api.steamcmd.net/v1/info/2519830
echo ""
echo "EOFEOF"
} >> "$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:
Expand All @@ -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"
Expand Down
45 changes: 21 additions & 24 deletions .github/workflows/check-repository-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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' }}"
Expand All @@ -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 }}
6 changes: 4 additions & 2 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/init-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"



6 changes: 0 additions & 6 deletions .github/workflows/update-ResoniteFiles.cmd

This file was deleted.

2 changes: 1 addition & 1 deletion Mod.RML/SampleModRML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";


Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 &lt;Version&gt; number within the file ```SampleMod.csproj```
1. Increment the &lt;Version&gt; number within the files ```SampleMod.csproj``` and ```Mod.RML/SampleModRML.cs```
2. Execute the github workflow ```Create Release```

## Installation (ResoniteModLoader)
Expand Down
2 changes: 1 addition & 1 deletion SampleMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Product>SampleMod</Product>
<Description>A sample Resonite Mod</Description>
<Copyright>CC0</Copyright>
<Version>2.0.0</Version>
<Version>3.0.0</Version>
<PackageProjectUrl>$(PROJECT_URL)</PackageProjectUrl>
<PackageReleaseNotes>$(RELEASE_NOTES)</PackageReleaseNotes>
<PackageTags>Resonite</PackageTags>
Expand Down

0 comments on commit 351fc49

Please sign in to comment.