forked from j-hc/revanced-magisk-module
-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·79 lines (71 loc) · 2.89 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
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() {
PATCHES_SRC=$(toml_get "$(toml_get_table "")" patches-source) || PATCHES_SRC="ReVanced/revanced-patches"
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 return 1; fi
[ "$cur_patches" != "$last_patches" ] # test success=>build, fail=>dont build
}
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