forked from nikkinikki-org/OpenWrt-nikki
-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (82 loc) · 3.72 KB
/
update_mihomo_version.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
name: Update Mihomo Version
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
get_current_info:
runs-on: ubuntu-latest
outputs:
pkg_source_version: ${{ steps.get_current_info.outputs.pkg_source_version }}
pkg_mirror_hash: ${{ steps.get_current_info.outputs.pkg_mirror_hash }}
pkg_build_version: ${{ steps.get_current_info.outputs.pkg_build_version }}
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v4
with:
repository: xianren78/OpenWrt-mihomo
ref: main
path: OpenWrt-nikki
- id: get_current_info
name: Get Current Info
run: |
echo "pkg_source_version=$(grep "PKG_SOURCE_VERSION:=" OpenWrt-nikki/nikki/Makefile | cut -d '=' -f 2)" >> $GITHUB_OUTPUT
echo "pkg_mirror_hash=$(grep "PKG_MIRROR_HASH:=" OpenWrt-nikki/nikki/Makefile | cut -d '=' -f 2)" >> $GITHUB_OUTPUT
echo "pkg_build_version=$(grep "PKG_BUILD_VERSION:=" OpenWrt-nikki/nikki/Makefile | cut -d '=' -f 2)" >> $GITHUB_OUTPUT
get_lastest_info:
runs-on: ubuntu-latest
outputs:
commit_date: ${{ steps.get_lastest_info.outputs.commit_date }}
commit_sha: ${{ steps.get_lastest_info.outputs.commit_sha }}
short_commit_sha: ${{ steps.get_lastest_info.outputs.short_commit_sha }}
checksum: ${{ steps.get_lastest_info.outputs.checksum }}
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v4
with:
repository: 'MetaCubeX/mihomo'
ref: 'Alpha'
path: 'mihomo'
- id: get_lastest_info
name: Get Latest Info
run: |
echo "commit_date=$(git -C mihomo log -n 1 --format=%cs)" >> $GITHUB_OUTPUT
echo "commit_sha=$(git -C mihomo rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "short_commit_sha=$(git -C mihomo rev-parse --short HEAD)" >> $GITHUB_OUTPUT
git -C mihomo config tar.xz.command "xz -c"
git -C mihomo archive --output=mihomo.tar.xz HEAD
echo "checksum=$(sha256sum mihomo/mihomo.tar.xz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
update:
needs:
- get_current_info
- get_lastest_info
if: ${{ needs.get_current_info.outputs.pkg_source_version != needs.get_lastest_info.outputs.commit_sha }}
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v4
with:
repository: xianren78/OpenWrt-mihomo
ref: main
path: OpenWrt-nikki
- id: update
name: Update
run: |
sed -i "s/PKG_RELEASE:=.*/PKG_RELEASE:=1/" OpenWrt-nikki/nikki/Makefile
sed -i "s/PKG_SOURCE_DATE:=.*/PKG_SOURCE_DATE:=${{ needs.get_lastest_info.outputs.commit_date }}/" OpenWrt-nikki/nikki/Makefile
sed -i "s/PKG_SOURCE_VERSION:=.*/PKG_SOURCE_VERSION:=${{ needs.get_lastest_info.outputs.commit_sha }}/" OpenWrt-nikki/nikki/Makefile
sed -i "s/PKG_MIRROR_HASH:=.*/PKG_MIRROR_HASH:=${{ needs.get_lastest_info.outputs.checksum }}/" OpenWrt-nikki/nikki/Makefile
sed -i "s/PKG_BUILD_VERSION:=.*/PKG_BUILD_VERSION:=alpha-${{ needs.get_lastest_info.outputs.short_commit_sha }}/" OpenWrt-nikki/nikki/Makefile
- id: pr
name: Pull Request
uses: peter-evans/create-pull-request@v6
with:
path: OpenWrt-nikki
branch: dependabot
commit-message: "build: update mihomo to ${{ needs.get_lastest_info.outputs.short_commit_sha }}"
title: "build: update mihomo to ${{ needs.get_lastest_info.outputs.short_commit_sha }}"
body: |
[Changelog](https://github.com/metacubex/mihomo/compare/${{ needs.get_current_info.outputs.pkg_source_version }}...${{ needs.get_lastest_info.outputs.commit_sha }})