forked from j-hc/revanced-magisk-module
-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (90 loc) · 4.58 KB
/
build.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
on: workflow_dispatch
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- id: prev_tag
run: |
TAG=$(git tag --sort=creatordate | tail -1)
if [ -z "$TAG" ]; then TAG=1; fi
echo ::set-output name=tag::$TAG
- id: next_ver_code
run: export TAG=${{ steps.prev_tag.outputs.tag }}; echo ::set-output name=NEXT_VER_CODE::$((TAG + 1))
- run: ./build.sh build
env:
GITHUB_REPOSITORY: $GITHUB_REPOSITORY
NEXT_VER_CODE: ${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}
- id: get_output
run: |
BUILD_LOG=$(cat build.log)
BUILD_LOG="${BUILD_LOG//'%'/'%25'}"
BUILD_LOG="${BUILD_LOG//$'\n'/'%0A'}"
BUILD_LOG="${BUILD_LOG//$'\r'/'%0D'}"
echo ::set-output name=BUILD_LOG::$BUILD_LOG
cd build
yt_op=$(find . -maxdepth 1 -name "yt-revanced-magisk-*.zip" -printf '%P')
echo ::set-output name=YT_OUTPUT::$yt_op
if [ -z "$yt_op" ]; then
echo ::set-output name=RELEASE_NAME::"revanced"
else
echo ::set-output name=RELEASE_NAME::$yt_op
fi
echo ::set-output name=MUSIC_OUTPUT_ARM64::$(find . -maxdepth 1 -name "music-revanced-magisk-*-arm64-v8a.zip" -printf '%P')
echo ::set-output name=MUSIC_OUTPUT_ARM::$(find . -maxdepth 1 -name "music-revanced-magisk-*-arm-v7a.zip" -printf '%P')
- name: Upload modules to release
uses: svenstaro/upload-release-action@v2
with:
body: ${{ steps.get_output.outputs.BUILD_LOG }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./build/*
release_name: ${{ steps.get_output.outputs.RELEASE_NAME }}
tag: ${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}
file_glob: true
overwrite: false
- name: Switch to update branch
run: git checkout -f update || git switch --discard-changes --orphan update
- name: Update changelog and Magisk update jsons
id: update_config
run: |
cp build.log latest_build.md
CHANGELOG_URL="https://raw.githubusercontent.com/$GITHUB_REPOSITORY/update/latest_build.md"
get_update_json() {
echo "{
\"version\": \"v$1\",
\"versionCode\": $2,
\"zipUrl\": \"$3\",
\"changelog\": \"$4\"
}"
}
if [ -n "${{ steps.get_output.outputs.YT_OUTPUT }}" ]; then
YT_VER=$(echo "${{ steps.get_output.outputs.BUILD_LOG }}" | sed -n 's/.*YouTube version: \(.*\)/\1/p')
YT_DLURL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/${{ steps.next_ver_code.outputs.NEXT_VER_CODE}}/${{ steps.get_output.outputs.YT_OUTPUT }}"
UPDATE_YT_JSON=$(get_update_json "$YT_VER" "${{ steps.next_ver_code.outputs.NEXT_VER_CODE}}" "$YT_DLURL" "$CHANGELOG_URL")
echo "$UPDATE_YT_JSON" >yt-update.json
fi
if [ -n "${{ steps.get_output.outputs.MUSIC_OUTPUT_ARM64 }}" ]; then
MUSIC_VER=$(echo "${{ steps.get_output.outputs.BUILD_LOG }}" | sed -n 's/.*Music (arm64-v8a) version: \(.*\)/\1/p')
MUSIC_ARM64_DLURL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/${{ steps.next_ver_code.outputs.NEXT_VER_CODE}}/${{ steps.get_output.outputs.MUSIC_OUTPUT_ARM64 }}"
UPDATE_MUSIC_ARM64_JSON=$(get_update_json "$MUSIC_VER" "${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}" "$MUSIC_ARM64_DLURL" "$CHANGELOG_URL")
echo "$UPDATE_MUSIC_ARM64_JSON" >music-update-arm64-v8a.json
fi
if [ -n "${{ steps.get_output.outputs.MUSIC_OUTPUT_ARM }}" ]; then
MUSIC_VER=$(echo "${{ steps.get_output.outputs.BUILD_LOG }}" | sed -n 's/.*Music (arm-v7a) version: \(.*\)/\1/p')
MUSIC_ARM_DLURL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/${{ steps.next_ver_code.outputs.NEXT_VER_CODE}}/${{ steps.get_output.outputs.MUSIC_OUTPUT_ARM }}"
UPDATE_MUSIC_ARM_JSON=$(get_update_json "$MUSIC_VER" "${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}" "$MUSIC_ARM_DLURL" "$CHANGELOG_URL")
echo "$UPDATE_MUSIC_ARM_JSON" >music-update-arm-v7a.json
fi
- uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: update
skip_checkout: true
file_pattern: latest_build.md *.json
commit_message: Bump ${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}