-
Notifications
You must be signed in to change notification settings - Fork 1
165 lines (144 loc) · 5.51 KB
/
Update.Unturned.Redist.yaml
File metadata and controls
165 lines (144 loc) · 5.51 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
name: "Update.Unturned.Redist"
on:
schedule:
- cron: "*/15 * * * *" # Run every 15 minutes
workflow_dispatch:
inputs:
variant:
description: 'Which variant to update'
required: true
default: 'client'
type: choice
options:
- client
- server
- server-preview
- client-preview
- server-preview-old
- client-preview-old
permissions:
contents: write
packages: 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
echo "variants=[\"${INPUT_VARIANT}\"]" >> $GITHUB_OUTPUT
else
all_variants=("client" "server" "server-preview" "client-preview" "server-preview-old" "client-preview-old")
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) }}
# Run sequentially, one variant at a time
max-parallel: 1
fail-fast: false
steps:
- name: Determine APP_ID and REDIST_DIR
id: vars
run: |
if [[ "${{ matrix.variant }}" == client || "${{ matrix.variant }}" == client-preview || "${{ matrix.variant }}" == client-preview-old ]]; then
echo "APP_ID=304930" >> $GITHUB_ENV
else
echo "APP_ID=1110390" >> $GITHUB_ENV
fi
case "${{ matrix.variant }}" in
client-preview) echo "REDIST_DIR=redist/redist-client" >> $GITHUB_ENV ;;
server-preview) echo "REDIST_DIR=redist/redist-server" >> $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 ;;
*) echo "REDIST_DIR=redist/redist-unknown" >> $GITHUB_ENV ;;
esac
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: master
- 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 .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
- name: Setup SteamCMD
uses: CyberAndrii/setup-steamcmd@v1
- name: Update game files
run: |
if [[ "${{ matrix.variant }}" == "client" || "${{ matrix.variant }}" == "server" ]]; 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 preview -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: Commit changes
if: success()
run: |
git config --global user.email "sunnamed434@users.noreply.github.com"
git config --global user.name "sunnamed434"
if git diff --quiet; then
echo "No changes detected for ${{ matrix.variant }}"
else
git add -A
git reset README.md # Reset README.md, cause steamcmd override it.
git status
git commit -m "${{ steps.generate_commit_message.outputs.message }}"
git push
fi
workflow-keepalive:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: liskin/gh-workflow-keepalive@v1