Update and Publish #3958
This file contains hidden or 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: Update and Publish | |
| on: | |
| schedule: | |
| - cron: "*/15 * * * *" | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version override (e.g., 3.25.10.1). Leave empty to auto-detect." | |
| required: false | |
| type: string | |
| force: | |
| description: "Force update even if version matches" | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| needs_update: ${{ steps.check.outputs.needs_update }} | |
| new_buildid: ${{ steps.check.outputs.new_buildid }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Check Steam build ID | |
| id: check | |
| run: | | |
| # Get current build ID from repo | |
| if [ -f "buildid.txt" ]; then | |
| CURRENT_BUILD=$(cat buildid.txt) | |
| else | |
| CURRENT_BUILD="0" | |
| fi | |
| echo "Current build ID: $CURRENT_BUILD" | |
| if [ -n "${{ inputs.version }}" ]; then | |
| # Manual version override - always update | |
| echo "needs_update=true" >> $GITHUB_OUTPUT | |
| echo "Manual version override: ${{ inputs.version }}" | |
| else | |
| # Get latest build ID from Steam API | |
| RESPONSE=$(curl -s "https://api.steamcmd.net/v1/info/1110390") | |
| NEW_BUILD=$(echo "$RESPONSE" | jq -r '.data["1110390"].depots.branches.public.buildid') | |
| echo "Steam build ID: $NEW_BUILD" | |
| echo "new_buildid=$NEW_BUILD" >> $GITHUB_OUTPUT | |
| FORCE="${{ inputs.force }}" | |
| if [ "$CURRENT_BUILD" = "$NEW_BUILD" ] && [ "$FORCE" != "true" ]; then | |
| echo "needs_update=false" >> $GITHUB_OUTPUT | |
| echo "No update needed" | |
| else | |
| echo "needs_update=true" >> $GITHUB_OUTPUT | |
| echo "Update available: build $CURRENT_BUILD -> $NEW_BUILD" | |
| fi | |
| fi | |
| update-and-publish: | |
| needs: check-version | |
| if: needs.check-version.outputs.needs_update == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install DepotDownloader | |
| run: | | |
| wget -q https://github.com/SteamRE/DepotDownloader/releases/latest/download/DepotDownloader-linux-x64.zip | |
| unzip -q DepotDownloader-linux-x64.zip -d depotdownloader | |
| chmod +x depotdownloader/DepotDownloader | |
| - name: Create file lists | |
| run: | | |
| cat > binaries_filelist.txt << 'EOF' | |
| Unturned_Headless_Data/Managed/Assembly-CSharp.dll | |
| Unturned_Headless_Data/Managed/Assembly-CSharp.xml | |
| Unturned_Headless_Data/Managed/Newtonsoft.Json.dll | |
| Unturned_Headless_Data/Managed/SDG.NetTransport.dll | |
| Unturned_Headless_Data/Managed/UnityEngine.CoreModule.dll | |
| Unturned_Headless_Data/Managed/UnityEngine.PhysicsModule.dll | |
| Unturned_Headless_Data/Managed/UnityEngine.dll | |
| Unturned_Headless_Data/Managed/UnityEx.dll | |
| Unturned_Headless_Data/Managed/UnturnedDat.dll | |
| Unturned_Headless_Data/Managed/com.rlabrecque.steamworks.net.dll | |
| EOF | |
| cat > content_filelist.txt << 'EOF' | |
| Status.json | |
| Extras/Rocket.Unturned/Rocket.API.dll | |
| Extras/Rocket.Unturned/Rocket.Core.dll | |
| Extras/Rocket.Unturned/Rocket.Unturned.dll | |
| EOF | |
| - name: Download from Steam | |
| run: | | |
| ./depotdownloader/DepotDownloader -app 1110390 -depot 1110392 -os linux -dir download -filelist binaries_filelist.txt | |
| ./depotdownloader/DepotDownloader -app 1110390 -depot 1110393 -os linux -dir download -filelist content_filelist.txt | |
| - name: Get version from Status.json | |
| id: version | |
| run: | | |
| if [ -n "${{ inputs.version }}" ]; then | |
| VERSION="${{ inputs.version }}" | |
| else | |
| STATUS_FILE="download/Status.json" | |
| MAJOR=$(jq -r '.Game.Major_Version' "$STATUS_FILE") | |
| MINOR=$(jq -r '.Game.Minor_Version' "$STATUS_FILE") | |
| PATCH=$(jq -r '.Game.Patch_Version' "$STATUS_FILE") | |
| VERSION="3.${MAJOR}.${MINOR}.${PATCH}" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Copy assemblies | |
| run: | | |
| cp download/Unturned_Headless_Data/Managed/Assembly-CSharp.dll unturned/assemblies/ | |
| cp download/Unturned_Headless_Data/Managed/Assembly-CSharp.xml unturned/assemblies/ || true | |
| cp download/Unturned_Headless_Data/Managed/Newtonsoft.Json.dll unturned/assemblies/ | |
| cp download/Unturned_Headless_Data/Managed/SDG.NetTransport.dll unturned/assemblies/ | |
| cp download/Unturned_Headless_Data/Managed/UnityEngine.CoreModule.dll unturned/assemblies/ | |
| cp download/Unturned_Headless_Data/Managed/UnityEngine.PhysicsModule.dll unturned/assemblies/ | |
| cp download/Unturned_Headless_Data/Managed/UnityEngine.dll unturned/assemblies/ | |
| cp download/Unturned_Headless_Data/Managed/UnityEx.dll unturned/assemblies/ || true | |
| cp download/Unturned_Headless_Data/Managed/UnturnedDat.dll unturned/assemblies/ || true | |
| cp download/Unturned_Headless_Data/Managed/com.rlabrecque.steamworks.net.dll unturned/assemblies/ | |
| cp download/Extras/Rocket.Unturned/Rocket.API.dll rocket/assemblies/ | |
| cp download/Extras/Rocket.Unturned/Rocket.Core.dll rocket/assemblies/ | |
| cp download/Extras/Rocket.Unturned/Rocket.Unturned.dll rocket/assemblies/ | |
| - name: Update nuspec versions | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| sed -i "s|<version>[^<]*</version>|<version>$VERSION</version>|" unturned/RestoreMonarchy.UnturnedRedist.nuspec | |
| sed -i "s|<version>[^<]*</version>|<version>$VERSION</version>|" rocket/RestoreMonarchy.RocketRedist.nuspec | |
| sed -i "s|<dependency id=\"RestoreMonarchy.UnturnedRedist\" version=\"[^\"]*\"|<dependency id=\"RestoreMonarchy.UnturnedRedist\" version=\"$VERSION\"|" rocket/RestoreMonarchy.RocketRedist.nuspec | |
| - name: Save build ID | |
| run: | | |
| echo "${{ needs.check-version.outputs.new_buildid }}" > buildid.txt | |
| - name: Commit changes | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add unturned/ rocket/ buildid.txt | |
| git diff --staged --quiet || (git commit -m "Update to $VERSION" && git push) | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: "8.0.x" | |
| - name: Install NuGet CLI | |
| run: | | |
| curl -o nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe | |
| sudo apt-get update && sudo apt-get install -y mono-complete | |
| - name: Pack and publish UnturnedRedist | |
| run: | | |
| mono nuget.exe pack unturned/RestoreMonarchy.UnturnedRedist.nuspec -OutputDirectory out | |
| dotnet nuget push out/RestoreMonarchy.UnturnedRedist.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| - name: Pack and publish RocketRedist | |
| run: | | |
| mono nuget.exe pack rocket/RestoreMonarchy.RocketRedist.nuspec -OutputDirectory out | |
| dotnet nuget push out/RestoreMonarchy.RocketRedist.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate |