Skip to content

Scan V2Ray Version #1193

Scan V2Ray Version

Scan V2Ray Version #1193

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@v2
with:
token: ${{ secrets.PAT }}
- name: Get Latest Version
id: get_version
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const { data } = await github.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 "::set-output name=version::$latest_version"
echo "::set-output name=source_hash::$source_hash"
else
echo "::set-output name=version::"
echo "::set-output name=source_hash::"
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-actions[bot]"
git config user.email "41898282+github-actions[bot]@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"