forked from EmulatorJS/EmulatorJS
-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (101 loc) · 3.79 KB
/
Copy pathstable.yml
File metadata and controls
112 lines (101 loc) · 3.79 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
name: Update EmulatorJS CDN
on:
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
jobs:
run:
if: github.repository == 'EmulatorJS/EmulatorJS'
runs-on: emulatorjs-server
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Variables
run: |
cd /mnt/HDD/public/
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
wget -q "https://api.github.com/repos/EmulatorJS/EmulatorJS/releases?per_page=1" -O .tmp.json
# The releases endpoint returns an array, get the first item
version=$(jq -r '.[0].tag_name' .tmp.json)
download_url=$(jq -r '.[0].assets[0].browser_download_url' .tmp.json)
name=$(jq -r '.[0].assets[0].name' .tmp.json)
is_prerelease=true
else
wget -q "https://api.github.com/repos/EmulatorJS/EmulatorJS/releases/latest" -O .tmp.json
version=$(jq -r '.tag_name' .tmp.json)
download_url=$(jq -r '.assets[0].browser_download_url' .tmp.json)
name=$(jq -r '.assets[0].name' .tmp.json)
is_prerelease=false
fi
old_version=$(jq -r '.github' versions.json)
v_version="$version"
if [[ $version == v* ]]; then
version="${version:1}"
fi
rm .tmp.json
echo "VERSION=$version" >> $GITHUB_ENV
echo "DOWNLOAD_URL=$download_url" >> $GITHUB_ENV
echo "NAME=$name" >> $GITHUB_ENV
echo "OLD_VERSION=$old_version" >> $GITHUB_ENV
echo "V_VERSION=$v_version" >> $GITHUB_ENV
echo "IS_PRERELEASE=$is_prerelease" >> $GITHUB_ENV
- name: Download Release
run: |
cd /mnt/HDD/public/
mkdir -p ".new"
wget -q "$DOWNLOAD_URL" -O ".new/$NAME"
- name: Extract Release
run: |
cd /mnt/HDD/public/.new/
7z x "$NAME"
- name: Archive Release Asset
run: |
cd /mnt/HDD/public/
mv ".new/$NAME" releases/
- name: Promote Stable (stable releases only)
if: env.IS_PRERELEASE == 'false'
run: |
cd /mnt/HDD/public/
mv "$OLD_VERSION" "$VERSION"
mv stable "$OLD_VERSION"
mv .new stable
jq --arg version "$VERSION" '.github = $version' versions.json | sponge versions.json
- name: Place Prerelease Folder (prereleases only)
if: env.IS_PRERELEASE == 'true'
run: |
cd /mnt/HDD/public/
mv .new "$VERSION"
- name: Set Permissions
run: |
cd /mnt/HDD/public
if [[ "$IS_PRERELEASE" == "true" ]]; then
chmod -R 775 "$VERSION/"
else
chmod -R 775 stable/
fi
- name: Update Stable Cores
if: env.IS_PRERELEASE == 'false'
run: |
rsync -a --delete /mnt/HDD/public/stable/data/cores/ /mnt/HDD/public/.EmulatorJS/data/cores/
- name: Zip Stable
if: env.IS_PRERELEASE == 'false'
run: |
cd /mnt/HDD/public/stable/data/
rm -f emulator.min.zip
zip emulator.min.zip *.min.*
- name: Update Versions JSON
run: |
cd /mnt/HDD/public/
if [[ "$IS_PRERELEASE" == "true" ]]; then
jq --arg version "$VERSION" '.versions += {($version): ($version + "/")}' versions.json | sponge versions.json
else
jq --arg old_version "$OLD_VERSION" '.versions += {($old_version): ($old_version + "/")}' versions.json | sponge versions.json
fi
- name: Clean Up (stable releases only)
if: env.IS_PRERELEASE == 'false'
run: |
cd /mnt/HDD/public/
rm -f "$OLD_VERSION/data/emulator.min.zip"
rm -rf "$OLD_VERSION/node_modules/"