Skip to content

Scan V2Ray Version #1344

Scan V2Ray Version

Scan V2Ray Version #1344

Workflow file for this run

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"