-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgithub-workflows-generate
executable file
·179 lines (133 loc) · 4.02 KB
/
github-workflows-generate
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
#!/bin/sh
set -e
if [ -d ndk-pkg-formula-repository-official-core ] ; then
git -C ndk-pkg-formula-repository-official-core pull
else
git clone --depth=1 https://github.com/leleliu008/ndk-pkg-formula-repository-official-core
fi
cd ndk-pkg-formula-repository-official-core/formula
unset PKGS
for f in *.yml
do
unset PKGNAME
unset PKGTYPE
unset BSYSTEM
unset DOBUILD
PKGTYPE="$(sed -n '/^pkgtype:/p' "$f" | cut -c10-)"
if [ -z "$PKGTYPE" ] ; then
PKGNAME="${f%.yml}"
case $PKGNAME in
lib*) continue ;;
*lib) continue ;;
*-dev) continue ;;
d8) continue ;;
calc) continue ;;
fortune) continue ;;
*)
BSYSTEM="$(sed -n '/^bsystem:/p' "$f" | cut -c10-)"
if [ -z "$BSYSTEM" ] ; then
DOBUILD="$(yq '.install | select(. != null)' "$f")"
if [ -n "$DOBUILD" ] ; then
for FirstWordOfLineInInstallActions in $(printf '%s\n' "$DOBUILD" | sed 's|^[[:space:]]*||' | cut -d ' ' -f1)
do
case "$FirstWordOfLineInInstallActions" in
go|gow) BSYSTEM=go ; break ;;
esac
done
fi
fi
if [ "$BSYSTEM" != go ] ; then
PKGTYPE=exe
fi
esac
fi
if [ "$PKGTYPE" = exe ] ; then
PKGS="$PKGS
$PKGNAME"
fi
done
list_size() {
printf '%s\n' "$#"
}
PKGS_COUNT="$(list_size $PKGS)"
echo "PKGS_COUNT=$PKGS_COUNT"
cd -
cat > .github/workflows/publish.yml <<EOF
name: publish
on:
workflow_dispatch
jobs:
EOF
unset ITEMS
unset NEEDS
I=0
J=0
K=0
for item in $PKGS
do
if [ -z "$ITEMS" ] ; then
ITEMS="$item"
else
ITEMS="$ITEMS, $item"
fi
K=$(($K + 1))
J=$(($J + 1))
echo "J=$J"
echo "K=$K"
if [ "$J" = 256 ] || [ "$K" = "$PKGS_COUNT" ] ; then
J=0
I=$(($I + 1))
cat >> .github/workflows/publish.yml <<EOF
build$I:
strategy:
fail-fast: false
matrix:
pkg: [$ITEMS]
runs-on: ubuntu-latest
container: ubuntu:24.04
steps:
- run: apt -y update
- run: apt -y install curl
- run: curl -LO https://raw.githubusercontent.com/leleliu008/ndk-pkg/master/ndk-pkg
- run: chmod a+x ndk-pkg
- run: ./ndk-pkg about
- run: ./ndk-pkg setup
- run: ./ndk-pkg update
- run: ./ndk-pkg install android-35-arm64-v8a/\${{ matrix.pkg }} --static
- run: ./ndk-pkg bundle android-35-arm64-v8a/\${{ matrix.pkg }} .tar.xz --exclude include/ --exclude lib/
- name: generate \${{ matrix.pkg }}.yml
run: |
set -ex
PACKAGE_SUMMARY="\$(./ndk-pkg info-installed android-35-arm64-v8a/\${{ matrix.pkg }} summary)"
PACKAGE_WEB_URL="\$(./ndk-pkg info-installed android-35-arm64-v8a/\${{ matrix.pkg }} web-url)"
PACKAGE_VERSION="\$(./ndk-pkg info-installed android-35-arm64-v8a/\${{ matrix.pkg }} version)"
PACKAGE_FILENAME="\$(ls *-android-aarch64.release.tar.xz)"
PACKAGE_BIN_SHA="\$(sha256sum "\$PACKAGE_FILENAME" | cut -d ' ' -f1)"
PACKAGE_BIN_URL="https://github.com/\${{ github.repository }}/releases/download/@TAGNAME@/\$PACKAGE_FILENAME"
cat > \${{ matrix.pkg }}.yml <<EOF
summary: \$PACKAGE_SUMMARY
webpage: \$PACKAGE_WEB_URL
version: \$PACKAGE_VERSION
bin-url: \$PACKAGE_BIN_URL
bin-sha: \$PACKAGE_BIN_SHA
EOF
- uses: actions/upload-artifact@v4
with:
name: \${{ matrix.pkg }}
path: |
./*.tar.xz
./*.yml
EOF
unset ITEMS
if [ -z "$NEEDS" ] ; then
NEEDS="build$I"
else
NEEDS="$NEEDS, build$I"
fi
fi
done
cat >> .github/workflows/publish.yml <<EOF
publish:
needs: [$NEEDS]
EOF
cat >> .github/workflows/publish.yml < foot