-
Notifications
You must be signed in to change notification settings - Fork 1
335 lines (289 loc) · 13 KB
/
Update.Unturned.Redist.yaml
File metadata and controls
335 lines (289 loc) · 13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
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
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
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@v4
with:
ref: master
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
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
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 \
-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: Skip unchanged manifest
if: steps.compare_manifest.outputs.manifest_changed != 'true'
run: |
echo "No manifest changes for ${{ matrix.variant }}. Skipping update steps."
exit 0
- name: Download update tool
uses: robinraju/release-downloader@v1
with:
repository: RocketModFix/UnturnedRedistUpdateTool
latest: true
fileName: UnturnedRedistUpdateTool.zip
out-file-path: redist_tool
extract: true
- name: Setup SteamCMD
uses: CyberAndrii/setup-steamcmd@v1
- name: Update game files
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
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
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
run: |
msg=$( cat .commit )
echo "message=$msg" >> "$GITHUB_OUTPUT"
id: generate_commit_message
- name: Check for changes
id: check_changes
run: |
if git diff --quiet; then
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "No changes detected for ${{ matrix.variant }}"
else
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "Changes detected for ${{ matrix.variant }}"
fi
- name: Final check for changes
run: |
if git diff --quiet; then
echo "No changes detected after all processing for ${{ matrix.variant }}. Exiting."
exit 0
else
echo "Changes detected after all processing for ${{ matrix.variant }}"
fi
- name: Install BepInEx Assembly Publicizer
if: contains(matrix.variant, 'publicized')
run: |
dotnet tool install -g BepInEx.AssemblyPublicizer.Cli
echo "BepInEx Assembly Publicizer installed"
- name: Publicize Assembly-CSharp.dll
if: contains(matrix.variant, 'publicized')
run: |
echo "Publicizing Assembly-CSharp.dll for ${{ matrix.variant }}"
# Find Assembly-CSharp.dll in the redist directory
ASSEMBLY_PATH="$GITHUB_WORKSPACE/$REDIST_DIR/Assembly-CSharp.dll"
if [ -f "$ASSEMBLY_PATH" ]; then
echo "Found Assembly-CSharp.dll at: $ASSEMBLY_PATH"
# Create backup
cp "$ASSEMBLY_PATH" "$ASSEMBLY_PATH.backup"
echo "Created backup at: $ASSEMBLY_PATH.backup"
# Publicize the assembly
echo "Running assembly-publicizer..."
if assembly-publicizer "$ASSEMBLY_PATH"; then
echo "Successfully publicized Assembly-CSharp.dll"
# Remove backup if successful
rm "$ASSEMBLY_PATH.backup"
echo "Removed backup file"
else
echo "Failed to publicize Assembly-CSharp.dll"
echo "Restoring original file from backup..."
mv "$ASSEMBLY_PATH.backup" "$ASSEMBLY_PATH"
echo "Original file restored. Workflow will fail."
exit 1
fi
else
echo "Error: Assembly-CSharp.dll not found at $ASSEMBLY_PATH"
echo "This is required for publicized variants. Workflow will fail."
exit 1
fi
- name: Create Pull Request
id: create_pr
uses: peter-evans/create-pull-request@v7
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"
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 "- **Has Changes**: ${{ steps.check_changes.outputs.has_changes }}" >> $GITHUB_STEP_SUMMARY
if [[ "${{ steps.check_changes.outputs.has_changes }}" == "true" ]]; then
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
workflow-keepalive:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: liskin/gh-workflow-keepalive@v1