forked from j-hc/revanced-magisk-module
-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·92 lines (84 loc) · 3.43 KB
/
ci.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
name: CI
on:
workflow_dispatch:
schedule:
- cron: "0 16 * * *"
jobs:
check:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Should build?
id: should_build
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
source utils.sh
toml_prep "$(cat config.toml)"
is_youtube_latest() {
t=$(toml_get_table YouTube)
v=$(toml_get "$t" "version") || v=""
if isoneof "$v" latest beta; then
cur_yt=$(sed -n 's/.*YouTube: \(.*\)/\1/p' build.md | xargs)
[ -z "$cur_yt" ] && return 1 # empty, fail=>dont build
if [ "$v" = beta ]; then aav="true"; else aav="false"; fi
last_ver=$(get_apkmirror_vers youtube "$aav" | get_largest_ver)
[ -z "$last_ver" ] && return 1 # cant fetch, dont build
echo "current yt version: '$cur_yt'"
echo "latest yt version: '$last_ver'"
[ "$cur_yt" != "$last_ver" ] # test success=>build, fail=>dont build
else
return 1 # not experimental, dont build
fi
}
is_patches_latest() {
declare -A sources
sources["ReVanced/revanced-patches"]=1
for table_name in $(toml_get_table_names); do
if [ -z "$table_name" ]; then continue; fi
t=$(toml_get_table "$table_name")
enabled=$(toml_get "$t" enabled) || enabled=true
if [ "$enabled" = false ]; then continue; fi
PATCHES_SRC=$(toml_get "$t" patches-source)
if [ "$PATCHES_SRC" ]; then sources[$PATCHES_SRC]=1; fi
done
for PATCHES_SRC in "${!sources[@]}"; do
echo "chk: '$PATCHES_SRC'"
last_patches_url=$(gh_req "https://api.github.com/repos/${PATCHES_SRC}/releases/latest" - | json_get 'browser_download_url' | grep 'jar')
last_patches=${last_patches_url##*/}
cur_patches=$(sed -n "s/.*Patches: ${PATCHES_SRC%%/*}\/\(.*\)/\1/p" build.md | xargs)
echo "current patches version: $cur_patches"
echo "latest patches version: $last_patches"
if [ -z "$cur_patches" ] || [ -z "$last_patches" ]; then continue; fi
if [ "$cur_patches" != "$last_patches" ]; then return 0; fi
done
return 1
}
if ! git checkout update; then
echo "first time building!"
echo "SHOULD_BUILD=1" >> $GITHUB_OUTPUT
elif is_patches_latest || is_youtube_latest; then
echo "build!"
echo "SHOULD_BUILD=1" >> $GITHUB_OUTPUT
else
echo "dont build!"
echo "SHOULD_BUILD=0" >> $GITHUB_OUTPUT
fi
- name: Clear older runs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh run list -L400 --json databaseId -q '.[].databaseId' | tail -n+10 | xargs -IID gh api "repos/$(gh repo view --json nameWithOwner -q .nameWithOwner)/actions/runs/ID" -X DELETE || :
outputs:
SHOULD_BUILD: ${{ steps.should_build.outputs.SHOULD_BUILD }}
build:
permissions: write-all
needs: check
uses: ./.github/workflows/build.yml
if: ${{ needs.check.outputs.SHOULD_BUILD == 1 }}
secrets: inherit