aa_greenhouse_fix command #121
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 | |
- name: Checkout Repository | |
uses: actions/[email protected] | |
# Step 2: Checkout Common | |
- name: Checkout or Restore Common Project | |
run: git clone https://github.com/Smoked-Fish/Common.git Common | |
# Step 3: 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 Targets | |
echo "GamePath=$GITHUB_WORKSPACE/GamePath" >> "$GITHUB_ENV" | |
echo "<Project><PropertyGroup><GamePath>$GITHUB_WORKSPACE/GamePath</GamePath></PropertyGroup></Project>" > "$HOME/stardewvalley.targets" | |
# Step 4: 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 5: 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 6: Set up .NET | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 6.0.x | |
# Step 7: 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 8: Restore NuGet dependencies if not cached | |
- name: Restore dependencies | |
if: steps.cache-nuget.outputs.cache-hit != 'true' | |
run: dotnet restore | |
# Step 9: Build the project | |
- name: Build | |
run: dotnet build --no-restore --configuration Release | |
# Step 10: 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 11: 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 |