forked from bottlesdevs/components
-
Notifications
You must be signed in to change notification settings - Fork 0
268 lines (243 loc) · 12.8 KB
/
pull-components.yml
File metadata and controls
268 lines (243 loc) · 12.8 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
name: CI
on:
schedule:
# Check for update every day at 07:11
- cron: '11 7 * * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
PR_BRANCH: ci/${{ github.ref_name }}
concurrency:
# Github Actions does not support ${{ env.PR_BRANCH }} as group name...
group: ci/${{ github.ref_name }}
cancel-in-progress: true
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: "bottle-components-repository"
ref: ${{ github.ref_name }}
- name: Create or reset ${{ env.PR_BRANCH }}
working-directory: "bottle-components-repository"
run: |
git checkout -B ${{ env.PR_BRANCH }}
git push -f --set-upstream origin ${{ env.PR_BRANCH }}
pull:
needs: prepare
strategy:
fail-fast: false
matrix:
components: [
{repo : "doitsujin/dxvk" , workflow: "artifacts.yml" , branch: "master", name-prefix: "dxvk-" , version-prefix: "v" , Category: "dxvk" , Sub-category: "" , yaml-file: "14-dxvk.yml" },
{repo : "HansKristian-Work/vkd3d-proton" , workflow: "artifacts.yml" , branch: "master", name-prefix: "vkd3d-proton-", version-prefix: "v" , Category: "vkd3d" , Sub-category: "" , yaml-file: "13-vkd3d-proton.yml" },
{repo : "bottlesdevs/wine" , workflow: "" , branch: "soda" , name-prefix: "soda-" , version-prefix: "soda-" , Category: "runners" , Sub-category: "wine" , yaml-file: "3-soda.yml" },
{repo : "bottlesdevs/wine" , workflow: "" , branch: "caffe" , name-prefix: "caffe-" , version-prefix: "caffe-" , Category: "runners" , Sub-category: "wine" , yaml-file: "4-caffe.yml" },
{repo : "GloriousEggroll/wine-ge-custom" , workflow: "" , branch: "master", name-prefix: "wine-" , version-prefix: "" , Category: "runners" , Sub-category: "wine" , yaml-file: "5-wine-GE-Proton.yml"},
{repo : "GloriousEggroll/proton-ge-custom", workflow: "" , branch: "master", name-prefix: "GE-Proton" , version-prefix: "GE-Proton", Category: "runners" , Sub-category: "proton", yaml-file: "10-GE-Proton.yml" },
{repo : "ishitatsuyuki/LatencyFleX" , workflow: "artifact.yml" , branch: "master", name-prefix: "latencyflex-" , version-prefix: "" , Category: "latencyflex", Sub-category: "" , yaml-file: "17-latencyflex.yml" },
{repo : "jp7677/dxvk-nvapi" , workflow: "artifacts.yml" , branch: "master", name-prefix: "dxvk-nvapi-" , version-prefix: "" , Category: "nvapi" , Sub-category: "" , yaml-file: "16-dxvk-nvapi.yml" },
{repo : "Sporif/dxvk-async" , workflow: "" , branch: "master", name-prefix: "dxvk-async-" , version-prefix: "" , Category: "dxvk" , Sub-category: "" , yaml-file: "15-dxvk-async.yml" },
]
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
type -p curl >/dev/null || sudo apt install curl -y
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt-get update
sudo apt-get install gh python3-pip zstd gawk
pip3 install yq
- name: Check for new release
id: check-release
shell: bash {0}
run: |
latest_release=$(gh release list -R ${{ matrix.components.repo }} | grep -m1 "${{ matrix.components.version-prefix }}" | awk '{print $(NF-1)}')
if [ -z "$latest_release" ]; then
echo "::error::Cannot find release tag begining by: ${{ matrix.components.version-prefix }}"
exit 1
fi
asset_name=" "
found=false
i=-1
until [ -z "$asset_name" ] || [ "$found" = true ]; do
i=$((i + 1))
asset_name=$(gh release view "$latest_release" --json assets -q ".[] | .[$i] | .name" -R ${{ matrix.components.repo }})
if [[ "$asset_name" =~ ${{ matrix.components.name-prefix }}.*[0-9]+\.tar.* ]]; then
found=true
fi
done
if [ "$found" = false ]; then
echo "::error::Cannot find asset name begining by: ${{ matrix.components.name-prefix }}"
exit 1
else
asset_json=$(gh release view "$latest_release" --json assets -q ".[] | .[$i]" -R ${{ matrix.components.repo }})
echo "asset=$asset_json" >> $GITHUB_OUTPUT
echo "version=${latest_release#${{ matrix.components.version-prefix }}}" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
with:
path: "bottle-components-repository"
ref: ${{ env.PR_BRANCH }}
- uses: actions/checkout@v3
with:
repository: bottlesdevs/tools
path: "tools"
- name: Define environment variables
run: |
lowercase_component_name=$(echo "${{ matrix.components.name-prefix }}${{ steps.check-release.outputs.version }}" | tr "[:upper:]" "[:lower:]")
echo "NAMEPREFIX=$(echo ${{ matrix.components.name-prefix }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
echo "NAME=$lowercase_component_name" >> $GITHUB_ENV
echo "CATEGORY=${{ matrix.components.Category }}" >> $GITHUB_ENV
echo "SUBCATEGORY=${{ matrix.components.Sub-category }}" >> $GITHUB_ENV
echo "CHANNEL=stable" >> $GITHUB_ENV
echo "YAML_FILENAME=${{ matrix.components.yaml-file }}" >> $GITHUB_ENV
echo "CREATED_AT=${{ fromJSON(steps.check-release.outputs.asset).createdAt }}" >> $GITHUB_ENV
echo "UPDATED=false" >> $GITHUB_ENV
- name: Update stable input_file entry
working-directory: "bottle-components-repository"
run: |
# This script can set env.UPDATED to true
./input_files/update_yml_entries.sh
- name: Create release tar archive
if: env.UPDATED == 'true'
working-directory: "bottle-components-repository"
run: |
release_archive_url=${{ fromJSON(steps.check-release.outputs.asset).url }}
release_archive_name=${{ fromJSON(steps.check-release.outputs.asset).name }}
if [[ $release_archive_name == *".tar.zst" ]]; then
curl -fsSLO "$release_archive_url"
tar --use-compress-program=unzstd -xvf $release_archive_name
tar -zcvf "${{ env.NAME }}.tar.gz" "${{ env.NAME }}"
echo "UPLOAD_FILE=$(pwd)/${{ env.NAME }}.tar.gz" >> $GITHUB_ENV
fi
- name: Check for new artifact
id: download-artifact
if: matrix.components.workflow != '' && env.UPDATED != 'true'
uses: dawidd6/action-download-artifact@master
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: ${{ matrix.components.workflow }}
branch: ${{ matrix.components.branch }}
repo: ${{ matrix.components.repo }}
check_artifacts: true
if_no_artifact_found: warn
path: artifact
- name: Update environment variables
if: env.UPDATED != 'true' && steps.download-artifact.outputs.found_artifact == 'true'
run: |
commit_sha1="${{ fromJSON(steps.download-artifact.outputs.artifacts)[0].workflow_run.head_sha }}"
lowercase_component_name=$(echo "${{ matrix.components.name-prefix }}${{ steps.check-release.outputs.version }}-1-${commit_sha1::7}" | tr "[:upper:]" "[:lower:]")
echo "NAME=$lowercase_component_name" >> $GITHUB_ENV
echo "CHANNEL=unstable" >> $GITHUB_ENV
echo "CREATED_AT=${{ fromJSON(steps.download-artifact.outputs.artifacts)[0].created_at }}" >> $GITHUB_ENV
- name: Update unstable input_file entry
if: env.UPDATED != 'true' && steps.download-artifact.outputs.found_artifact == 'true'
working-directory: "bottle-components-repository"
run: |
# This script can set env.UPDATED to true
./input_files/update_yml_entries.sh
- name: Create artifact tar archive
if: env.UPDATED == 'true' && steps.download-artifact.outputs.found_artifact == 'true'
working-directory: "bottle-components-repository"
run: |
folder=$(find "${{ github.workspace }}/artifact" -name "${{ env.NAMEPREFIX }}*")
# Components specific tweaks
if [[ "${{ env.NAMEPREFIX }}" == "dxvk"* ]]; then
rm -rf "$folder/usr"
fi
tar -C "$folder" -zcvf "${{ env.NAME }}.tar.gz" .
echo "UPLOAD_FILE=$(pwd)/${{ env.NAME }}.tar.gz" >> $GITHUB_ENV
- name: Upload component archive
id: upload-component
uses: softprops/action-gh-release@v1
if: env.UPLOAD_FILE != ''
with:
tag_name: "${{ env.NAME }}"
files: |
${{ env.UPLOAD_FILE }}
- name : Generate appropriate YAML file
if: env.UPDATED == 'true'
working-directory: "bottle-components-repository"
run: |
repo=${{ matrix.components.repo }}
if [ "${{ env.UPLOAD_FILE }}" != "" ]; then
url="${{ steps.upload-component.outputs.assets && fromJSON(steps.upload-component.outputs.assets)[0].browser_download_url }}"
path="${{ env.UPLOAD_FILE }}"
else
url="${{ fromJSON(steps.check-release.outputs.asset).url }}"
fi
python "${{ github.workspace }}/tools/MaintainersHelpers/component-generator.py" "components" "${repo%/*}" "${{ env.NAME }}" "${repo%/*}" "${{ env.CHANNEL }}" "$url" $path
# Components specific tweaks
if [[ "${{ env.NAME }}" == "wine-ge"* ]]; then
echo "Post:" >> "${{ env.NAME }}.yml"
echo -e "- action: rename" >> "${{ env.NAME }}.yml"
echo -e " source: lutris-${{ steps.check-release.outputs.version }}" >> "${{ env.NAME }}.yml"
echo -e " dest: ${{ env.NAME }}" >> "${{ env.NAME }}.yml"
fi
mv "${{ env.NAME }}.yml" "${{ env.CATEGORY }}/${{ env.SUBCATEGORY }}"
- name : Commit changes
if: env.UPDATED == 'true'
working-directory: "bottle-components-repository"
timeout-minutes: 10
shell: bash {0}
run: |
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add "${{ env.CATEGORY }}/${{ env.SUBCATEGORY }}/*.yml" "input_files/${{ env.YAML_FILENAME }}"
git pull
git commit -m "Update ${{ env.YAML_FILENAME }}"
git push
success=$?
until [ $success -eq 0 ]; do
git pull --rebase;
git push
success=$?
done
finish:
needs: pull
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: "bottle-components-repository"
ref: ${{ env.PR_BRANCH }}
fetch-depth: 0
- name: Generate index.yml
working-directory: "bottle-components-repository"
run: |
git checkout ${{ github.ref_name }}
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git merge ${{ env.PR_BRANCH }}
./generate_index.sh
git add index.yml
git commit -m "Generate index.yml" || true
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v4
with:
path: "bottle-components-repository"
branch: pr/${{ env.PR_BRANCH }}
delete-branch: true
title: "Update available :tada:"
body: One or more components have been updated!
# PAT is not necessary unless auto-merge is used
# token: ${{secrets.PAT}}
token: ${{secrets.GITHUB_TOKEN}}
- name: Enable Pull Request Automerge
if: false && steps.cpr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v2
with:
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
merge-method: squash
token: ${{secrets.GITHUB_TOKEN}}
- uses: hmarr/auto-approve-action@v3
if: false && steps.cpr.outputs.pull-request-operation == 'created'
with:
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}