forked from wukongdaily/RunFilesBuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (127 loc) · 5.63 KB
/
Copy pathmomo.yml
File metadata and controls
148 lines (127 loc) · 5.63 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
136
137
138
139
140
141
142
143
144
145
146
147
148
#=================================================
# https://github.com/wukongdaily/RunFilesBuilder
# Description: Build RunFiles using GitHub Actions
# Lisence: MIT
# Author: wukongdaily
# Blog: wkdaily.cpolar.cn
#=================================================
name: Make momo run files 24.10
on:
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v7.0.1
- name: Fetch latest release tag from momo
id: fetch_latest_tag
run: |
latest_tag=$(curl --fail --silent --show-error --location \
https://api.github.com/repos/nikkinikki-org/OpenWrt-momo/releases/latest \
| jq -er '.tag_name // empty')
test -n "$latest_tag"
echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV
- name: Clone makeself repository
run: git clone https://github.com/megastep/makeself.git
- name: Download latest momo files
run: |
release_json=$(curl --fail --silent --show-error --location \
https://api.github.com/repos/nikkinikki-org/OpenWrt-momo/releases/latest)
a53_url=$(echo "$release_json" | jq -er \
'.assets[] | select(.name == "momo_aarch64_cortex-a53-openwrt-24.10.tar.gz") | .browser_download_url')
x86_url=$(echo "$release_json" | jq -er \
'.assets[] | select(.name == "momo_x86_64-openwrt-24.10.tar.gz") | .browser_download_url')
curl --fail --location --retry 3 -O "$a53_url"
curl --fail --location --retry 3 -O "$x86_url"
tar --one-top-level=momo_aarch64_cortex-a53-openwrt-24.10 -xvzf momo_aarch64_cortex-a53-openwrt-24.10.tar.gz
tar --one-top-level=momo_x86_64-openwrt-24.10 -xvzf momo_x86_64-openwrt-24.10.tar.gz
- name: Organize files for aarch64_cortex-a53&x86_64
run: |
mkdir momo_x86_64 momo_aarch64_cortex-a53
cp momo_x86_64-openwrt-24.10/*.ipk momo_x86_64/
cp momo_aarch64_cortex-a53-openwrt-24.10/*.ipk momo_aarch64_cortex-a53/
# 保存当前路径并进入目标目录
pushd "momo_x86_64" >/dev/null || exit 1
for file in *~*.ipk; do
[ -e "$file" ] || continue
# 构造新文件名,去除 ~ 字符
new_file="$(echo "$file" | tr -d '~')"
# 如果目标文件名已存在,则提示并跳过
if [ -e "$new_file" ]; then
echo "目标文件已存在,跳过: $new_file"
continue
fi
# 重命名文件
mv "$file" "$new_file"
echo "已重命名: $file -> $new_file"
done
popd >/dev/null
pushd "momo_aarch64_cortex-a53" >/dev/null || exit 1
for file in *~*.ipk; do
[ -e "$file" ] || continue
# 构造新文件名,去除 ~ 字符
new_file="$(echo "$file" | tr -d '~')"
# 如果目标文件名已存在,则提示并跳过
if [ -e "$new_file" ]; then
echo "目标文件已存在,跳过: $new_file"
continue
fi
# 重命名文件
mv "$file" "$new_file"
echo "已重命名: $file -> $new_file"
done
popd >/dev/null
- name: Create install.sh scripts
run: |
cat <<EOF > momo_x86_64/install.sh
#!/bin/sh
opkg update
if [ $? -ne 0 ]; then
echo "update failed。"
exit 1
fi
opkg install *.ipk
EOF
chmod +x momo_x86_64/install.sh
cp momo_x86_64/install.sh momo_aarch64_cortex-a53/install.sh
- name: Move momo directories to makeself
run: |
mv momo_x86_64 makeself/
mv momo_aarch64_cortex-a53 makeself/
- name: Create self-extracting packages
run: |
cd makeself
./makeself.sh momo_x86_64/ momo_${{ env.LATEST_TAG }}_x86_64.run "by github action" ./install.sh
./makeself.sh momo_aarch64_cortex-a53/ momo_${{ env.LATEST_TAG }}_aarch64_cortex-a53.run "by github action" ./install.sh
- name: Check file sizes
run: |
ls -lh makeself/momo_*.run
- name: Fetch latest release details
id: fetch_release_details
run: |
extra_content=" [](https://wkdaily.cpolar.cn/archives/1) "
sed -i "1i$extra_content" "${{ github.workspace }}/momo.md"
- name: Print release notes
run: |
cat ${{ github.workspace }}/info.md
- name: Generate new tag & release
uses: softprops/action-gh-release@v3.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.LATEST_TAG }}
target_commitish: ${{ github.ref_name }}
prerelease: false
body_path: ${{ github.workspace }}/momo.md
- name: Upload run files as release assets
uses: softprops/action-gh-release@v3.0.2
with:
tag_name: ${{ env.LATEST_TAG }}
name: "momo-${{ env.LATEST_TAG }}"
files: makeself/momo_*.run
token: ${{ secrets.GITHUB_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}