ConfigManager update #102
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '.github/**' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the repository and its submodules | |
- name: Checkout Submodule | |
uses: actions/[email protected] | |
with: | |
submodules: true | |
# Step 2: Set environment variables | |
- name: Set Environment Variables | |
run: | | |
# Extract variables from manifest.json | |
echo "MOD_NAME=$(cat ./manifest.json | jq --raw-output '.EntryDll' | sed 's/.dll//i')" >> $GITHUB_ENV | |
echo "MOD_VERSION=$(cat ./manifest.json | jq --raw-output '.Version')" >> $GITHUB_ENV | |
# Fetch the latest tag from the reference assemblies repository | |
echo "REFASM_TAG=$(curl -s 'https://api.github.com/repos/Smoked-Fish/mod-reference-assemblies/tags' | jq -r '.[0].name')" >> $GITHUB_ENV | |
# Set up GamePath | |
echo "GamePath=$GITHUB_WORKSPACE/GamePath" >> "$GITHUB_ENV" | |
echo "<Project><PropertyGroup><GamePath>$GITHUB_WORKSPACE/GamePath</GamePath></PropertyGroup></Project>" > "$HOME/stardewvalley.targets" | |
# Step 3: Cache NuGet packages | |
- name: Cache NuGet | |
id: cache-nuget | |
uses: actions/[email protected] | |
with: | |
path: | | |
~/.nuget/packages | |
${{ github.workspace }}/obj | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | |
# Step 4: Cache reference assemblies | |
- name: Restore Reference Assemblies | |
id: cache-refasm | |
uses: actions/[email protected] | |
with: | |
path: GamePath | |
key: ${{ runner.os }}-mod-reference-${{ env.REFASM_TAG }} | |
# Step 5: Set up .NET | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 6.0.x | |
# Step 6: Check out the reference assemblies if not cached | |
- name: Setup game and SMAPI | |
if: steps.cache-refasm.outputs.cache-hit != 'true' | |
uses: actions/checkout@v4 | |
with: | |
repository: Smoked-Fish/mod-reference-assemblies | |
fetch-tags: true | |
ref: refs/tags/${{ env.REFASM_TAG }} | |
path: GamePath | |
# Step 7: Restore NuGet dependencies if not cached | |
- name: Restore dependencies | |
if: steps.cache-nuget.outputs.cache-hit != 'true' | |
run: dotnet restore | |
# Step 8: Build the project | |
- name: Build | |
run: dotnet build --no-restore --configuration Release | |
# Step 9: Unzip the mod for artifact upload | |
- name: Unzip mod | |
run: | | |
MOD_ZIP_PATH="${{ github.workspace }}/bin/Release/${{ env.MOD_NAME }} ${{ env.MOD_VERSION }}.zip" | |
unzip "$MOD_ZIP_PATH" -d Mod | |
# Step 10: Upload the mod as an artifact | |
- name: Upload Artifact | |
uses: actions/[email protected] | |
with: | |
name: ${{ env.MOD_NAME }} ${{ env.MOD_VERSION }} | |
path: Mod | |
compression-level: 9 |