Skip to content

Commit 334b8dc

Browse files
committed
优化版本号的获取脚本
1 parent 072a48e commit 334b8dc

4 files changed

Lines changed: 92 additions & 80 deletions

File tree

.github/workflows/update-adguardhome.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Get `Go` latest version
2626
id: go
2727
run: |
28-
echo "version=$(curl -sSL https://raw.githubusercontent.com/actions/go-versions/update-versions-manifest-file/versions-manifest.json | jq -r '.[0].version')" >> ${GITHUB_OUTPUT}
28+
echo "version=$(curl -sSL https://raw.githubusercontent.com/actions/go-versions/update-versions-manifest-file/versions-manifest.json | jq -r '.[0].version')" >> "${GITHUB_OUTPUT}"
2929
3030
node:
3131
runs-on: ubuntu-latest
@@ -35,7 +35,7 @@ jobs:
3535
- name: Get `Node` latest version (LTS)
3636
id: node
3737
run: |
38-
echo "version=$(curl -sSL https://nodejs.org/dist/index.json | jq -r 'map(select(.lts)) | .[0].version[1:]')" >> ${GITHUB_OUTPUT}
38+
echo "version=$(curl -sSL https://nodejs.org/dist/index.json | jq -r 'map(select(.lts)) | .[0].version[1:]')" >> "${GITHUB_OUTPUT}"
3939
4040
release_version:
4141
runs-on: ubuntu-latest
@@ -48,11 +48,12 @@ jobs:
4848
id: version
4949
run: |
5050
while true; do
51-
release_version=$(curl -sSL https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest | jq -r '.tag_name')
52-
release_time=$(curl -sSL https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest | jq -r '.published_at // .created_at' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
51+
latest=$(curl -sSL https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest)
52+
release_version=$(echo "${latest}" | jq -r '.tag_name')
5353
if [[ -n "${release_version}" && "${release_version}" != "null" ]]; then
54-
echo "release_version=${release_version}" >> ${GITHUB_OUTPUT}
55-
echo "release_time=${release_time}" >> ${GITHUB_OUTPUT}
54+
release_time=$(echo "${latest}" | jq -r '.published_at // .created_at' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
55+
echo "release_version=${release_version}" >> "${GITHUB_OUTPUT}"
56+
echo "release_time=${release_time}" >> "${GITHUB_OUTPUT}"
5657
break
5758
fi
5859
echo "未成功获取到 AdGuard Home Release 版本号,将在 10 秒后重试..."
@@ -72,7 +73,7 @@ jobs:
7273
echo "当前 ${name} 版本较低,需要更新最新版本至 ${version}"
7374
skip_update=false
7475
fi
75-
echo "skip_update=$skip_update" >> ${GITHUB_OUTPUT}
76+
echo "skip_update=$skip_update" >> "${GITHUB_OUTPUT}"
7677
7778
release_cross:
7879
runs-on: ubuntu-latest
@@ -145,11 +146,12 @@ jobs:
145146
id: version
146147
run: |
147148
while true; do
148-
beta_version=$(curl -sSL https://api.github.com/repos/AdguardTeam/AdGuardHome/releases | jq -r '[.[] | select(.tag_name | contains("b"))][0].tag_name')
149-
beta_time=$(curl -sSL https://api.github.com/repos/AdguardTeam/AdGuardHome/releases | jq -r '[.[] | select(.tag_name | contains("b"))][0] | (.published_at // .created_at)' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
149+
releases=$(curl -sSL https://api.github.com/repos/AdguardTeam/AdGuardHome/releases)
150+
beta_version=$(echo "${releases}" | jq -r '[.[] | select(.tag_name | contains("b"))][0].tag_name')
150151
if [[ -n "${beta_version}" && "${beta_version}" != "null" ]]; then
151-
echo "beta_version=${beta_version}" >> ${GITHUB_OUTPUT}
152-
echo "beta_time=${beta_time}" >> ${GITHUB_OUTPUT}
152+
beta_time=$(echo "${releases}" | jq -r '[.[] | select(.tag_name | contains("b"))][0] | (.published_at // .created_at)' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
153+
echo "beta_version=${beta_version}" >> "${GITHUB_OUTPUT}"
154+
echo "beta_time=${beta_time}" >> "${GITHUB_OUTPUT}"
153155
break
154156
fi
155157
echo "未成功获取到 AdGuard Home Beta 版本号,将在 10 秒后重试..."
@@ -169,7 +171,7 @@ jobs:
169171
echo "当前 ${name} 版本较低,需要更新最新版本至 ${version}"
170172
skip_update=false
171173
fi
172-
echo "skip_update=$skip_update" >> ${GITHUB_OUTPUT}
174+
echo "skip_update=$skip_update" >> "${GITHUB_OUTPUT}"
173175
174176
beta_cross:
175177
runs-on: ubuntu-latest
@@ -302,10 +304,10 @@ jobs:
302304
run: |
303305
if ls ./AdGuardHome/* >/dev/null 2>&1; then
304306
echo "AdGuard Home 文件夹内存在新内核文件,需要上传"
305-
echo "adguardhome_exist=true" >> ${GITHUB_OUTPUT}
307+
echo "adguardhome_exist=true" >> "${GITHUB_OUTPUT}"
306308
else
307309
echo "AdGuard Home 文件夹内没有新内核文件,无需上传"
308-
echo "adguardhome_exist=false" >> ${GITHUB_OUTPUT}
310+
echo "adguardhome_exist=false" >> "${GITHUB_OUTPUT}"
309311
fi
310312
311313
- name: Release and upload `AdGuardHome` assets

.github/workflows/update-dashboard.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ jobs:
2727
run: |
2828
while true; do
2929
yacd_meta_version=$(curl -sSL https://api.github.com/repos/MetaCubeX/Yacd-meta/releases/latest | jq -r '.tag_name')
30-
yacd_meta_time=$(curl -sSL https://api.github.com/repos/MetaCubeX/Yacd-meta/commits/gh-pages | jq -r '.commit.committer.date' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
3130
metacubexd_version=$(curl -sSL https://api.github.com/repos/MetaCubeX/metacubexd/releases/latest | jq -r '.tag_name')
32-
metacubexd_time=$(curl -sSL https://api.github.com/repos/MetaCubeX/metacubexd/commits/gh-pages | jq -r '.commit.committer.date' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
3331
zashboard_version=$(curl -sSL https://api.github.com/repos/Zephyruso/zashboard/releases/latest | jq -r '.tag_name')
34-
zashboard_time=$(curl -sSL https://api.github.com/repos/Zephyruso/zashboard/commits/gh-pages-cdn-fonts | jq -r '.commit.committer.date' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
3532
singbox_dashboard_version=$(curl -sSL https://api.github.com/repos/SagerNet/sing-box-dashboard/commits/gh-pages | jq -r '.sha[:7]')
36-
singbox_dashboard_time=$(curl -sSL https://api.github.com/repos/SagerNet/sing-box-dashboard/commits/gh-pages | jq -r '.commit.committer.date' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
3733
if [[ -n "${yacd_meta_version}" && "${yacd_meta_version}" != "null" && -n "${metacubexd_version}" && "${metacubexd_version}" != "null" && -n "${zashboard_version}" && "${zashboard_version}" != "null" && -n "${singbox_dashboard_version}" && "${singbox_dashboard_version}" != "null" ]]; then
38-
echo "yacd_meta_version=${yacd_meta_version}" >> ${GITHUB_ENV}
39-
echo "yacd_meta_time=${yacd_meta_time}" >> ${GITHUB_ENV}
40-
echo "metacubexd_version=${metacubexd_version}" >> ${GITHUB_ENV}
41-
echo "metacubexd_time=${metacubexd_time}" >> ${GITHUB_ENV}
42-
echo "zashboard_version=${zashboard_version}" >> ${GITHUB_ENV}
43-
echo "zashboard_time=${zashboard_time}" >> ${GITHUB_ENV}
44-
echo "singbox_dashboard_version=${singbox_dashboard_version}" >> ${GITHUB_ENV}
45-
echo "singbox_dashboard_time=${singbox_dashboard_time}" >> ${GITHUB_ENV}
34+
yacd_meta_time=$(curl -sSL https://api.github.com/repos/MetaCubeX/Yacd-meta/commits/gh-pages | jq -r '.commit.committer.date' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
35+
echo "yacd_meta_version=${yacd_meta_version}" >> "${GITHUB_ENV}"
36+
echo "yacd_meta_time=${yacd_meta_time}" >> "${GITHUB_ENV}"
37+
metacubexd_time=$(curl -sSL https://api.github.com/repos/MetaCubeX/metacubexd/commits/gh-pages | jq -r '.commit.committer.date' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
38+
echo "metacubexd_version=${metacubexd_version}" >> "${GITHUB_ENV}"
39+
echo "metacubexd_time=${metacubexd_time}" >> "${GITHUB_ENV}"
40+
zashboard_time=$(curl -sSL https://api.github.com/repos/Zephyruso/zashboard/commits/gh-pages-cdn-fonts | jq -r '.commit.committer.date' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
41+
echo "zashboard_version=${zashboard_version}" >> "${GITHUB_ENV}"
42+
echo "zashboard_time=${zashboard_time}" >> "${GITHUB_ENV}"
43+
singbox_dashboard_time=$(curl -sSL https://api.github.com/repos/SagerNet/sing-box-dashboard/commits/gh-pages | jq -r '.commit.committer.date' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
44+
echo "singbox_dashboard_version=${singbox_dashboard_version}" >> "${GITHUB_ENV}"
45+
echo "singbox_dashboard_time=${singbox_dashboard_time}" >> "${GITHUB_ENV}"
4646
break
4747
fi
4848
echo "未获取到面板版本号,将在 10 秒后重试..."
@@ -70,7 +70,7 @@ jobs:
7070
eval "${var_name}=false"
7171
fi
7272
eval "value=\$${var_name}"
73-
echo "${var_name}=${value}" >> ${GITHUB_ENV}
73+
echo "${var_name}=${value}" >> "${GITHUB_ENV}"
7474
done
7575
7676
- name: Download and compress `Yacd-meta`
@@ -113,10 +113,10 @@ jobs:
113113
run: |
114114
if ls ./Dashboard/*.tar.gz >/dev/null 2>&1; then
115115
echo "Dashboard 文件夹内存在新面板文件,需要上传"
116-
echo "dashboard_exist=true" >> ${GITHUB_ENV}
116+
echo "dashboard_exist=true" >> "${GITHUB_ENV}"
117117
else
118118
echo "Dashboard 文件夹内没有新面板文件,无需上传"
119-
echo "dashboard_exist=false" >> ${GITHUB_ENV}
119+
echo "dashboard_exist=false" >> "${GITHUB_ENV}"
120120
fi
121121
122122
- name: Release and upload `Dashboard` assets

.github/workflows/update-mihomo.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Get `Go` latest version
2626
id: go
2727
run: |
28-
echo "version=$(curl -sSL https://raw.githubusercontent.com/actions/go-versions/update-versions-manifest-file/versions-manifest.json | jq -r '.[0].version')" >> ${GITHUB_OUTPUT}
28+
echo "version=$(curl -sSL https://raw.githubusercontent.com/actions/go-versions/update-versions-manifest-file/versions-manifest.json | jq -r '.[0].version')" >> "${GITHUB_OUTPUT}"
2929
3030
meta_version:
3131
runs-on: ubuntu-latest
@@ -40,19 +40,20 @@ jobs:
4040
id: version
4141
run: |
4242
while true; do
43-
meta_version=$(curl -sSL https://api.github.com/repos/MetaCubeX/mihomo/releases/latest | jq -r '.tag_name' | sed 's/^v//')
44-
meta_time=$(curl -sSL https://api.github.com/repos/MetaCubeX/mihomo/releases/latest | jq -r '.published_at // .created_at' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
43+
latest=$(curl -sSL https://api.github.com/repos/MetaCubeX/mihomo/releases/latest)
44+
meta_version=$(echo "${latest}" | jq -r '.tag_name' | sed 's/^v//')
4545
if [[ -n "${meta_version}" && "${meta_version}" != "null" ]]; then
46-
echo "meta_version=${meta_version}" >> ${GITHUB_OUTPUT}
47-
echo "meta_time=${meta_time}" >> ${GITHUB_OUTPUT}
46+
meta_time=$(echo "${latest}" | jq -r '.published_at // .created_at' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
47+
echo "meta_version=${meta_version}" >> "${GITHUB_OUTPUT}"
48+
echo "meta_time=${meta_time}" >> "${GITHUB_OUTPUT}"
4849
break
4950
fi
5051
echo "未成功获取到 mihomo Meta 版本号,将在 10 秒后重试..."
5152
sleep 10
5253
done
5354
54-
echo "meta_linux_tags=no_tailscale" >> ${GITHUB_OUTPUT}
55-
echo "meta_windows_tags=with_gvisor" >> ${GITHUB_OUTPUT}
55+
echo "meta_linux_tags=no_tailscale" >> "${GITHUB_OUTPUT}"
56+
echo "meta_windows_tags=with_gvisor" >> "${GITHUB_OUTPUT}"
5657
5758
- name: Compare `mihomo Meta` versions with current release
5859
id: compare
@@ -67,7 +68,7 @@ jobs:
6768
echo "当前 ${name} 版本较低,需要更新最新版本至 v${version}"
6869
skip_update=false
6970
fi
70-
echo "skip_update=$skip_update" >> ${GITHUB_OUTPUT}
71+
echo "skip_update=$skip_update" >> "${GITHUB_OUTPUT}"
7172
7273
meta_cross:
7374
runs-on: ubuntu-latest
@@ -150,19 +151,20 @@ jobs:
150151
id: version
151152
run: |
152153
while true; do
153-
alpha_version=$(curl -sSL https://api.github.com/repos/MetaCubeX/mihomo/releases | jq -r '[.[] | select(.tag_name=="Prerelease-Alpha")][0].assets[].name' | perl -ne '/(alpha\-)([^.]+)/ && print "$1$2\n"' | head -n 1)
154-
alpha_time=$(curl -sSL https://api.github.com/repos/MetaCubeX/mihomo/releases | jq -r '[.[] | select(.tag_name=="Prerelease-Alpha")][0] | (.updated_at // .created_at)' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
154+
releases=$(curl -sSL https://api.github.com/repos/MetaCubeX/mihomo/releases)
155+
alpha_version=$(echo "${releases}" | jq -r '[.[] | select(.tag_name=="Prerelease-Alpha")][0].assets[].name' | perl -ne '/(alpha\-)([^.]+)/ && print "$1$2\n"' | head -n 1)
155156
if [[ -n "${alpha_version}" && "${alpha_version}" != "null" ]]; then
156-
echo "alpha_version=${alpha_version}" >> ${GITHUB_OUTPUT}
157-
echo "alpha_time=${alpha_time}" >> ${GITHUB_OUTPUT}
157+
alpha_time=$(echo "${releases}" | jq -r '[.[] | select(.tag_name=="Prerelease-Alpha")][0] | (.updated_at // .created_at)' | xargs -I {} date -d '{} +8 hours' '+%Y-%m-%d')
158+
echo "alpha_version=${alpha_version}" >> "${GITHUB_OUTPUT}"
159+
echo "alpha_time=${alpha_time}" >> "${GITHUB_OUTPUT}"
158160
break
159161
fi
160162
echo "未成功获取到 mihomo Alpha 版本号,将在 10 秒后重试..."
161163
sleep 10
162164
done
163165
164-
echo "alpha_linux_tags=no_tailscale" >> ${GITHUB_OUTPUT}
165-
echo "alpha_windows_tags=with_gvisor" >> ${GITHUB_OUTPUT}
166+
echo "alpha_linux_tags=no_tailscale" >> "${GITHUB_OUTPUT}"
167+
echo "alpha_windows_tags=with_gvisor" >> "${GITHUB_OUTPUT}"
166168
167169
- name: Compare `mihomo Alpha` versions with current release
168170
id: compare
@@ -177,7 +179,7 @@ jobs:
177179
echo "当前 ${name} 版本较低,需要更新最新版本至 ${version}"
178180
skip_update=false
179181
fi
180-
echo "skip_update=$skip_update" >> ${GITHUB_OUTPUT}
182+
echo "skip_update=$skip_update" >> "${GITHUB_OUTPUT}"
181183
182184
alpha_cross:
183185
runs-on: ubuntu-latest
@@ -318,10 +320,10 @@ jobs:
318320
run: |
319321
if ls ./mihomo/* >/dev/null 2>&1; then
320322
echo "mihomo 文件夹内存在新内核文件,需要上传"
321-
echo "mihomo_exist=true" >> ${GITHUB_OUTPUT}
323+
echo "mihomo_exist=true" >> "${GITHUB_OUTPUT}"
322324
else
323325
echo "mihomo 文件夹内没有新内核文件,无需上传"
324-
echo "mihomo_exist=false" >> ${GITHUB_OUTPUT}
326+
echo "mihomo_exist=false" >> "${GITHUB_OUTPUT}"
325327
fi
326328
327329
- name: Release and upload `mihomo` assets

0 commit comments

Comments
 (0)