Build #360
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
schedule: | |
- cron: "00 20 * * *" | |
workflow_dispatch: | |
env: | |
GH_TOKEN: ${{ github.token }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Git | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global advice.detachedHead false | |
- name: Transform proto to java | |
run: | | |
release_status="0" | |
release_version="$(date "+%Y%m%d%H%M%S")" | |
repo_version="$(curl -sL https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name')" | |
xray_version="$(curl -sL https://api.github.com/repos/XTLS/Xray-core/releases/latest | jq -r '.tag_name')" | |
if [ "$repo_version" = "null" ] || [ ! -f xray-version ] || [ "$xray_version" != "null" ] && [ "$xray_version" != "$(cat xray-version)" ]; then | |
echo "$xray_version" > xray-version | |
git add xray-version | |
git commit -m "Bump Xray-core to $xray_version" | |
release_status="1" | |
fi | |
v2ray_version="$(curl -sL https://api.github.com/repos/v2fly/v2ray-core/releases/latest | jq -r '.tag_name')" | |
if [ "$repo_version" = "null" ] || [ ! -f v2ray-version ] || [ "$v2ray_version" != "null" ] && [ "$v2ray_version" != "$(cat v2ray-version)" ]; then | |
echo "$v2ray_version" > v2ray-version | |
git add v2ray-version | |
git commit -m "Bump v2ray-core to $v2ray_version" | |
release_status="1" | |
fi | |
geosite_version="$(curl -sL https://api.github.com/repos/v2fly/domain-list-community/releases/latest | jq -r '.tag_name')" | |
if [ "$repo_version" = "null" ] || [ ! -f geosite-version ] || [ "$geosite_version" != "null" ] && [ "$geosite_version" != "$(cat geosite-version)" ]; then | |
echo "$geosite_version" > geosite-version | |
git add geosite-version | |
git commit -m "Bump geosite to $geosite_version" | |
release_status="1" | |
fi | |
geoip_version="$(curl -sL https://api.github.com/repos/v2fly/geoip/releases/latest | jq -r '.tag_name')" | |
if [ "$repo_version" = "null" ] || [ ! -f geoip-version ] || [ "$geoip_version" != "null" ] && [ "$geoip_version" != "$(cat geoip-version)" ]; then | |
echo "$geoip_version" > geoip-version | |
git add geoip-version | |
git commit -m "Bump geoip to $geoip_version" | |
release_status="1" | |
fi | |
if [ "$release_status" = "1" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
git push | |
mkdir "$release_version" | |
cd "$release_version" | |
curl -sL https://github.com/XTLS/Xray-core/archive/refs/tags/$xray_version.zip -o "Xray-source-$xray_version.zip" | |
curl -sLO https://github.com/XTLS/Xray-core/releases/latest/download/Xray-windows-64.zip | |
curl -sLO https://github.com/XTLS/Xray-core/releases/latest/download/Xray-windows-arm64-v8a.zip | |
curl -sLO https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-64.zip | |
curl -sLO https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-arm64-v8a.zip | |
curl -sLO https://github.com/XTLS/Xray-core/releases/latest/download/Xray-macos-64.zip | |
curl -sLO https://github.com/XTLS/Xray-core/releases/latest/download/Xray-macos-arm64-v8a.zip | |
curl -sL https://github.com/v2fly/v2ray-core/archive/refs/tags/$v2ray_version.zip -o "v2ray-source-$v2ray_version.zip" | |
curl -sLO https://github.com/v2fly/v2ray-core/releases/latest/download/v2ray-windows-64.zip | |
curl -sLO https://github.com/v2fly/v2ray-core/releases/latest/download/v2ray-windows-arm64-v8a.zip | |
curl -sLO https://github.com/v2fly/v2ray-core/releases/latest/download/v2ray-linux-64.zip | |
curl -sLO https://github.com/v2fly/v2ray-core/releases/latest/download/v2ray-linux-arm64-v8a.zip | |
curl -sLO https://github.com/v2fly/v2ray-core/releases/latest/download/v2ray-macos-64.zip | |
curl -sLO https://github.com/v2fly/v2ray-core/releases/latest/download/v2ray-macos-arm64-v8a.zip | |
cd .. | |
curl -sL https://github.com/protocolbuffers/protobuf/releases/download/v25.5/protoc-25.5-linux-x86_64.zip -o protobuf.zip | |
unzip -q protobuf.zip -d protobuf | |
sudo chmod +x protobuf/bin/protoc | |
curl -sL https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-java/1.69.0/protoc-gen-grpc-java-1.69.0-linux-x86_64.exe -o protobuf/bin/protoc-gen-grpc-java | |
sudo chmod +x protobuf/bin/protoc-gen-grpc-java | |
mkdir "$release_version/Xray-protobuf" | |
git clone -b "$xray_version" https://github.com/XTLS/Xray-core.git | |
find Xray-core -type f -name *.proto -exec protobuf/bin/protoc --plugin=protoc-gen-grpc-java=protobuf/bin/protoc-gen-grpc-java --proto_path=Xray-core --proto_path=protobuf/include --java_out="$release_version/Xray-protobuf" --grpc-java_out="$release_version/Xray-protobuf" {} \; | |
mkdir "$release_version/v2ray-protobuf" | |
git clone -b "$v2ray_version" https://github.com/v2fly/v2ray-core.git | |
find v2ray-core -type f -name *.proto -exec protobuf/bin/protoc --plugin=protoc-gen-grpc-java=protobuf/bin/protoc-gen-grpc-java --proto_path=v2ray-core --proto_path=protobuf/include --java_out="$release_version/v2ray-protobuf" --grpc-java_out="$release_version/v2ray-protobuf" {} \; | |
mkdir "$release_version/geo-assets" | |
curl -sL https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat -o "$release_version/geo-assets/geosite.dat" | |
curl -sL https://github.com/v2fly/geoip/releases/latest/download/geoip.dat -o "$release_version/geo-assets/geoip.dat" | |
if [[ "$(ls -A "$release_version/Xray-protobuf")" && "$(ls -A "$release_version/v2ray-protobuf")" && "$(ls -A "$release_version/geo-assets")" ]]; then | |
cd "$release_version" && zip -q -r "Xray-protobuf-$xray_version.zip" Xray-protobuf && cd .. | |
cd "$release_version" && zip -q -r "v2ray-protobuf-$v2ray_version.zip" v2ray-protobuf && cd .. | |
cd "$release_version" && zip -q -r geo-assets.zip geo-assets && cd .. | |
gh release create "$release_version" --generate-notes "$release_version"/*.zip | |
fi | |
fi |