Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoco007 committed Apr 3, 2024
1 parent 387075f commit 7b794f7
Show file tree
Hide file tree
Showing 11 changed files with 229 additions and 160 deletions.
49 changes: 18 additions & 31 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,40 @@ jobs:
runs-on: windows-latest
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up environment
run: ${{ github.workspace }}\.github\workflows\set_up_env.ps1 "${{ github.workspace }}\Source\CustomAvatar\manifest.json"

- name: Fetch Beat Saber Bindings
run: git clone https://${{ github.actor }}:${{ secrets.PRIVATE_GITHUB_TOKEN }}@github.com/nicoco007/BeatSaberBindings --branch v${{ env.GAME_VERSION }} --single-branch '${{ runner.temp }}\BeatSaberBindings\Beat Saber_Data\Managed'

- name: Download dependencies
uses: nicoco007/download-beatmods-deps@main
- name: Set up Beat Saber
uses: nicoco007/setup-beat-saber@main
with:
manifest: ${{ github.workspace }}\Source\CustomAvatar\manifest.json
path: ${{ runner.temp }}\BeatSaberBindings
access-token: ${{ secrets.PRIVATE_GITHUB_TOKEN }}
additional-dependencies: '{ "XR Hands": "^1.1.0", "OpenVR API": "^2.0.0" }'
manifest: ${{ github.workspace }}\Source\CustomAvatar\manifest.json

- name: Add NuGet source
run: dotnet nuget update source "nicoco007 GitHub Packages" --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text

- name: Build Debug
run: dotnet build Source\CustomAvatar\CustomAvatar.csproj -c Debug -p:BeatSaberDir=${{ runner.temp }}\BeatSaberBindings

- name: Upload Debug
uses: actions/upload-artifact@v3
with:
name: BeatSaberCustomAvatars-${{ env.ZIP_VERSION }}-DEBUG
path: Source\CustomAvatar\bin\Debug\net472\publish

- name: Build Release
run: dotnet build Source\CustomAvatar\CustomAvatar.csproj -c Release -p:BeatSaberDir=${{ runner.temp }}\BeatSaberBindings
id: build-release
run: dotnet build Source\CustomAvatar\CustomAvatar.csproj -c Release

- name: Upload Release
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: BeatSaberCustomAvatars-${{ env.ZIP_VERSION }}-RELEASE
path: Source\CustomAvatar\bin\Release\net472\publish
name: ${{ steps.build-release.outputs.artifact-name }}
path: ${{ steps.build-release.outputs.artifact-path }}

- name: Build Editor
run: dotnet build Source\CustomAvatar-Editor\CustomAvatar-Editor.csproj -c Release -p:BeatSaberDir=${{ runner.temp }}\BeatSaberBindings
id: build-editor
run: dotnet build Source\CustomAvatar-Editor\CustomAvatar-Editor.csproj -c Release

- name: Upload Editor
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: BeatSaberCustomAvatars-${{ env.ZIP_VERSION }}-Editor
path: Source\CustomAvatar-Editor\bin\Release\net472\publish\CustomAvatar.dll
name: ${{ steps.build-editor.outputs.artifact-name }}
path: ${{ steps.build-editor.outputs.artifact-path }}

- name: Upload Unity Project
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: BeatSaberCustomAvatars-${{ env.ZIP_VERSION }}-UnityProject
path: Unity
name: ${{ steps.build-editor.outputs.unity-project-name }}
path: Unity\BeatSaberCustomAvatars
47 changes: 0 additions & 47 deletions .github/workflows/set_up_env.ps1

This file was deleted.

