Skip to content

Commit

Permalink
Fix check unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
Markson committed Aug 12, 2023
1 parent dacdae2 commit f9acaf9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 48 deletions.
72 changes: 36 additions & 36 deletions Formula/v2raya-unstable.rb
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
class V2rayaUnstable < Formula
desc "Web-based GUI client of Project V"
homepage "https://v2raya.org"
license "AGPL-3.0-only"
version ""
$v2raya_version = ""
$url_linux_x64 = "https://nightly.link/v2rayA/v2rayA/actions/runs/5839660426/v2raya_linux_x64_unstable-.zip"
$sha_linux_x64 = "1abe48fa2093c43daf177f7db213e1d07d71b90104e43fdf0b375c29d2ffd052"
$url_macos_x64 = "https://nightly.link/v2rayA/v2rayA/actions/runs/5839660426/v2raya_darwin_x64_unstable-.zip"
$sha_macos_x64 = "d096d51fc1e696cfff3b17520373a3c179da496368119df3f0768300844e4d88"
$url_macos_arm64 = "https://nightly.link/v2rayA/v2rayA/actions/runs/5839660426/v2raya_darwin_arm64_unstable-.zip"
$sha_macos_arm64 = "936dfbde9d1c4c37dea831ce5df0eb0a3bd051e689e68d84201682d807c4545f"
desc "Web-based GUI client of Project V"
homepage "https://v2raya.org"
license "AGPL-3.0-only"
version "20230808.r1356.a670323"

$v2raya_version = "20230808.r1356.a670323"
$url_linux_x64 = "https://nightly.link/v2rayA/v2rayA/actions/runs/5791674195/v2raya_linux_x64_unstable-20230808.r1356.a670323.zip"
$sha_linux_x64 = "4c470c3a53fa48844e4d5b00cbc2892aebf8cf2c67fa1aa3cf2760ee4f362021"
$url_macos_x64 = "https://nightly.link/v2rayA/v2rayA/actions/runs/5791674195/v2raya_darwin_x64_unstable-20230808.r1356.a670323.zip"
$sha_macos_x64 = "ca53305237587c2719ad8905dd7132d86afa0e53080589ec8ae4555117335a18"
$url_macos_arm64 = "https://nightly.link/v2rayA/v2rayA/actions/runs/5791674195/v2raya_darwin_arm64_unstable-20230808.r1356.a670323.zip"
$sha_macos_arm64 = "d87f74d69b19ae6974ba68a25f5aa448195497d1886fc79f4d0e1a9037c14ecc"

if OS.linux?
url $url_linux_x64
sha256 $sha_linux_x64
$os_type = "linux_x64"
elsif Hardware::CPU.intel?
url $url_macos_x64
sha256 $sha_macos_x64
$os_type = "darwin_x64"
else
url $url_macos_arm64
sha256 $sha_macos_arm64
$os_type = "darwin_arm64"
end
if OS.linux?
url $url_linux_x64
sha256 $sha_linux_x64
$os_type = "linux_x64"
elsif Hardware::CPU.intel?
url $url_macos_x64
sha256 $sha_macos_x64
$os_type = "darwin_x64"
else
url $url_macos_arm64
sha256 $sha_macos_arm64
$os_type = "darwin_arm64"
end

depends_on "v2ray"
depends_on "v2ray"

def install
bin.install "v2raya_#{$os_type}_unstable-#{version}" => "v2raya-unstable"
puts "v2raya-unstable installed, don't run both v2raya and v2raya-unstable service at the same time, or write launchd's plist file yourself to specify ports used by v2raya-unstable."
puts "If you forget your password, stop running v2raya-unstable, then run `v2raya-unstable --lite --reset-password` to reset password."
end
def install
bin.install "v2raya_#{$os_type}_unstable-#{version}" => "v2raya-unstable"
puts "v2raya-unstable installed, don't run both v2raya and v2raya-unstable service at the same time, or write launchd's plist file yourself to specify ports used by v2raya-unstable."
puts "If you forget your password, stop running v2raya-unstable, then run `v2raya-unstable --lite --reset-password` to reset password."
end

service do
environment_variables V2RAYA_LOG_FILE: "/tmp/v2raya-unstable.log", XDG_DATA_DIRS: "#{HOMEBREW_PREFIX}/share:", PATH: "/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:#{HOMEBREW_PREFIX}/bin:"
run [bin/"v2raya-unstable", "--lite"]
keep_alive true
end
service do
environment_variables V2RAYA_LOG_FILE: "/tmp/v2raya-unstable.log", XDG_DATA_DIRS: "#{HOMEBREW_PREFIX}/share:", PATH: "/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:#{HOMEBREW_PREFIX}/bin:"
run [bin/"v2raya-unstable", "--lite"]
keep_alive true
end
end
26 changes: 14 additions & 12 deletions updaters/v2raya-unstable.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
#!/bin/bash

set -e
set -x

