Update.Unturned.Redist #10152
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.Unturned.Redist" | |
| on: | |
| schedule: | |
| - cron: "*/15 * * * *" # Run every 15 minutes | |
| workflow_dispatch: | |
| inputs: | |
| variant: | |
| description: 'Which variant to update' | |
| required: true | |
| default: 'all' | |
| type: choice | |
| options: | |
| - all | |
| - client | |
| - server | |
| - server-preview | |
| - client-preview | |
| - server-preview-old | |
| - client-preview-old | |
| - client-publicized | |
| - server-publicized | |
| - client-preview-publicized | |
| - server-preview-publicized | |
| permissions: | |
| contents: write | |
| packages: write | |
| pull-requests: write | |
| concurrency: | |
| group: unturned-redist-update-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| determine-variants: | |
| name: "Determine Variants to Run" | |
| runs-on: ubuntu-latest | |
| outputs: | |
| variants: ${{ steps.set_variants.outputs.variants }} | |
| steps: | |
| - name: Set variants | |
| id: set_variants | |
| run: | | |
| if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then | |
| if [ "$INPUT_VARIANT" = "all" ]; then | |
| all_variants=("client" "server" "server-preview" "client-preview" "server-preview-old" "client-preview-old" "client-publicized" "server-publicized" "client-preview-publicized" "server-preview-publicized") | |
| variants_json=$(printf '%s\n' "${all_variants[@]}" | jq -R . | jq -s -c .) | |
| echo "variants=$variants_json" >> $GITHUB_OUTPUT | |
| else | |
| echo "variants=[\"${INPUT_VARIANT}\"]" >> $GITHUB_OUTPUT | |
| fi | |
| else | |
| all_variants=("client" "server" "server-preview" "client-preview" "server-preview-old" "client-preview-old" "client-publicized" "server-publicized" "client-preview-publicized" "server-preview-publicized") | |
| variants_json=$(printf '%s\n' "${all_variants[@]}" | jq -R . | jq -s -c .) | |
| echo "variants=$variants_json" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| INPUT_VARIANT: ${{ github.event.inputs.variant }} | |
| GITHUB_EVENT_NAME: ${{ github.event_name }} | |
| update_redist: | |
| name: "Update Redist" | |
| runs-on: ubuntu-latest | |
| needs: determine-variants | |
| continue-on-error: true | |
| strategy: | |
| matrix: | |
| variant: ${{ fromJson(needs.determine-variants.outputs.variants) }} | |
| fail-fast: false | |
| steps: | |
| - name: Determine APP_ID, APP_BRANCH_NAME, APP_DEPOT_ID, and REDIST_DIR | |
| id: vars | |
| continue-on-error: true | |
| run: | | |
| if [[ "${{ matrix.variant }}" == client || "${{ matrix.variant }}" == client-preview || "${{ matrix.variant }}" == client-preview-publicized || "${{ matrix.variant }}" == client-preview-old ]]; then | |
| echo "APP_ID=304930" >> $GITHUB_ENV | |
| echo "APP_DEPOT_ID=304931" >> $GITHUB_ENV | |
| else | |
| echo "APP_ID=1110390" >> $GITHUB_ENV | |
| echo "APP_DEPOT_ID=1110391" >> $GITHUB_ENV | |
| fi | |
| if [[ "${{ matrix.variant }}" == client-preview || "${{ matrix.variant }}" == server-preview || "${{ matrix.variant }}" == client-preview-publicized || "${{ matrix.variant }}" == server-preview-publicized || "${{ matrix.variant }}" == client-preview-old || "${{ matrix.variant }}" == server-preview-old ]]; then | |
| echo "APP_BRANCH_NAME=preview" >> $GITHUB_ENV | |
| fi | |
| case "${{ matrix.variant }}" in | |
| client-preview) echo "REDIST_DIR=redist/redist-client-preview" >> $GITHUB_ENV ;; | |
| server-preview) echo "REDIST_DIR=redist/redist-server-preview" >> $GITHUB_ENV ;; | |
| client-preview-old) echo "REDIST_DIR=redist/redist-client-preview-old" >> $GITHUB_ENV ;; | |
| server-preview-old) echo "REDIST_DIR=redist/redist-server-preview-old" >> $GITHUB_ENV ;; | |
| client) echo "REDIST_DIR=redist/redist-client" >> $GITHUB_ENV ;; | |
| server) echo "REDIST_DIR=redist/redist-server" >> $GITHUB_ENV ;; | |
| client-publicized) echo "REDIST_DIR=redist/redist-client-publicized" >> $GITHUB_ENV ;; | |
| server-publicized) echo "REDIST_DIR=redist/redist-server-publicized" >> $GITHUB_ENV ;; | |
| client-preview-publicized) echo "REDIST_DIR=redist/redist-client-preview-publicized" >> $GITHUB_ENV ;; | |
| server-preview-publicized) echo "REDIST_DIR=redist/redist-server-preview-publicized" >> $GITHUB_ENV ;; | |
| *) echo "REDIST_DIR=redist/redist-unknown" >> $GITHUB_ENV ;; | |
| esac | |
| # Generate unique branch name | |
| timestamp=$(date +%Y%m%d-%H%M%S) | |
| echo "BRANCH_NAME=redist-update/${{ matrix.variant }}-${timestamp}" >> $GITHUB_ENV | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: master | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| env: | |
| DOTNET_NOLOGO: true | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
| DOTNET_CLI_TELEMETRY_OPTOUT: true | |
| with: | |
| dotnet-version: | | |
| 9.x | |
| 6.0.x | |
| - name: Download depot downloader | |
| uses: robinraju/release-downloader@v1 | |
| with: | |
| repository: SteamRE/DepotDownloader | |
| latest: true | |
| fileName: DepotDownloader-linux-x64.zip | |
| out-file-path: depot_downloader | |
| tag: "DepotDownloader_3.4.0" # Pin it's version to avoid breaking changes. | |
| extract: true | |
| - name: Compare current vs saved manifest | |
| id: compare_manifest | |
| continue-on-error: true | |
| run: | | |
| MANIFEST_FILE="redist/redist-manifests/.manifest.redist-${{ matrix.variant }}.txt" | |
| mkdir -p redist/temp_depots | |
| chmod +x depot_downloader/DepotDownloader | |
| manifest_output=$(depot_downloader/DepotDownloader \ | |
| -app $APP_ID \ | |
| -depot $APP_DEPOT_ID \ | |
| -username ${{ secrets.STEAM_USERNAME }} \ | |
| -password ${{ secrets.STEAM_PASSWORD }} \ | |
| -manifest-only \ | |
| -beta $APP_BRANCH_NAME \ | |
| -dir redist/temp_depots) | |
| current_manifest=$(echo "$manifest_output" | grep -oE '[0-9]{19}' | head -n 1) | |
| echo "Current manifest: $current_manifest" | |
| if [ -f "$MANIFEST_FILE" ]; then | |
| previous_manifest=$(cat "$MANIFEST_FILE") | |
| else | |
| previous_manifest="" | |
| fi | |
| echo "Previous manifest: $previous_manifest" | |
| if [ "$current_manifest" != "$previous_manifest" ]; then | |
| echo "Manifest changed" | |
| echo "$current_manifest" > "$MANIFEST_FILE" | |
| echo "manifest_changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Manifest unchanged" | |
| echo "manifest_changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Download update tool | |
| if: steps.compare_manifest.outputs.manifest_changed == 'true' | |
| uses: robinraju/release-downloader@v1 | |
| with: | |
| repository: RocketModFix/UnturnedRedistUpdateTool | |
| latest: true | |
| fileName: UnturnedRedistUpdateTool.zip | |
| out-file-path: redist_tool | |
| extract: true | |
| - name: Setup SteamCMD | |
| if: steps.compare_manifest.outputs.manifest_changed == 'true' | |
| uses: CyberAndrii/setup-steamcmd@v1 | |
| - name: Update game files | |
| if: steps.compare_manifest.outputs.manifest_changed == 'true' | |
| run: | | |
| if [[ "$APP_BRANCH_NAME" == "" ]]; then | |
| steamcmd +force_install_dir $GITHUB_WORKSPACE +login ${{ secrets.STEAM_USERNAME }} ${{ secrets.STEAM_PASSWORD }} +app_update $APP_ID -validate +quit | |
| else | |
| steamcmd +force_install_dir $GITHUB_WORKSPACE +login ${{ secrets.STEAM_USERNAME }} ${{ secrets.STEAM_PASSWORD }} +app_update $APP_ID -beta $APP_BRANCH_NAME -validate +quit | |
| fi | |
| - name: Run redist updater | |
| if: steps.compare_manifest.outputs.manifest_changed == 'true' | |
| continue-on-error: true | |
| run: | | |
| flags="" | |
| # Add --force flag for manual dispatch | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| flags="$flags --force" | |
| fi | |
| # Add --preview flag for preview variants | |
| case "${{ matrix.variant }}" in | |
| client-preview|server-preview) | |
| flags="$flags --preview" | |
| ;; | |
| esac | |
| # Add -update-files with all DLL files | |
| flags="$flags -update-files Assembly-CSharp.dll,Assembly-CSharp.xml,SDG.NetPak.Runtime.xml,UnturnedDat.dll,UnityEx.dll,SystemEx.dll,SDG.NetTransport.dll,SDG.NetPak.Runtime.dll,SDG.HostBans.Runtime.dll,SDG.Glazier.Runtime.dll,com.rlabrecque.steamworks.net.dll" | |
| if [[ "${{ matrix.variant }}" == client-publicized || "${{ matrix.variant }}" == server-publicized || "${{ matrix.variant }}" == client-preview-publicized || "${{ matrix.variant }}" == server-preview-publicized ]]; then | |
| flags="$flags -publicize Assembly-CSharp.dll" | |
| fi | |
| echo "Event name: ${{ github.event_name }}" | |
| echo "Matrix variant: ${{ matrix.variant }}" | |
| echo "Final flags: '$flags'" | |
| dotnet redist_tool/UnturnedRedistUpdateTool.dll "$GITHUB_WORKSPACE" "$GITHUB_WORKSPACE/$REDIST_DIR" "$APP_ID" $flags | |
| - name: Generate Commit Message | |
| if: steps.compare_manifest.outputs.manifest_changed == 'true' | |
| run: | | |
| msg=$( cat .commit ) | |
| echo "message=$msg" >> "$GITHUB_OUTPUT" | |
| id: generate_commit_message | |
| - name: Check for git changes | |
| if: steps.compare_manifest.outputs.manifest_changed == 'true' | |
| id: check_git_changes | |
| run: | | |
| if git diff --quiet; then | |
| echo "No changes detected after all processing for ${{ matrix.variant }}." | |
| echo "has_git_changes=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Changes detected after all processing for ${{ matrix.variant }}" | |
| echo "has_git_changes=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Check for existing PRs | |
| if: steps.compare_manifest.outputs.manifest_changed == 'true' && steps.check_git_changes.outputs.has_git_changes == 'true' | |
| id: check_existing_prs | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Check for existing open PRs for this variant created by rocketmodfixadmin | |
| existing_prs=$(gh pr list --state open --search "Auto-update ${{ matrix.variant }} redist files" --json number,title,url,author) | |
| # Filter to only include PRs created by rocketmodfixadmin | |
| filtered_prs=$(echo "$existing_prs" | jq '[.[] | select(.author.login == "rocketmodfixadmin")]') | |
| if [ "$(echo "$filtered_prs" | jq length)" -gt 0 ]; then | |
| echo "Found existing PRs for ${{ matrix.variant }} created by rocketmodfixadmin:" | |
| echo "$filtered_prs" | jq -r '.[] | "- #\(.number): \(.title) by \(.author.login) (\(.url))"' | |
| echo "has_existing_pr=true" >> $GITHUB_OUTPUT | |
| echo "existing_pr_count=$(echo "$filtered_prs" | jq length)" >> $GITHUB_OUTPUT | |
| else | |
| echo "No existing PRs found for ${{ matrix.variant }} created by rocketmodfixadmin" | |
| echo "has_existing_pr=false" >> $GITHUB_OUTPUT | |
| echo "existing_pr_count=0" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Pull Request | |
| if: steps.compare_manifest.outputs.manifest_changed == 'true' && steps.check_git_changes.outputs.has_git_changes == 'true' && steps.check_existing_prs.outputs.has_existing_pr == 'false' | |
| id: create_pr | |
| uses: peter-evans/create-pull-request@v8 | |
| with: | |
| add-paths: | | |
| redist/* | |
| token: ${{ secrets.PAT }} | |
| branch: ${{ env.BRANCH_NAME }} | |
| base: master | |
| commit-message: "${{ steps.generate_commit_message.outputs.message }}" | |
| title: "🤖 Auto-update ${{ matrix.variant }} redist files" | |
| committer: rocketmodfixadmin <[email protected]> | |
| author: rocketmodfixadmin <[email protected]> | |
| body: | | |
| ## Automated Redist Update - ${{ matrix.variant }} | |
| This PR contains automatically updated redist files for the **${{ matrix.variant }}** variant. | |
| ### Changes | |
| ${{ steps.generate_commit_message.outputs.message }} | |
| ### Validation | |
| 🔄 Validation will run automatically when this PR is created. | |
| --- | |
| **Triggered by**: ${{ github.event_name == 'workflow_dispatch' && 'Manual dispatch' || 'Scheduled run' }} | |
| **Variant**: ${{ matrix.variant }} | |
| **Branch**: `${{ env.BRANCH_NAME }}` | |
| > This PR was automatically created by the Unturned Redist update workflow. | |
| > Validation checks will run automatically. Review the changes carefully before merging. | |
| draft: false | |
| labels: | | |
| automated | |
| redist-update | |
| ${{ matrix.variant }} | |
| - name: Summary | |
| run: | | |
| echo "## Update Summary for ${{ matrix.variant }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Branch**: \`${{ env.BRANCH_NAME }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Manifest Changed**: ${{ steps.compare_manifest.outputs.manifest_changed }}" >> $GITHUB_STEP_SUMMARY | |
| if [[ "${{ steps.compare_manifest.outputs.manifest_changed }}" == "true" ]]; then | |
| echo "- **Git Changes**: ${{ steps.check_git_changes.outputs.has_git_changes }}" >> $GITHUB_STEP_SUMMARY | |
| if [[ "${{ steps.check_git_changes.outputs.has_git_changes }}" == "true" ]]; then | |
| echo "- **Existing PRs**: ${{ steps.check_existing_prs.outputs.existing_pr_count }}" >> $GITHUB_STEP_SUMMARY | |
| if [[ "${{ steps.check_existing_prs.outputs.has_existing_pr }}" == "true" ]]; then | |
| echo "- **Status**: Skipped (existing PR already pending)" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "- **PR Created**: #${{ steps.create_pr.outputs.pull-request-number }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **PR URL**: ${{ steps.create_pr.outputs.pull-request-url }}" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| else | |
| echo "- **Status**: No git changes detected after processing" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| else | |
| echo "- **Status**: Skipped (no manifest changes)" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| workflow-keepalive: | |
| if: github.event_name == 'schedule' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: write | |
| steps: | |
| - uses: liskin/gh-workflow-keepalive@v1 |