-
Notifications
You must be signed in to change notification settings - Fork 464
84 lines (68 loc) · 2.7 KB
/
version-scan.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: Scan V2Ray Version
on:
schedule:
- cron: "0 1 * * *" # every day at UTC 1:00AM
workflow_dispatch:
jobs:
check:
name: Check Version
runs-on: ubuntu-latest
if: ${{ github.repository_owner }} == "kuoruan"
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
- name: Get Latest Version
id: get_version
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const { data } = await github.rest.repos.getLatestRelease({
owner: 'v2fly',
repo: 'v2ray-core'
});
if (data && data.tag_name) {
return data.tag_name.replace(/^v/, "")
}
return "";
- name: Compare Version
id: compare_version
if: steps.get_version.outputs.result != ''
run: |
latest_version="${{ steps.get_version.outputs.result }}"
current_version="$(grep '^PKG_VERSION:' Makefile 2>/dev/null | cut -d'=' -f2)"
if [ -n "$current_version" ] && \
[ "$current_version" != "$latest_version" ] ; then
source_hash="$(curl -sL \
"https://codeload.github.com/v2fly/v2ray-core/tar.gz/v$latest_version" | \
sha256sum | cut -d' ' -f1)"
echo "version=$latest_version" >> $GITHUB_OUTPUT
echo "source_hash=$source_hash" >> $GITHUB_OUTPUT
else
echo "version=" >> $GITHUB_OUTPUT
echo "source_hash=" >> $GITHUB_OUTPUT
fi
- name: Commit New Version
if: steps.compare_version.outputs.version != '' && steps.compare_version.outputs.source_hash != ''
run: |
version="${{ steps.compare_version.outputs.version }}"
source_hash="${{ steps.compare_version.outputs.source_hash }}"
release_branch="releases/v${version}-1"
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
if [ "$(git ls-remote origin "$release_branch" | wc -l)" -gt "0" ] ; then
# delete existing release branch
git push origin :$release_branch 2>/dev/null || true
fi
git checkout -b "$release_branch"
sed -i \
-e "s/^PKG_VERSION.*/PKG_VERSION:=${version}/" \
-e "s/^PKG_RELEASE.*/PKG_RELEASE:=1/" \
-e "s/^PKG_HASH.*/PKG_HASH:=${source_hash}/" \
Makefile
git add -f Makefile
git commit -m "chore: bump to v${version}-1"
git push -u origin "$release_branch"