mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-06 21:24:10 +00:00
ci: optimize release workflow
This commit is contained in:
parent
78767c082e
commit
67e0fb62b4
1 changed files with 77 additions and 54 deletions
131
.github/workflows/release.yml
vendored
131
.github/workflows/release.yml
vendored
|
|
@ -4,7 +4,7 @@ on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*.*.*"
|
- "v*.*"
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- '**.js'
|
- '**.js'
|
||||||
|
|
@ -18,6 +18,10 @@ on:
|
||||||
- 'x-ui.service.arch'
|
- 'x-ui.service.arch'
|
||||||
- 'x-ui.service.rhel'
|
- 'x-ui.service.rhel'
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
analyze:
|
analyze:
|
||||||
name: Analyze Go code
|
name: Analyze Go code
|
||||||
|
|
@ -57,6 +61,7 @@ jobs:
|
||||||
run: go test -race -shuffle=on ./...
|
run: go test -race -shuffle=on ./...
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
timeout-minutes: 30
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
strategy:
|
strategy:
|
||||||
|
|
@ -86,6 +91,21 @@ jobs:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
check-latest: true
|
check-latest: true
|
||||||
|
|
||||||
|
- name: Get latest Xray version
|
||||||
|
id: xray_version
|
||||||
|
run: |
|
||||||
|
LATEST=$(curl -fsSL https://api.github.com/repos/XTLS/Xray-core/releases/latest | jq -r '.tag_name')
|
||||||
|
echo "version=$LATEST" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Latest Xray version: $LATEST"
|
||||||
|
|
||||||
|
- name: Cache Bootlin toolchain
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: /tmp/toolchain
|
||||||
|
key: bootlin-${{ matrix.platform }}-${{ hashFiles('.github/workflows/release.yml') }}
|
||||||
|
restore-keys: |
|
||||||
|
bootlin-${{ matrix.platform }}-
|
||||||
|
|
||||||
- name: Build 3X-UI
|
- name: Build 3X-UI
|
||||||
run: |
|
run: |
|
||||||
export CGO_ENABLED=1
|
export CGO_ENABLED=1
|
||||||
|
|
@ -101,19 +121,28 @@ jobs:
|
||||||
386) BOOTLIN_ARCH="x86-i686" ;;
|
386) BOOTLIN_ARCH="x86-i686" ;;
|
||||||
s390x) BOOTLIN_ARCH="s390x-z13" ;;
|
s390x) BOOTLIN_ARCH="s390x-z13" ;;
|
||||||
esac
|
esac
|
||||||
echo "Resolving Bootlin musl toolchain for arch=$BOOTLIN_ARCH (platform=${{ matrix.platform }})"
|
|
||||||
TARBALL_BASE="https://toolchains.bootlin.com/downloads/releases/toolchains/$BOOTLIN_ARCH/tarballs/"
|
TOOLCHAIN_DIR=$(find /tmp/toolchain -maxdepth 1 -type d -name "${BOOTLIN_ARCH}--musl--stable-*" 2>/dev/null | head -n1)
|
||||||
TARBALL_URL=$(curl -fsSL "$TARBALL_BASE" | grep -oE "${BOOTLIN_ARCH}--musl--stable-[^\"]+\\.tar\\.xz" | sort -r | head -n1)
|
|
||||||
[ -z "$TARBALL_URL" ] && { echo "Failed to locate Bootlin musl toolchain for arch=$BOOTLIN_ARCH" >&2; exit 1; }
|
if [ -z "$TOOLCHAIN_DIR" ]; then
|
||||||
echo "Downloading: $TARBALL_URL"
|
echo "Cache miss, downloading toolchain..."
|
||||||
cd /tmp
|
mkdir -p /tmp/toolchain
|
||||||
curl -fL -sS -o "$(basename "$TARBALL_URL")" "$TARBALL_BASE/$TARBALL_URL"
|
TARBALL_BASE="https://toolchains.bootlin.com/downloads/releases/toolchains/$BOOTLIN_ARCH/tarballs/"
|
||||||
tar -xf "$(basename "$TARBALL_URL")"
|
TARBALL_URL=$(curl -fsSL "$TARBALL_BASE" | grep -oE "${BOOTLIN_ARCH}--musl--stable-[^\"]+\\.tar\\.xz" | sort -r | head -n1)
|
||||||
TOOLCHAIN_DIR=$(find . -maxdepth 1 -type d -name "${BOOTLIN_ARCH}--musl--stable-*" | head -n1)
|
[ -z "$TARBALL_URL" ] && { echo "Failed to locate Bootlin musl toolchain for arch=$BOOTLIN_ARCH" >&2; exit 1; }
|
||||||
export PATH="$(realpath "$TOOLCHAIN_DIR")/bin:$PATH"
|
echo "Downloading: $TARBALL_URL"
|
||||||
export CC=$(realpath "$(find "$TOOLCHAIN_DIR/bin" -name '*-gcc.br_real' -type f -executable | head -n1)")
|
cd /tmp/toolchain
|
||||||
[ -z "$CC" ] && { echo "No gcc.br_real found in $TOOLCHAIN_DIR/bin" >&2; exit 1; }
|
curl -fL -sS --retry 3 --retry-delay 5 -o "$(basename "$TARBALL_URL")" "$TARBALL_BASE/$TARBALL_URL"
|
||||||
cd -
|
tar -xf "$(basename "$TARBALL_URL")"
|
||||||
|
TOOLCHAIN_DIR=$(find . -maxdepth 1 -type d -name "${BOOTLIN_ARCH}--musl--stable-*" | head -n1)
|
||||||
|
cd -
|
||||||
|
else
|
||||||
|
echo "Using cached toolchain: $TOOLCHAIN_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export PATH="$(realpath "/tmp/toolchain/$TOOLCHAIN_DIR")/bin:$PATH"
|
||||||
|
export CC=$(realpath "$(find "/tmp/toolchain/$TOOLCHAIN_DIR/bin" -name '*-gcc.br_real' -type f -executable | head -n1)")
|
||||||
|
[ -z "$CC" ] && { echo "No gcc.br_real found in /tmp/toolchain/$TOOLCHAIN_DIR/bin" >&2; exit 1; }
|
||||||
go build -ldflags "-w -s -linkmode external -extldflags '-static'" -o xui-release -v main.go
|
go build -ldflags "-w -s -linkmode external -extldflags '-static'" -o xui-release -v main.go
|
||||||
file xui-release
|
file xui-release
|
||||||
ldd xui-release || echo "Static binary confirmed"
|
ldd xui-release || echo "Static binary confirmed"
|
||||||
|
|
@ -128,44 +157,38 @@ jobs:
|
||||||
mkdir x-ui/bin
|
mkdir x-ui/bin
|
||||||
cd x-ui/bin
|
cd x-ui/bin
|
||||||
|
|
||||||
# Download dependencies
|
# Download Xray
|
||||||
Xray_URL="https://github.com/XTLS/Xray-core/releases/download/v26.2.6/"
|
Xray_URL="https://github.com/XTLS/Xray-core/releases/download/${{ steps.xray_version.outputs.version }}/"
|
||||||
if [ "${{ matrix.platform }}" == "amd64" ]; then
|
declare -A XRAY_MAP=(
|
||||||
wget -q ${Xray_URL}Xray-linux-64.zip
|
[amd64]="Xray-linux-64.zip"
|
||||||
unzip Xray-linux-64.zip
|
[arm64]="Xray-linux-arm64-v8a.zip"
|
||||||
rm -f Xray-linux-64.zip
|
[armv7]="Xray-linux-arm32-v7a.zip"
|
||||||
elif [ "${{ matrix.platform }}" == "arm64" ]; then
|
[armv6]="Xray-linux-arm32-v6.zip"
|
||||||
wget -q ${Xray_URL}Xray-linux-arm64-v8a.zip
|
[386]="Xray-linux-32.zip"
|
||||||
unzip Xray-linux-arm64-v8a.zip
|
[armv5]="Xray-linux-arm32-v5.zip"
|
||||||
rm -f Xray-linux-arm64-v8a.zip
|
[s390x]="Xray-linux-s390x.zip"
|
||||||
elif [ "${{ matrix.platform }}" == "armv7" ]; then
|
)
|
||||||
wget -q ${Xray_URL}Xray-linux-arm32-v7a.zip
|
XRAY_FILE="${XRAY_MAP[${{ matrix.platform }}]}"
|
||||||
unzip Xray-linux-arm32-v7a.zip
|
[ -z "$XRAY_FILE" ] && { echo "Unknown platform: ${{ matrix.platform }}" >&2; exit 1; }
|
||||||
rm -f Xray-linux-arm32-v7a.zip
|
curl -fL -sS --retry 3 --retry-delay 5 -o "$XRAY_FILE" "${Xray_URL}${XRAY_FILE}"
|
||||||
elif [ "${{ matrix.platform }}" == "armv6" ]; then
|
unzip -q "$XRAY_FILE"
|
||||||
wget -q ${Xray_URL}Xray-linux-arm32-v6.zip
|
rm -f "$XRAY_FILE"
|
||||||
unzip Xray-linux-arm32-v6.zip
|
|
||||||
rm -f Xray-linux-arm32-v6.zip
|
# Download geo data in parallel
|
||||||
elif [ "${{ matrix.platform }}" == "386" ]; then
|
curl -fL -sS --retry 3 -o geoip.dat \
|
||||||
wget -q ${Xray_URL}Xray-linux-32.zip
|
https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat &
|
||||||
unzip Xray-linux-32.zip
|
curl -fL -sS --retry 3 -o geosite.dat \
|
||||||
rm -f Xray-linux-32.zip
|
https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat &
|
||||||
elif [ "${{ matrix.platform }}" == "armv5" ]; then
|
curl -fL -sS --retry 3 -o geoip_IR.dat \
|
||||||
wget -q ${Xray_URL}Xray-linux-arm32-v5.zip
|
https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat &
|
||||||
unzip Xray-linux-arm32-v5.zip
|
curl -fL -sS --retry 3 -o geosite_IR.dat \
|
||||||
rm -f Xray-linux-arm32-v5.zip
|
https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat &
|
||||||
elif [ "${{ matrix.platform }}" == "s390x" ]; then
|
curl -fL -sS --retry 3 -o geoip_RU.dat \
|
||||||
wget -q ${Xray_URL}Xray-linux-s390x.zip
|
https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geoip.dat &
|
||||||
unzip Xray-linux-s390x.zip
|
curl -fL -sS --retry 3 -o geosite_RU.dat \
|
||||||
rm -f Xray-linux-s390x.zip
|
https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geosite.dat &
|
||||||
fi
|
wait
|
||||||
rm -f geoip.dat geosite.dat
|
|
||||||
wget -q https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
|
|
||||||
wget -q https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
|
|
||||||
wget -q -O geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat
|
|
||||||
wget -q -O geosite_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat
|
|
||||||
wget -q -O geoip_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geoip.dat
|
|
||||||
wget -q -O geosite_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geosite.dat
|
|
||||||
mv xray xray-linux-${{ matrix.platform }}
|
mv xray xray-linux-${{ matrix.platform }}
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
|
|
@ -185,7 +208,8 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
TAG="${{ github.ref_name }}"
|
TAG="${{ github.ref_name }}"
|
||||||
if ! gh release view "$TAG" > /dev/null 2>&1; then
|
if ! gh release view "$TAG" > /dev/null 2>&1; then
|
||||||
gh release create "$TAG" --prerelease --title "$TAG" --generate-notes
|
gh release create "$TAG" --prerelease --title "$TAG" --generate-notes \
|
||||||
|
--notes "**Xray-core:** ${{ steps.xray_version.outputs.version }}"
|
||||||
fi
|
fi
|
||||||
gh release upload "$TAG" x-ui-linux-${{ matrix.platform }}.tar.gz --clobber
|
gh release upload "$TAG" x-ui-linux-${{ matrix.platform }}.tar.gz --clobber
|
||||||
|
|
||||||
|
|
@ -194,7 +218,6 @@ jobs:
|
||||||
# =================================
|
# =================================
|
||||||
# build-windows:
|
# build-windows:
|
||||||
# name: Build for Windows
|
# name: Build for Windows
|
||||||
# needs: analyze
|
|
||||||
# permissions:
|
# permissions:
|
||||||
# contents: write
|
# contents: write
|
||||||
# strategy:
|
# strategy:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue