-
Notifications
You must be signed in to change notification settings - Fork 79
135 lines (119 loc) · 3.81 KB
/
build.yaml
File metadata and controls
135 lines (119 loc) · 3.81 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Build
on:
push:
branches:
- main
paths-ignore:
- '**.md'
workflow_dispatch:
env:
MODULE_NAME: 'KPatch-Next-Module'
GH_TOKEN: ${{ github.token }}
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_vars.outputs.version }}
check_tag: ${{ steps.check_tag.outputs.need_release }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Load versions from version.properties
run: |
grep -v '^#' version.properties | sed -e 's/ *= */=/g' -e 's/"//g' >> $GITHUB_ENV
- name: download kpatch-next binaries
run: |
mkdir -p module/bin
TAG="${{ env['kpatch-next'] }}"
ARGS=("-R" "KernelSU-Next/KPatch-Next" "-p" "kpatch-android" "-p" "kptools-android" "-p" "kpimg-linux" "-D" "module/bin")
if [ "$TAG" != "latest" ]; then
gh release download "$TAG" "${ARGS[@]}"
else
gh release download "${ARGS[@]}"
fi
mv module/bin/kpatch-android module/bin/kpatch
mv module/bin/kptools-android module/bin/kptools
mv module/bin/kpimg-linux module/bin/kpimg
- name: Download magiskboot binary
run: |
TAG="${{ env.magiskboot }}"
ARGS=("-R" "topjohnwu/Magisk" "-p" "Magisk*.apk" "-O" "magisk.apk")
if [ "$TAG" != "latest" ]; then
gh release download "$TAG" "${ARGS[@]}"
else
gh release download "${ARGS[@]}"
fi
unzip -p magisk.apk 'lib/arm64-v8a/libmagiskboot.so' > module/bin/magiskboot
rm magisk.apk
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 'latest'
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 'latest'
cache: 'pnpm'
cache-dependency-path: webui/pnpm-lock.yaml
- name: build webroot
run: |
cd webui
pnpm install --frozen-lockfile
pnpm build
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: ${{ env.MODULE_NAME }}-${{ github.run_number }}
path: 'module'
- name: Check if valid to release
id: check_tag
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "need_release=false" >> $GITHUB_OUTPUT
else
git fetch --tags
VERSION="$(jq -r .version update.json)"
if [ -z "$VERSION" ]; then
echo "need_release=false" >> $GITHUB_OUTPUT
elif git tag | grep -qx "^${VERSION}"; then
echo "need_release=false" >> $GITHUB_OUTPUT
else
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "need_release=true" >> $GITHUB_OUTPUT
fi
fi
release:
runs-on: ubuntu-latest
needs: build
if: needs.release.outputs.check_tag == 'true'
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Download artifact
uses: actions/download-artifact@v7
with:
name: ${{ env.MODULE_NAME }}-${{ github.run_number }}
path: ${{ env.MODULE_NAME }}
- name: Zip for release
run: cd ${{ env.MODULE_NAME }} && zip -r ../${{ env.MODULE_NAME }}.zip .
- name: Generate changelog
run: |
CHANGELOG_RAW=$(git diff HEAD^ HEAD -- "CHANGELOG.md" | grep '^+[^+]' | sed 's/^+//')
{
echo "CHANGELOG<<EOF"
echo -e "${CHANGELOG_RAW}"
echo "EOF"
} >> $GITHUB_ENV
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.release.outputs.version }}
name: ${{ needs.release.outputs.version }}
body: ${{ env.CHANGELOG }}
files: ${{ env.MODULE_NAME }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}