-
Notifications
You must be signed in to change notification settings - Fork 11
204 lines (184 loc) · 9.52 KB
/
shadowsocks-rust.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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
name: "shadowsocks-rust"
on:
repository_dispatch:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
schedule:
- cron: "0 */8 * * *"
env:
TZ: Asia/Shanghai
jobs:
job_init:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Initialization environment
run: |
sudo timedatectl set-timezone "$TZ"
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@main
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 1
keep_minimum_runs: 0
- name: SSH connection to Actions
uses: kenzok78/ssh-action@master
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
job_auto_update_packages:
if: ${{ always() }}
needs: job_init
runs-on: ubuntu-latest
name: update-${{ matrix.pakcages }}
strategy:
fail-fast: false
matrix:
pakcages: [shadowsocks-rust]
include:
- pakcages: shadowsocks-rust-aarch64
folder: shadowsocks-rust
version_head: PKG_VERSION:=
hash_head: \ PKG_HASH:=
version_line:
hash_line: 24
release_api_command: curl -sL "https://api.github.com/repos/shadowsocks/shadowsocks-rust/releases" | jq -r 'map(select(.prerelease|not)) | first | .tag_name' | sed -e 's/.*v//'
release_download_url: https://github.com/shadowsocks/shadowsocks-rust/releases/download/v
file_name: /shadowsocks-v$New_PKG_VERSION.aarch64-unknown-linux-musl.tar.xz
- pakcages: shadowsocks-rust-arm-musleabi
folder: shadowsocks-rust
version_head: PKG_VERSION:=
hash_head: \ PKG_HASH:=
version_line:
hash_line: 30
release_api_command: curl -sL "https://api.github.com/repos/shadowsocks/shadowsocks-rust/releases" | jq -r 'map(select(.prerelease|not)) | first | .tag_name' | sed -e 's/.*v//'
release_download_url: https://github.com/shadowsocks/shadowsocks-rust/releases/download/v
file_name: /shadowsocks-v$New_PKG_VERSION.arm-unknown-linux-musleabi.tar.xz
- pakcages: shadowsocks-rust-arm-musleabihf
folder: shadowsocks-rust
version_head: PKG_VERSION:=
hash_head: \ PKG_HASH:=
version_line:
hash_line: 33
release_api_command: curl -sL "https://api.github.com/repos/shadowsocks/shadowsocks-rust/releases" | jq -r 'map(select(.prerelease|not)) | first | .tag_name' | sed -e 's/.*v//'
release_download_url: https://github.com/shadowsocks/shadowsocks-rust/releases/download/v
file_name: /shadowsocks-v$New_PKG_VERSION.arm-unknown-linux-musleabihf.tar.xz
- pakcages: shadowsocks-rust-i686
folder: shadowsocks-rust
version_head: PKG_VERSION:=
hash_head: \ PKG_HASH:=
version_line:
hash_line: 37
release_api_command: curl -sL "https://api.github.com/repos/shadowsocks/shadowsocks-rust/releases" | jq -r 'map(select(.prerelease|not)) | first | .tag_name' | sed -e 's/.*v//'
release_download_url: https://github.com/shadowsocks/shadowsocks-rust/releases/download/v
file_name: /shadowsocks-v$New_PKG_VERSION.i686-unknown-linux-musl.tar.xz
- pakcages: shadowsocks-rust-x86_64
folder: shadowsocks-rust
version_head: PKG_VERSION:=
hash_head: \ PKG_HASH:=
version_line:
hash_line: 40
release_api_command: curl -sL "https://api.github.com/repos/shadowsocks/shadowsocks-rust/releases" | jq -r 'map(select(.prerelease|not)) | first | .tag_name' | sed -e 's/.*v//'
release_download_url: https://github.com/shadowsocks/shadowsocks-rust/releases/download/v
file_name: /shadowsocks-v$New_PKG_VERSION.x86_64-unknown-linux-musl.tar.xz
- pakcages: shadowsocks-rust-mips
folder: shadowsocks-rust
version_head: PKG_VERSION:=
hash_head: \ PKG_HASH:=
version_line:
hash_line: 43
release_api_command: curl -sL "https://api.github.com/repos/shadowsocks/shadowsocks-rust/releases" | jq -r 'map(select(.prerelease|not)) | first | .tag_name' | sed -e 's/.*v//'
release_download_url: https://github.com/sbwml/shadowsocks-rust-mips/releases/download/v
file_name: /shadowsocks-v$New_PKG_VERSION.mips-unknown-linux-musl.tar.xz
- pakcages: shadowsocks-rust-mipsel
folder: shadowsocks-rust
version_head: PKG_VERSION:=
hash_head: \ PKG_HASH:=
version_line:
hash_line: 46
release_api_command: curl -sL "https://api.github.com/repos/shadowsocks/shadowsocks-rust/releases" | jq -r 'map(select(.prerelease|not)) | first | .tag_name' | sed -e 's/.*v//'
release_download_url: https://github.com/sbwml/shadowsocks-rust-mips/releases/download/v
file_name: /shadowsocks-v$New_PKG_VERSION.mipsel-unknown-linux-musl.tar.xz
steps:
- name: Checkout
uses: actions/checkout@main
- name: Initialization environment
run: |
cd && mkdir -p pack && cd pack
sudo timedatectl set-timezone "$TZ"
- name: Check ${{ matrix.pakcages }}
id: check
run: |
is_continue=true
if [ "$is_continue" = "true" ]; then
cd && cd $GITHUB_WORKSPACE/${{ matrix.folder }}
if [ ! -n "${{ matrix.version_line }}" ] ; then
Old_PKG_VERSION=$(sed -n '/^${{ matrix.version_head }}/p' Makefile | awk -F '=' '{print $2}');
else
Old_PKG_VERSION=$(sed -n '${{ matrix.version_line }}p' Makefile | awk -F '=' '{print $2}');
fi
New_PKG_VERSION=$(${{ matrix.release_api_command }})
echo "${{ matrix.pakcages }}目前版本: $Old_PKG_VERSION"
echo "${{ matrix.pakcages }}最新版本: $New_PKG_VERSION"
if [ "$Old_PKG_VERSION" = "$New_PKG_VERSION" ]; then
echo "status=failure" >> $GITHUB_OUTPUT;
echo "${{ matrix.pakcages }}版本为最新版本$New_PKG_VERSION,无需更新";
else
echo "New_PKG_VERSION=$New_PKG_VERSION" >> $GITHUB_OUTPUT;
echo "status=success" >> $GITHUB_OUTPUT;
fi
else
echo "status=failure" >> $GITHUB_OUTPUT;
fi
- name: Update ${{ matrix.pakcages }}
id: update
if: steps.check.outputs.status == 'success' && steps.check.outputs.New_PKG_VERSION != '' && !cancelled()
run: |
cd && cd $GITHUB_WORKSPACE/${{ matrix.folder }}
New_PKG_VERSION=${{ steps.check.outputs.New_PKG_VERSION }}
if [ ! -n "${{ matrix.version_line }}" ] ; then
sed -i "/^${{ matrix.version_head }}/c\${{ matrix.version_head }}$New_PKG_VERSION" Makefile;
else
sed -i "${{ matrix.version_line }}c ${{ matrix.version_head }}$New_PKG_VERSION" Makefile;
fi
cd && cd pack && mkdir -p ${{ matrix.pakcages }} && cd ${{ matrix.pakcages }}
wget -P / ${{ matrix.release_download_url }}$New_PKG_VERSION${{ matrix.file_name }}
file_name=${{ matrix.file_name }}
is_v=$(echo ${{ matrix.release_download_url }} | awk -F/ '{print $NF}')
if [ ! -n "${{ matrix.file_name }}" ]; then PKG_HASH=$(sha256sum $is_v$New_PKG_VERSION) && PKG_HASH=${PKG_HASH%% *}; else PKG_HASH=$(sha256sum ${file_name##*/}) && PKG_HASH=${PKG_HASH%% *}; fi;
cd && cd $GITHUB_WORKSPACE/${{ matrix.folder }}
if [ ! -n "${{ matrix.hash_line }}" ] ; then
sed -i "/^${{ matrix.hash_head }}/c\${{ matrix.hash_head }}$PKG_HASH" Makefile;
else
sed -i "${{ matrix.hash_line }}c ${{ matrix.hash_head }}$PKG_HASH" Makefile;
fi
echo "已更新${{ matrix.pakcages }}版本到: $New_PKG_VERSION"
echo "${{ matrix.pakcages }} Hash:$PKG_HASH"
cd && cd pack
echo ":white_check_mark: ${{ matrix.pakcages }}: update to $New_PKG_VERSION" >> commit_messages.txt
echo "version=$New_PKG_VERSION" >> $GITHUB_OUTPUT
cd && cd $GITHUB_WORKSPACE
echo "branch_exists=$(git ls-remote --heads origin patches-${{ matrix.pakcages }}-$New_PKG_VERSION | tr -d '\n')" >> $GITHUB_OUTPUT
- name: Create Pull Request
id: cpr
if: steps.check.outputs.status == 'success' && steps.check.outputs.New_PKG_VERSION != '' && steps.update.outputs.branch_exists == '' && !cancelled()
uses: peter-evans/create-pull-request@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "${{ matrix.pakcages }}: update to ${{ steps.update.outputs.version }}"
committer: action <[email protected]>
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: patches-${{ matrix.pakcages }}-${{ steps.update.outputs.version }}
base: main
delete-branch: true
body: |
${{ matrix.pakcages }}: update to ${{ steps.update.outputs.version }}
title: "${{ matrix.pakcages }}: update to ${{ steps.update.outputs.version }}"
labels: |
automated-pr
draft: false