forked from litetex/fdroid-pages
-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (152 loc) · 5.76 KB
/
update.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
name: Update
on:
schedule:
- cron: '40 0 * * *'
workflow_dispatch:
inputs:
force_update:
type: boolean
description: 'Force update/build'
default: false
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
permissions:
contents: write
jobs:
update:
runs-on: ubuntu-latest
outputs:
executed_update: ${{ steps.postprocess.outputs.executed_update }}
steps:
- uses: actions/checkout@v4
- name: Update
id: update
run: |
set -e
declare -a repo_infos=(
"org.maintainteam.lastpipebender;github;MaintainTeam/LastPipeBender"
"org.maintainteam.lastpipebender.extended;github;MaintainTeam/LastPipeBender"
"org.maintainteam.hypatia;github;MaintainTeam/Hypatia"
)
force_update="${{ inputs.force_update }}"
if [[ "$force_update" != "true" ]]; then
echo "Checking if updates are required..."
update_required=false
for repo_info in ${repo_infos[@]}; do
repo_info_parts=(${repo_info//;/ })
id=${repo_info_parts[0]}
provider=${repo_info_parts[1]}
repo=${repo_info_parts[2]}
echo "Checking if $id needs updating"
current_deployed_release=$(cat current-versions/$id.txt || echo "")
echo "Currently deployed version is '$current_deployed_release'"
latest_version=""
if [[ "$provider" == "github" ]]; then
latest_release_data=$(curl -L https://api.github.com/repos/$repo/releases/latest)
latest_version=$(echo "$latest_release_data" | jq -r '.name')
else
echo "Unknown provider"
exit 1
fi
echo "Latest version is '$latest_version'"
if [[ "$current_deployed_release" != "$latest_version" ]]; then
echo "Update required"
update_required=true
break
fi
done
if [[ "$update_required" != "true" ]]; then
echo "Everything is up-to-date; No update required"
exit 0
fi
fi
echo "Downloading APKs"
mkdir -p apks
for repo_info in ${repo_infos[@]}; do
repo_info_parts=(${repo_info//;/ })
id=${repo_info_parts[0]}
provider=${repo_info_parts[1]}
repo=${repo_info_parts[2]}
echo "Downloading APKs for $id"
latest_version=""
if [[ "$provider" == "github" ]]; then
curl -L https://api.github.com/repos/$repo/releases?per_page=3 \
| jq -r '.[].assets[].browser_download_url' \
| while read -r url; do wget -P apks --no-verbose $url; done
latest_release_data=$(curl -L https://api.github.com/repos/$repo/releases/latest)
latest_version=$(echo "$latest_release_data" | jq -r '.name')
else
echo "Unknown provider"
exit 1
fi
echo "Downloaded APKs. Saving latest version $latest_version"
mkdir -p current-versions
echo "$latest_version" > current-versions/$id.txt
done
echo "Deleting non-APK files"
(cd apks && find . -type f ! -name '*.apk' -delete)
echo "Done"
echo "do_update=true" >> "$GITHUB_ENV"
ls -lha apks
- name: Load KeyStore file
if: ${{ env.do_update == 'true' }}
run: echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d - > repo/keystore.p12
- uses: docker/setup-qemu-action@v3
if: ${{ env.do_update == 'true' }}
- uses: docker/setup-buildx-action@v3
if: ${{ env.do_update == 'true' }}
- name: Build F-Droid Repo Generator
if: ${{ env.do_update == 'true' }}
uses: docker/build-push-action@v6
with:
context: ./fdroid-repo-generator
load: true
tags: fdroid-repo-generator
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Write index.html
if: ${{ env.do_update == 'true' }}
run: |
mkdir -p deploy
cat <<EOF >> deploy/index.html
<html>
<head>
<meta http-equiv="refresh" content="0; url=fdroid/repo" />
</head>
<body>
<p><a href="fdroid/repo">Click here if redirect is not working</a></p>
</body>
</html>
EOF
- name: Run F-Droid Repo Generator
if: ${{ env.do_update == 'true' }}
run: |
docker run --rm \
-v $(pwd)/apks:/apks \
-v $(pwd)/deploy:/deploy \
-v $(pwd)/repo:/repobase \
-w /repo \
-e REPO_KEYALIAS="${{ secrets.REPO_KEYALIAS }}" \
-e KEYSTOREPASS="${{ secrets.KEYSTOREPASS }}" \
-e KEYPASS="${{ secrets.KEYPASS }}" \
-e KEYDNAME="${{ secrets.KEYDNAME }}" \
fdroid-repo-generator
- name: Deploy to Github pages
if: ${{ env.do_update == 'true' }}
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./deploy
force_orphan: true
- name: PostProcess
id: postprocess
if: ${{ env.do_update == 'true' }}
run: |
echo "Configuring git"
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
echo "Committing changed tracking files"
git add -A || true
git commit -m "Update versions" && git push || true
echo "executed_update=true" >> "$GITHUB_OUTPUT"