6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
## Getting Started
The easiest way to get Custom Avatars up and running is to use [ModAssistant](https://github.com/Assistant/ModAssistant). The latest version of Custom Avatars will always be posted in the [releases](https://github.com/nicoco007/BeatSaberCustomAvatars/releases) here, and then become available on ModAssistant a few days later. If you want to install it manually by using the releases available here or are looking for the files to create an avatar yourself, you can follow the instructions below.

### What to download
- RELEASE is what you should download if you just want to use the mod. If you are unsure what to download, this is the file you are looking for.
- DEBUG contains debug code and a PDB for debugging purposes. This is useful if you're developing a mod that relies on Custom Avatars.
- UnityProject contains a barebones Unity project to get started with creating avatars. You will need to copy `FinalIK.dll` and `DynamicBone.dll` from the game's installation folder into the `Assets\Libraries` folder **before opening the project in Unity** to get it working.
- Editor contains only the `CustomAvatar.dll` file for use in the editor. Use this if you want to update your current Unity project to the latest version of Custom Avatars.

### Installing manually
Install [BeatSaberMarkupLanguage](https://github.com/monkeymanboy/BeatSaberMarkupLanguage) and [DynamicOpenVR](https://github.com/nicoco007/DynamicOpenVR/releases) (the required versions are listed in Custom Avatars' release notes). Download [the latest release of Custom Avatars](https://github.com/nicoco007/BeatSaberCustomAvatars/releases/latest) and extract **the entire contents** of the ZIP file into your Beat Saber folder and **overwrite any existing files**. By default, your Beat Saber install folder should be `C:\Program Files (x86)\Steam\steamapps\common\Beat Saber` for Steam and `C:\Program Files\Oculus\Software\Software\hyperbolic-magnetism-beat-saber` for Oculus.

Expand Down
2 changes: 1 addition & 1 deletion Source/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
root = true

[*.{bsml,csproj,csproj.user}]
[*.{bsml,csproj,csproj.user,props,targets}]
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
Expand Down
36 changes: 0 additions & 36 deletions Source/CustomAvatar-Editor/CustomAvatar-Editor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,43 +82,7 @@
<ItemGroup>
<EmbeddedResource Include="Resources\**\*.*" />
</ItemGroup>
<Target Name="CheckBSMTInstalled" AfterTargets="BeforeBuild" Condition="'$(BSMTTaskAssembly)' == ''">
<Error Text="The BeatSaberModdingTools.Tasks NuGet package doesn't seem to be installed. Please restore NuGet packages before building the project." />
</Target>
<Target Name="SetAssemblyVersion" AfterTargets="CheckBSMTInstalled">
<GetManifestInfo ManifestPath="../CustomAvatar/manifest.json">
<Output TaskParameter="BasePluginVersion" PropertyName="BasePluginVersion" />
</GetManifestInfo>

<PropertyGroup>
<Version>$(BasePluginVersion)</Version>
</PropertyGroup>
</Target>
<Target Name="Organize" AfterTargets="AfterBuild">
<!-- remove deps.json file since it's not used -->
<Delete Files="$(TargetDir)$(TargetName).deps.json" />

<!-- make sure we have a clean slate -->
<RemoveDir Directories="$(PublishDir)" />

<MakeDir Directories="$(PublishDir)" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(PublishDir)" />

<!-- copy static files -->
<Copy SourceFiles="@(CopyToOutput)" DestinationFiles="@(CopyToOutput->'$(PublishDir)\%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>
<Target Name="CopyUnityProjectFiles" AfterTargets="AfterBuild" Condition="$(UnityProjectDir) != ''">
<ItemGroup>
<CopyToUnityProjectFolder Include="$(PublishDir)**\*.*" />
</ItemGroup>

<Copy SourceFiles="@(CopyToUnityProjectFolder)" DestinationFiles="@(CopyToUnityProjectFolder->'$(UnityProjectDir)\Assets\Libraries\%(RecursiveDir)%(Filename)%(Extension)')" Condition="!Exists('$(UnityProjectDir)\Assets\Libraries\%(RecursiveDir)%(Filename)%(Extension)') OR '%(Extension)' != '.meta'" />
</Target>
<ItemGroup>
<PackageReference Include="BeatSaberModdingTools.Tasks" Version="1.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="BSIPA.AssemblyPublicizer.MSBuild" Version="0.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
25 changes: 25 additions & 0 deletions Source/CustomAvatar-Editor/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendPlatformToOutputPath>false</AppendPlatformToOutputPath>
<BeatSaberOutputType>Plugin</BeatSaberOutputType>
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<LangVersion>12</LangVersion>
<Nullable>disable</Nullable>
<PathMap>$(MSBuildProjectDirectory)\$(IntermediateOutputPath)=$(MSBuildProjectName)</PathMap>
</PropertyGroup>

<ItemGroup>
<None Include="$(ProjectName).csproj.user" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BeatSaberModdingTools.Tasks" Version="1.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
68 changes: 68 additions & 0 deletions Source/CustomAvatar-Editor/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<Project>
<PropertyGroup>
<ManifestPath>$(ProjectDir)..\CustomAvatar\manifest.json</ManifestPath>
</PropertyGroup>

<!--Get info about the project used by later targets -->
<Target Name="GetProjectInfo" AfterTargets="BeforeBuild">
<GetManifestInfo ManifestPath="$(ManifestPath)">
<Output TaskParameter="PluginVersion" PropertyName="PluginVersion" />
<Output TaskParameter="GameVersion" PropertyName="GameVersion" />
<Output TaskParameter="BasePluginVersion" PropertyName="BasePluginVersion" />
</GetManifestInfo>

<PropertyGroup>
<Version>$(BasePluginVersion)</Version>
<FileVersion>$(BasePluginVersion)</FileVersion>
<InformationalVersion>$(PluginVersion)</InformationalVersion>
</PropertyGroup>
</Target>

<!-- Set shared properties that can't be set in a top-level PropertyGroup (too early) -->
<Target Name="GetProperties">
<PropertyGroup>
<ArtifactDir>$(TargetDir)Artifact\</ArtifactDir>
</PropertyGroup>
</Target>

<!-- Copy the assembly and PDB to the Artifact folder -->
<Target Name="CopyToArtifact" AfterTargets="AfterBuild" DependsOnTargets="GetProperties">
<Message Text="$(MSBuildProjectName) -&gt; $(ArtifactDir)" Importance="high" />

<MakeDir Directories="$(ArtifactDir)" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(ArtifactDir)" />
</Target>

<Target Name="SetGitHubActionsOutput" AfterTargets="CopyToArtifact" Condition="'$(GITHUB_ACTIONS)' == 'true'">
<Message Text="Writing to GitHub output" Importance="high" />

<PropertyGroup>
<ArtifactName>$(ProjectName)-v$(PluginVersion)</ArtifactName>
<ArtifactName Condition="'$(Configuration)' != 'Release'">$(ArtifactName)-$(Configuration)</ArtifactName>
</PropertyGroup>

<ItemGroup>
<LinesToWrite Include="artifact-name=$(ArtifactName)" />
<LinesToWrite Include="artifact-path=$(ArtifactDir)" />
<LinesToWrite Include="unity-project-name=$(ArtifactName.Replace('Editor', 'UnityProject'))" />
</ItemGroup>

<WriteLinesToFile File="$(GITHUB_OUTPUT)" Lines="@(LinesToWrite)" />
</Target>

<!-- Copy the assembly and PDB to the Unity Project's folder -->
<Target Name="CopyToUnityProject" AfterTargets="CopyToArtifact" Condition="'$(UnityProjectDir)' != ''">
<Message Text="$(MSBuildProjectName) -&gt; $(UnityProjectDir)" Importance="high" />

<ItemGroup>
<FilesToCopy Include="$(ArtifactDir)\**\*" />
</ItemGroup>

<Copy SourceFiles="@(FilesToCopy)" DestinationFiles="@(FilesToCopy->'$(UnityProjectDir)\Assets\Libraries\%(RecursiveDir)%(Filename)%(Extension)')" Condition="!Exists('$(UnityProjectDir)\Assets\Libraries\%(RecursiveDir)%(Filename)%(Extension)') OR '%(Extension)' != '.meta'" />
</Target>

<!-- Clean up artifact files -->
<Target Name="CleanArtifact" AfterTargets="Clean" DependsOnTargets="GetProperties">
<RemoveDir Directories="$(ArtifactDir)" />
</Target>
</Project>
1 change: 1 addition & 0 deletions Source/CustomAvatar.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
..\NuGet.config = ..\NuGet.config
..\README.md = ..\README.md
EndProjectSection
EndProject
Global
Expand Down
39 changes: 0 additions & 39 deletions Source/CustomAvatar/CustomAvatar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -213,53 +213,14 @@
<None Include="$(ProjectName).csproj.user" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="manifest.json" />
<EmbeddedResource Include="UI\Views\**\*.bsml" />
<EmbeddedResource Include="Resources\**\*" />
</ItemGroup>
<ItemGroup>
<CopyToOutput Include="$(ProjectDir)..\..\Packaging\CustomAvatar\**\*.*" />
</ItemGroup>
<Target Name="CheckBSMTInstalled" AfterTargets="BeforeBuild" Condition="'$(BSMTTaskAssembly)' == ''">
<Error Text="The BeatSaberModdingTools.Tasks NuGet package doesn't seem to be installed. Please restore NuGet packages before building the project." />
</Target>
<Target Name="SetAssemblyVersion" AfterTargets="CheckBSMTInstalled">
<GetManifestInfo>
<Output TaskParameter="BasePluginVersion" PropertyName="BasePluginVersion" />
</GetManifestInfo>

<PropertyGroup>
<Version>$(BasePluginVersion)</Version>
</PropertyGroup>
</Target>
<Target Name="Organize" AfterTargets="AfterBuild">
<!-- remove deps.json file since it's not used -->
<Delete Files="$(TargetDir)$(TargetName).deps.json" />

<!-- make sure we have a clean slate -->
<RemoveDir Directories="$(PublishDir)" />

<!-- create Plugins folder and move plugin DLL/PDB inside -->
<MakeDir Directories="$(PublishDir)Plugins" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(PublishDir)Plugins" />
<Copy SourceFiles="$(TargetDir)$(TargetName).pdb" DestinationFolder="$(PublishDir)Plugins" Condition="$(DebugType) == 'portable'" />

<!-- copy static files -->
<Copy SourceFiles="@(CopyToOutput)" DestinationFiles="@(CopyToOutput->'$(PublishDir)\%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>
<Target Name="CopyToBeatSaberFolder" AfterTargets="AfterBuild" Condition="$(BeatSaberDir) != ''">
<ItemGroup>
<CopyToBeatSaberFolder Include="$(PublishDir)**\*.*" />
</ItemGroup>

<Copy SourceFiles="@(CopyToBeatSaberFolder)" DestinationFiles="@(CopyToBeatSaberFolder->'$(BeatSaberDir)\%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>
<ProjectExtensions><VisualStudio><UserProperties manifest_1json__JsonSchema="https://json-schema.org/draft-04/schema" /></VisualStudio></ProjectExtensions>
<ItemGroup>
<PackageReference Include="BeatSaberModdingTools.Tasks" Version="1.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="BSIPA.AssemblyPublicizer.MSBuild" Version="0.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
25 changes: 25 additions & 0 deletions Source/CustomAvatar/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendPlatformToOutputPath>false</AppendPlatformToOutputPath>
<BeatSaberOutputType>Plugin</BeatSaberOutputType>
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<LangVersion>12</LangVersion>
<Nullable>disable</Nullable>
<PathMap>$(MSBuildProjectDirectory)\$(IntermediateOutputPath)=$(MSBuildProjectName)</PathMap>
</PropertyGroup>

<ItemGroup>
<None Include="$(ProjectName).csproj.user" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BeatSaberModdingTools.Tasks" Version="1.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
Loading

0 comments on commit 7b794f7

Please sign in to comment.