mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-11-20 23:02:25 +03:00
192 lines
8.9 KiB
YAML
192 lines
8.9 KiB
YAML
name: Build Linux Packages (Reusable)
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
version:
|
|
description: "Version string for the packages"
|
|
type: string
|
|
required: true
|
|
|
|
jobs:
|
|
Build_Linux_Packages:
|
|
name: ${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
goos: [linux]
|
|
goarch:
|
|
[amd64, arm64, 386, riscv64, loong64]
|
|
include:
|
|
- goos: linux
|
|
goarch: arm
|
|
goarm: 7
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
GOARM: ${{ matrix.goarm }}
|
|
CGO_ENABLED: 0
|
|
VERSION: ${{ inputs.version }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Get Friendly File Name
|
|
shell: pwsh
|
|
id: get_filename
|
|
run: |
|
|
$build_name = $(((Get-Content ./install/friendly-filenames.json | ConvertFrom-Json)."${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm }}").friendlyName)
|
|
$friendly_arch = $((((Get-Content ./install/friendly-filenames.json | ConvertFrom-Json)."${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm }}").friendlyName).Split('_')[1])
|
|
Write-Output "BUILD_NAME=$build_name" >> ${env:GITHUB_OUTPUT}
|
|
Write-Output "BUILD_NAME=$build_name" >> ${env:GITHUB_ENV}
|
|
Write-Output "FRIENDLY_ARCH=$friendly_arch" >> ${env:GITHUB_OUTPUT}
|
|
Write-Output "FRIENDLY_ARCH=$friendly_arch" >> ${env:GITHUB_ENV}
|
|
- name: Download Artifact
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
name: v2raya_${{ steps.get_filename.outputs.BUILD_NAME }}_${{ inputs.version }}
|
|
path: build/
|
|
- name: Download Core Artifact
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
name: v2raya_core_${{ steps.get_filename.outputs.BUILD_NAME }}_${{ inputs.version }}
|
|
path: build/
|
|
- name: Download Geosite and GeoIP
|
|
shell: bash
|
|
run: |
|
|
mkdir v2ray-rules-dat
|
|
curl -LO https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
|
|
curl -LO https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
|
|
mv geosite.dat geoip.dat v2ray-rules-dat/
|
|
ls v2ray-rules-dat/
|
|
- name: Download x64 Linux Build
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
name: v2raya_linux_x64_${{ inputs.version }}
|
|
path: test/
|
|
- name: Show Artifacts
|
|
run: |
|
|
ls -l build/
|
|
- name: Install nfpm
|
|
env:
|
|
NFPM_VERSION: 2.48.0
|
|
run: |
|
|
curl -fsSL -o nfpm.tar.gz "https://github.com/goreleaser/nfpm/releases/download/v$NFPM_VERSION/nfpm_${NFPM_VERSION}_Linux_x86_64.tar.gz"
|
|
sudo tar -xzf nfpm.tar.gz -C /usr/local/bin nfpm
|
|
rm nfpm.tar.gz
|
|
nfpm --version
|
|
- name: Build Packages
|
|
run: |
|
|
sudo chmod 755 ./test/v2raya_linux_x64_$VERSION
|
|
./test/v2raya_linux_x64_$VERSION --report config | sed '1,6d' | fold -s -w 78 | sed -E 's/^([^#].+)/# \1/' >> install/universal/v2raya.default
|
|
mkdir -p pkg packages
|
|
cp ./build/v2raya_${{ steps.get_filename.outputs.BUILD_NAME }}_${{ inputs.version }} pkg/v2raya
|
|
cp ./build/v2raya_core_${{ steps.get_filename.outputs.BUILD_NAME }}_${{ inputs.version }} pkg/v2raya_core
|
|
cp ./v2ray-rules-dat/geoip.dat ./v2ray-rules-dat/geosite.dat pkg/
|
|
chmod 755 pkg/v2raya pkg/v2raya_core
|
|
chmod 644 pkg/geoip.dat pkg/geosite.dat
|
|
# dpkg and pacman reject a version that does not start with a digit,
|
|
# so a development build such as unstable-20261114.r2341.eec29db8
|
|
# becomes the pre-release 0.0.0-unstable.20261114.r2341.eec29db8,
|
|
# which also sorts below every release.
|
|
case "$VERSION" in
|
|
[0-9]*) export PACKAGE_VERSION="$VERSION" ;;
|
|
*) export PACKAGE_VERSION="0.0.0-$(echo "$VERSION" | tr - .)" ;;
|
|
esac
|
|
# nfpm maps the Go architecture onto the name each packager expects.
|
|
if [ "$GOARCH" = 'arm' ]; then
|
|
export PACKAGE_ARCH="arm$GOARM"
|
|
else
|
|
export PACKAGE_ARCH="$GOARCH"
|
|
fi
|
|
if [ -n "$(echo $GOARCH | grep mips)" ]; then
|
|
packages="deb rpm"
|
|
else
|
|
packages="deb rpm archlinux apk"
|
|
fi
|
|
for package_manager in $packages; do
|
|
case $package_manager in
|
|
deb) package_distro='debian'; package_ext='deb' ;;
|
|
rpm) package_distro='redhat'; package_ext='rpm' ;;
|
|
archlinux) package_distro='archlinux'; package_ext='pkg.tar.zst' ;;
|
|
apk) package_distro='alpine'; package_ext='apk' ;;
|
|
esac
|
|
nfpm package -f install/nfpm/v2raya.yaml -p "$package_manager" \
|
|
-t "packages/installer_${package_distro}_${{ steps.get_filename.outputs.FRIENDLY_ARCH }}_${{ inputs.version }}.$package_ext"
|
|
done
|
|
ls -l packages/
|
|
- name: Set up QEMU
|
|
if: matrix.goarch != 'amd64' && matrix.goarch != '386'
|
|
uses: docker/setup-qemu-action@v4
|
|
- name: Test Packages
|
|
# A package can build and still not install: the 2.5.14 apk carried
|
|
# "provides = v2raya", which apk reads as a second package conflicting
|
|
# with v2raya itself. Each package is installed in a container of its
|
|
# own architecture where the distribution publishes one.
|
|
env:
|
|
NAME: ${{ steps.get_filename.outputs.FRIENDLY_ARCH }}_${{ inputs.version }}
|
|
run: |
|
|
alpine=alpine:latest
|
|
debian=debian:stable
|
|
case "$GOARCH" in
|
|
amd64) platform=linux/amd64 ;;
|
|
arm64) platform=linux/arm64 ;;
|
|
arm) platform=linux/arm/v7 ;;
|
|
386) platform=linux/386 ;;
|
|
riscv64) platform=linux/riscv64 ;;
|
|
loong64)
|
|
platform=linux/loong64
|
|
# Docker's alpine image has no loong64 variant, so import
|
|
# Alpine's own loongarch64 minirootfs. No Debian image exists.
|
|
base=https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/loongarch64
|
|
curl -fsSL "$base/latest-releases.yaml" > releases.yaml
|
|
file=$(awk '/flavor: alpine-minirootfs/ {m=1} m && /file:/ {print $2; exit}' releases.yaml)
|
|
sum=$(awk '/flavor: alpine-minirootfs/ {m=1} m && /sha256:/ {print $2; exit}' releases.yaml)
|
|
curl -fsSLO "$base/$file"
|
|
echo "$sum $file" | sha256sum -c -
|
|
docker import --platform "$platform" "$file" alpine-loong64
|
|
alpine=alpine-loong64
|
|
debian=
|
|
;;
|
|
*) echo "No distribution image for $GOARCH; the packages are not installed"; exit 0 ;;
|
|
esac
|
|
check() {
|
|
docker run --rm --platform "$platform" -v "$PWD/packages:/packages:ro" -e NAME "$1" sh -euc "$2"
|
|
}
|
|
check "$alpine" 'apk add --allow-untrusted "/packages/installer_alpine_$NAME.apk" && v2raya --version'
|
|
if [ -n "$debian" ]; then
|
|
check "$debian" 'apt-get update -qq && apt-get install -y -qq "/packages/installer_debian_$NAME.deb" && v2raya --version'
|
|
fi
|
|
case "$GOARCH" in
|
|
amd64|arm64) check fedora:latest 'dnf install -y -q "/packages/installer_redhat_$NAME.rpm" && v2raya --version' ;;
|
|
esac
|
|
if [ "$GOARCH" = amd64 ]; then
|
|
check archlinux:latest 'pacman -U --noconfirm "/packages/installer_archlinux_$NAME.pkg.tar.zst" && v2raya --version'
|
|
fi
|
|
- name: Upload Arch Linux Package
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
if-no-files-found: ignore
|
|
name: installer_archlinux_${{ steps.get_filename.outputs.FRIENDLY_ARCH }}_${{ inputs.version }}.pkg.tar.zst
|
|
path: |
|
|
packages/installer_archlinux_${{ steps.get_filename.outputs.FRIENDLY_ARCH }}_${{ inputs.version }}.pkg.tar.zst
|
|
- name: Upload Red Hat Package
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: installer_redhat_${{ steps.get_filename.outputs.FRIENDLY_ARCH }}_${{ inputs.version }}.rpm
|
|
path: |
|
|
packages/installer_redhat_${{ steps.get_filename.outputs.FRIENDLY_ARCH }}_${{ inputs.version }}.rpm
|
|
- name: Upload Debian Package
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: installer_debian_${{ steps.get_filename.outputs.FRIENDLY_ARCH }}_${{ inputs.version }}.deb
|
|
path: |
|
|
packages/installer_debian_${{ steps.get_filename.outputs.FRIENDLY_ARCH }}_${{ inputs.version }}.deb
|
|
- name: Upload Alpine Package
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
if-no-files-found: ignore
|
|
name: installer_alpine_${{ steps.get_filename.outputs.FRIENDLY_ARCH }}_${{ inputs.version }}.apk
|
|
path: |
|
|
packages/installer_alpine_${{ steps.get_filename.outputs.FRIENDLY_ARCH }}_${{ inputs.version }}.apk
|