sudo apt install -y jq
latest_action_id=$(curl -sL https://scoop-apps.vercel.app/v2rayA/v2rayA | grep 'data-url=' | grep 'summary_partial' | awk -F '"' '{print $2}' | awk -F '/' '{print $6}')
latest_linux_x64=$(curl -sL https://scoop-apps.vercel.app/v2rayA/v2rayA | grep v2raya_linux_x64 |awk 'NR==1' |awk '{print $1}')
latest_darwin_x64=$(curl -sL https://scoop-apps.vercel.app/v2rayA/v2rayA | grep v2raya_darwin_x64 |awk 'NR==1' |awk '{print $1}')
latest_darwin_arm64=$(curl -sL https://scoop-apps.vercel.app/v2rayA/v2rayA | grep v2raya_darwin_arm64 |awk 'NR==1' |awk '{print $1}')

latest_action_id=$(curl -s "https://api.github.com/repos/v2rayA/v2rayA/actions/workflows/release_feat_v5.yml/runs" | jq -r ".workflow_runs[0].jobs_url" | awk -F '/' '{printf $9}')
latest_version=$(curl -s "https://api.github.com/repos/v2rayA/v2rayA/actions/runs/$latest_action_id/artifacts" | jq -r ".artifacts[0].name" | awk -F '-' '{printf $2}')

url_linux_x64='https://nightly.link/v2rayA/v2rayA/actions/runs/'"$latest_action_id""/v2raya_linux_x64_unstable-$latest_version.zip"
url_darwin_x64='https://nightly.link/v2rayA/v2rayA/actions/runs/'"$latest_action_id""/v2raya_darwin_x64_unstable-$latest_version.zip"
url_darwin_arm64='https://nightly.link/v2rayA/v2rayA/actions/runs/'"$latest_action_id""/v2raya_darwin_arm64_unstable-$latest_version.zip"

url_linux_x64='https://nightly.link/v2rayA/v2rayA/actions/runs/'"$latest_action_id""/$latest_linux_x64.zip"
url_darwin_x64='https://nightly.link/v2rayA/v2rayA/actions/runs/'"$latest_action_id""/$latest_darwin_x64.zip"
url_darwin_arm64='https://nightly.link/v2rayA/v2rayA/actions/runs/'"$latest_action_id""/$latest_darwin_arm64.zip"
echo "$url_linux_x64"
echo "$url_darwin_x64"
echo "$url_darwin_arm64"

version=$(echo "$latest_darwin_x64" | cut -d'-' -f2)

current_url_linux_x64=$(cat ./Formula/v2raya-unstable.rb | grep 'url_linux_x64 =' | awk -F '"' '{print $2}')
current_url_darwin_x64=$(cat ./Formula/v2raya-unstable.rb | grep 'url_macos_x64 =' | awk -F '"' '{print $2}')
current_url_darwin_arm64=$(cat ./Formula/v2raya-unstable.rb | grep 'url_macos_arm64 =' | awk -F '"' '{print $2}')
current_version=$(cat ./Formula/v2raya-unstable.rb | grep 'v2raya_version =' | awk -F '"' '{print $2}')

if [ "$current_version" != "$latest_version" ]; then
if [ "$current_version" != "$version" ]; then
sed -i "s|$current_url_linux_x64|$url_linux_x64|g" ./Formula/v2raya-unstable.rb
curl -sL "$url_linux_x64" -o v2raya_linux_x64.zip; sha_linux_x64=$(sha256sum v2raya_linux_x64.zip | awk '{print $1}'); rm v2raya_linux_x64.zip
current_sha_linux_x64=$(cat ./Formula/v2raya-unstable.rb | grep 'sha_linux_x64 =' | awk -F '"' '{print $2}')
Expand All @@ -33,8 +35,8 @@ if [ "$current_version" != "$latest_version" ]; then
curl -sL "$url_darwin_arm64" -o v2raya_darwin_arm64.zip; sha_darwin_arm64=$(sha256sum v2raya_darwin_arm64.zip | awk '{print $1}'); rm v2raya_darwin_arm64.zip
current_sha_darwin_arm64=$(cat ./Formula/v2raya-unstable.rb | grep 'sha_macos_arm64 =' | awk -F '"' '{print $2}')
sed -i "s|$current_sha_darwin_arm64|$sha_darwin_arm64|g" ./Formula/v2raya-unstable.rb
sed -i "s|$current_version|$latest_version|g" ./Formula/v2raya-unstable.rb
git commit ./Formula/v2raya-unstable.rb -m "v2raya-unstable: update to $latest_version"
sed -i "s|$current_version|$version|g" ./Formula/v2raya-unstable.rb
git commit ./Formula/v2raya-unstable.rb -m "v2raya-unstable: update to $version"
else
echo "Nothing to do, you have the latest version of v2raya-unstable."
fi
fi

0 comments on commit f9acaf9

Please sign in to comment.