forked from obsproject/obs-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
216 lines (191 loc) · 8.72 KB
/
steam.yml
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
name: Steam Upload
on:
release:
types:
- published
workflow_dispatch:
inputs:
tag:
description: 'Tag to fetch and upload (nightly if none)'
required: false
win_url_override:
description: 'Windows build to use (.zip only)'
required: false
mac_url_override:
description: 'Mac build to use (.dmg only)'
required: false
schedule:
- cron: 0 0 * * *
env:
WORKFLOW_ID: 583765
GIT_NIGHTLY_BRANCH: master
STEAM_NIGHTLY_BRANCH: nightly
STEAM_STABLE_BRANCH: staging
STEAM_BETA_BRANCH: beta_staging
jobs:
upload:
name: Steam upload
runs-on: ubuntu-20.04
if: github.repository_owner == 'obsproject'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: source
- name: Setup 7-Zip (PPA)
# The 7-Zip version available in the default ubuntu repos (p7zip) is wildly out-of-date and does not properly support DMG files.
run: |
sudo add-apt-repository -y ppa:spvkgn/sevenzip
sudo apt update -y
sudo apt install -y 7-zip
- name: Get build information
id: build-info
run: |
EVENT='${{ github.event_name }}'
if [[ ${EVENT} == 'release' || ( ${EVENT} == 'workflow_dispatch' && -n '${{ github.event.inputs.tag }}') ]]; then
if [[ ${EVENT} == "release" ]]; then
DESC='${{ github.event.release.tag_name }}'
if [[ '${{ github.event.release.prerelease }}' == 'true' ]]; then
BRANCH='${{ env.STEAM_BETA_BRANCH }}'
else
BRANCH='${{ env.STEAM_STABLE_BRANCH }}'
fi
ASSETS_URL='${{ github.event.release.assets_url }}'
else
RELEASE="$(curl -s '${{ github.api_url }}/repos/obsproject/obs-studio/releases/tags/${{ github.event.inputs.tag }}')"
DESC="$(jq -r '.tag_name' <<< ${RELEASE})"
if [[ "$(jq -r '.prerelease' <<< ${RELEASE})" == 'true' ]]; then
BRANCH='${{ env.STEAM_BETA_BRANCH }}'
else
BRANCH='${{ env.STEAM_STABLE_BRANCH }}'
fi
ASSETS_URL="$(jq -r '.assets_url' <<< ${RELEASE})"
fi
ASSETS="$(curl -s "${ASSETS_URL}")"
WIN_ASSET_URL="$(jq -r '.[] | select(.name|test(".*x64.zip")) .browser_download_url' <<< ${ASSETS})"
MAC_ASSET_URL="$(jq -r '.[] | select(.name|test(".*.dmg")) .browser_download_url' <<< ${ASSETS})"
TYPE='release'
else
BRANCH='${{ env.STEAM_NIGHTLY_BRANCH }}'
BUILDS="$(curl -s '${{ github.api_url }}/repos/obsproject/obs-studio/actions/workflows/${{ env.WORKFLOW_ID }}/runs?per_page=1&event=push&status=success&branch=${{ env.GIT_NIGHTLY_BRANCH }}')"
ARTIFACTS_URL="$(jq -r '.workflow_runs[].artifacts_url' <<< ${BUILDS})"
DESC="g$(jq -r '.workflow_runs[].head_sha' <<< "${BUILDS}" | cut -c1-9)"
ARTIFACTS="$(curl -s ${ARTIFACTS_URL})"
WIN_ASSET_URL="$(jq -r '.artifacts[] | select(.name|test(".*win-x64.*")) .archive_download_url' <<< ${ARTIFACTS})"
MAC_ASSET_URL="$(jq -r '.artifacts[] | select(.name|test(".*macos-x86_64.*")) .archive_download_url' <<< ${ARTIFACTS})"
TYPE='nightly'
fi
# Apply overrides from workflow_dispatch
if [[ ${EVENT} == 'workflow_dispatch' ]]; then
if [[ -n '${{ github.event.inputs.win_url_override }}' ]]; then
WIN_ASSET_URL='${{ github.event.inputs.win_url_override }}'
fi
if [[ -n '${{ github.event.inputs.mac_url_override }}' ]]; then
MAC_ASSET_URL='${{ github.event.inputs.mac_url_override }}'
fi
fi
if [[ -z ${WIN_ASSET_URL} || -z ${MAC_ASSET_URL} ]]; then
echo "Missing at least one asset URL!"
exit 1
fi
# set env variables for subsequent steps
echo "::set-output name=type::${TYPE}"
echo "::set-output name=branch::${BRANCH}"
echo "::set-output name=desc::${DESC}"
echo "::set-output name=win_url::${WIN_ASSET_URL}"
echo "::set-output name=mac_intel_url::${MAC_ASSET_URL}"
- name: Restore build cache
id: cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/steam/build
key: ${{ steps.build-info.outputs.branch }}-${{ steps.build-info.outputs.desc }}
# Using "restore-keys" will restore the most recent cache for the branch, even if the exact cache doesn't exist.
# This doesn't set cache-hit to true so it won't skip the upload for nightlies.
restore-keys: ${{ steps.build-info.outputs.branch }}
- name: Determine if Steam upload should run
# If the nightly build has already been uploaded and thus a cache exists skip this and the following steps.
# Steam does not prevent us from uploading duplicate builds so this would just pollute the dashboard.
# This is a bit of a hack and can fail to work if our cache has been evicted or we somehow have no commits for 7 days,
# but it's better than nothing!
id: should-run
run: |
if [[ '${{ steps.build-info.outputs.type }}' == 'release' || '${{ steps.cache.outputs.cache-hit }}' != 'true' ]]; then
echo "::set-output name=result::true"
else
echo "::set-output name=result::false"
fi
- name: Download and prepare builds
if: steps.should-run.outputs.result == 'true'
run: |
echo "::group::Download Windows build"
if [[ '${{ steps.build-info.outputs.win_url }}' == *'api.github.com'* ]]; then
curl -L -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' '${{ steps.build-info.outputs.win_url }}' -o windows.zip
else
curl -L '${{ steps.build-info.outputs.win_url }}' -o windows.zip
fi
echo "::endgroup::"
echo "::group::Download Mac build"
if [[ '${{ steps.build-info.outputs.mac_intel_url }}' == *'api.github.com'* ]]; then
curl -L -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' '${{ steps.build-info.outputs.mac_intel_url }}' -o mac_x86.dmg.zip
else
curl -L '${{ steps.build-info.outputs.mac_intel_url }}' -o mac_x86.dmg
fi
echo "::endgroup::"
mkdir -p steam && cd steam
echo "::group::Extract and prepare Win64"
mkdir steam-windows
(
cd steam-windows
unzip ../../windows.zip
# CI builds can be double-zipped
if compgen -G "*.zip" > /dev/null; then
unzip *.zip
rm *.zip
fi
# copy install scripts and create sentinel file
cp -r ../../source/CI/steam/scripts scripts
touch disable_updater
)
echo "::endgroup::"
echo "::group::Extract macOS (x86)"
mkdir steam-macos
# CI builds are zipped
if [[ -f ../mac_x86.dmg.zip ]]; then
unzip ../mac_x86.dmg.zip
# 7-Zip will have an exit code of 2 due to the "unsafe" 'Applications' symlink.
# GitHub treats this as a failure so ignore non-zero exit codes here.
7zz x *.dmg -otmp || true
else
7zz x ../mac_x86.dmg -otmp || true
fi
mv tmp/*/OBS.app steam-macos
echo "::endgroup::"
- name: Setup steamcmd
if: steps.should-run.outputs.result == 'true'
uses: CyberAndrii/setup-steamcmd@e19cd1516315ce46dbfffa47193f92fe42d1419e
- name: Generate Steam auth code
if: steps.should-run.outputs.result == 'true'
id: steam-totp
uses: CyberAndrii/steam-totp@0fc9e59dc5bbf4368d23d5a33956f104248da31a
with:
shared_secret: ${{ secrets.STEAM_SHARED_SECRET }}
- name: Upload to Steam
if: steps.should-run.outputs.result == 'true'
run: |
cd steam
echo "::group::Prepare Steam build script"
# The description in Steamworks for the build will be "github_<branch>-<tag/short hash>", e.g. "github_nightly-gaa73de952"
sed 's/@@DESC@@/${{ steps.build-info.outputs.branch }}-${{ steps.build-info.outputs.desc }}/;s/@@BRANCH@@/${{ steps.build-info.outputs.branch }}/' ../source/CI/steam/obs_build.vdf > build.vdf
echo "Generated file:"
cat build.vdf
echo "::endgroup::"
echo "::group::Upload to Steam"
steamcmd +login '${{ secrets.STEAM_USER }}' '${{ secrets.STEAM_PASSWORD }}' '${{ steps.steam-totp.outputs.code }}' +run_app_build "$(pwd)/build.vdf" +quit
echo "::endgroup::"
- name: Upload Steam build logs
if: steps.should-run.outputs.result == 'true'
uses: actions/upload-artifact@v3
with:
name: steam-build-logs
path: ${{ github.workspace }}/steam/build/*.log