mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-11-20 23:02:25 +03:00
117 lines
5.1 KiB
YAML
117 lines
5.1 KiB
YAML
name: Build v2rayA Binaries (Reusable)
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
version:
|
|
description: "Version string for the build"
|
|
type: string
|
|
required: true
|
|
|
|
jobs:
|
|
Build_v2rayA_Binaries:
|
|
# An explicit name replaces the default "<job_id> (<every matrix value>)",
|
|
# which would spell out CC and EXTRA_LDFLAGS in the run's job list.
|
|
name: ${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
# Linux
|
|
- { goos: linux, goarch: amd64, CGO_ENABLED: 0 }
|
|
- { goos: linux, goarch: arm64, CGO_ENABLED: 0 }
|
|
# Linux, other architectures
|
|
- { goos: linux, goarch: "386", CGO_ENABLED: 0 }
|
|
- { goos: linux, goarch: riscv64, CGO_ENABLED: 0 }
|
|
- { goos: linux, goarch: loong64, CGO_ENABLED: 1, CC: "zig cc -target loongarch64-linux-musl", EXTRA_LDFLAGS: "-linkmode=external -extldflags '-static -Wl,--strip-debug'" }
|
|
# Linux armv7
|
|
- { goos: linux, goarch: arm, goarm: "7", CGO_ENABLED: 0 }
|
|
# Windows
|
|
- { goos: windows, goarch: amd64, CGO_ENABLED: 0 }
|
|
- { goos: windows, goarch: arm64, CGO_ENABLED: 0 }
|
|
# macOS
|
|
- { goos: darwin, goarch: amd64, CGO_ENABLED: 0 }
|
|
- { goos: darwin, goarch: arm64, CGO_ENABLED: 0 }
|
|
# FreeBSD (no TUN)
|
|
- { goos: freebsd, goarch: amd64, CGO_ENABLED: 0 }
|
|
- { goos: freebsd, goarch: arm64, CGO_ENABLED: 0 }
|
|
# OpenBSD (no TUN)
|
|
- { goos: openbsd, goarch: amd64, CGO_ENABLED: 0 }
|
|
- { goos: openbsd, goarch: arm64, CGO_ENABLED: 0 }
|
|
env:
|
|
VERSION: ${{ inputs.version }}
|
|
NAME: v2raya
|
|
DESC: "A web GUI client of Project V which supports VMess, VLESS, Shadowsocks, Trojan, TUIC, Juicity and AnyTLSs"
|
|
# Empty for every leg that does not need cgo; the build commands below are
|
|
# then exactly what they were before.
|
|
CC: ${{ matrix.CC }}
|
|
EXTRA_LDFLAGS: ${{ matrix.EXTRA_LDFLAGS }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Download Web Artifact
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
name: web
|
|
path: service/server/router/web
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
cache-dependency-path: |
|
|
core/go.mod
|
|
core/go.sum
|
|
service/go.mod
|
|
service/go.sum
|
|
go-version: "1.27"
|
|
# Zig supplies a C compiler for the cgo legs, so no distro cross-gcc is
|
|
# needed; the version pinned in the action is one that targets loongarch64.
|
|
- name: Install Zig
|
|
if: matrix.CGO_ENABLED == 1
|
|
uses: ./.github/actions/install-zig
|
|
- name: Build v2rayA Binary
|
|
id: build_binary
|
|
shell: bash
|
|
run: |
|
|
[ -d v2raya_binaries ] || mkdir -p v2raya_binaries
|
|
key="${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm }}"
|
|
filename=$(jq -r --arg key "$key" '.[$key].friendlyName' ./install/friendly-filenames.json)
|
|
ext=""
|
|
[ "${{ matrix.goos }}" = "windows" ] && ext=".exe"
|
|
cgo_enabled=${{ matrix.CGO_ENABLED }}
|
|
cd service
|
|
GOOS="${{ matrix.goos }}" GOARCH="${{ matrix.goarch }}" GOARM="${{ matrix.goarm }}" CGO_ENABLED="$cgo_enabled" \
|
|
go build -trimpath \
|
|
-o ../v2raya_binaries/v2raya_${filename}_${{ inputs.version }}${ext} \
|
|
-ldflags="-X github.com/v2rayA/v2rayA/conf.Version=${{ inputs.version }} -s -w ${EXTRA_LDFLAGS}" \
|
|
-trimpath
|
|
echo "filename=v2raya_${filename}_${{ inputs.version }}${ext}" >> ${GITHUB_OUTPUT}
|
|
- name: Build v2rayA Core Binary
|
|
id: build_core_binary
|
|
shell: bash
|
|
run: |
|
|
[ -d v2raya_binaries ] || mkdir -p v2raya_binaries
|
|
key="${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm }}"
|
|
filename=$(jq -r --arg key "$key" '.[$key].friendlyName' ./install/friendly-filenames.json)
|
|
ext=""
|
|
[ "${{ matrix.goos }}" = "windows" ] && ext=".exe"
|
|
cd core
|
|
cgo_enabled=${{ matrix.CGO_ENABLED }}
|
|
GOOS="${{ matrix.goos }}" GOARCH="${{ matrix.goarch }}" GOARM="${{ matrix.goarm }}" CGO_ENABLED="$cgo_enabled" \
|
|
go build -trimpath \
|
|
-o ../v2raya_binaries/v2raya_core_${filename}_${{ inputs.version }}${ext} \
|
|
-ldflags="-X main.Version=${{ inputs.version }} -s -w ${EXTRA_LDFLAGS}" \
|
|
-trimpath \
|
|
./main
|
|
echo "filename=v2raya_core_${filename}_${{ inputs.version }}${ext}" >> ${GITHUB_OUTPUT}
|
|
- name: Upload v2rayA Binary Artifact
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: ${{ steps.build_binary.outputs.filename }}
|
|
path: v2raya_binaries/${{ steps.build_binary.outputs.filename }}
|
|
- name: Upload v2rayA Core Binary Artifact
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: ${{ steps.build_core_binary.outputs.filename }}
|
|
path: v2raya_binaries/${{ steps.build_core_binary.outputs.filename }}
|