Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 114 additions & 62 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,55 @@
name: Build libXray

on:
workflow_dispatch:
push:
tags:
- "v*"

concurrency:
group: build-libxray-${{ github.ref }}
cancel-in-progress: false

env:
GO_VERSION: "stable"
XCODE_VERSION: "latest-stable"
PYTHON_VERSION: "3.12"
NDK_VERSION: r29

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- runner: ubuntu-24.04
target: linux
arch: x64
artifact: linux-x64
- runner: ubuntu-24.04-arm
target: linux
- os: ubuntu-latest
arch: arm64
artifact: linux-arm64
- runner: ubuntu-24.04
target: android
- os: windows-latest
artifact: android
- runner: windows-2022
target: windows
- os: macos-latest
arch: x64
artifact: windows-x64
- runner: macos-26
target: apple
apple_tool: go
artifact: apple-cgo
- runner: macos-26
target: apple
apple_tool: gomobile
artifact: apple-gomobile

runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
permissions:
contents: read

env:
CGO_ENABLED: "1"
Expand All @@ -30,15 +59,15 @@ jobs:
# Checkout
# =========================
- name: Checkout source
uses: actions/checkout@v4
uses: actions/checkout@v6

# =========================
# Python (build scripts)
# =========================
- name: Setup Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "3.11"
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Python deps
run: |
Expand All @@ -48,27 +77,44 @@ jobs:
# Go setup
# =========================
- name: Setup Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: "1.22"
go-version: ${{ env.GO_VERSION }}
check-latest: true

- name: Download Go modules
run: go mod download

# =========================
# Apple toolchain
# =========================
- name: Select latest stable Xcode
if: matrix.target == 'apple'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ env.XCODE_VERSION }}

# =========================
# Android toolchain
# =========================
- name: Setup Java (Android)
if: matrix.target == 'android'
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "17"
java-version: "21"

- name: Setup Android SDK
if: matrix.target == 'android'
uses: android-actions/setup-android@v3

- name: Setup Android NDK
if: matrix.target == 'android'
uses: nttld/setup-ndk@v1
with:
ndk-version: ${{ env.NDK_VERSION }}
add-to-path: true

- name: Install gomobile (Android)
if: matrix.target == 'android'
run: |
Expand All @@ -90,7 +136,7 @@ jobs:
# Apple toolchain
# =========================
- name: Setup gomobile (Apple)
if: matrix.target == 'apple'
if: matrix.target == 'apple' && matrix.apple_tool == 'gomobile'
run: |
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
Expand All @@ -117,7 +163,7 @@ jobs:
- name: Build Apple (macOS/iOS)
if: matrix.target == 'apple'
run: |
python3 build/main.py apple go
python3 build/main.py apple ${{ matrix.apple_tool }}

# =========================
# Collect artifacts
Expand All @@ -127,59 +173,65 @@ jobs:
run: |
set -e

# ---------------- Linux ----------------
mkdir -p dist/linux
cp linux_so/libXray.so dist/linux/ || true
cp linux_so/libXray.h dist/linux/ || true
cp bin/xray dist/linux/ || true

# ---------------- Windows ----------------
mkdir -p dist/windows
cp windows_dll/libXRay.dll dist/windows/ || true
cp windows_dll/libXRay.h dist/windows/ || true
cp bin/xray.exe dist/windows/ || true

# ---------------- Android ----------------
mkdir -p dist/android
cp ./libXray.aar dist/android/ || true
cp ./libXray-sources.jar dist/android/ || true

# ---------------- Apple ----------------
mkdir -p dist/apple
cp -r LibXray.xcframework dist/apple/ || true
case "${{ matrix.target }}" in
linux)
mkdir -p "dist/${{ matrix.artifact }}"
cp linux_so/libXray.so "dist/${{ matrix.artifact }}/"
cp linux_so/libXray.h "dist/${{ matrix.artifact }}/"
cp bin/xray "dist/${{ matrix.artifact }}/"
;;
windows)
mkdir -p "dist/${{ matrix.artifact }}"
cp windows_dll/libXray.dll "dist/${{ matrix.artifact }}/"
cp windows_dll/libXray.h "dist/${{ matrix.artifact }}/"
cp bin/xray.exe "dist/${{ matrix.artifact }}/"
;;
android)
mkdir -p "dist/${{ matrix.artifact }}"
cp libXray.aar "dist/${{ matrix.artifact }}/"
cp libXray-sources.jar "dist/${{ matrix.artifact }}/"
;;
apple)
mkdir -p "dist/${{ matrix.artifact }}"
cp -R LibXray.xcframework "dist/${{ matrix.artifact }}/"
;;
esac

# =========================
# Upload artifacts
# =========================
- name: Upload artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: libxray-${{ matrix.target }}
path: dist/${{ matrix.target }}/
name: libxray-${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}/
if-no-files-found: error

release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: libxray-*
path: dist/
merge-multiple: false

- name: Zip each platform
run: |
cd dist
for d in */ ; do
zip -r "${d%/}.zip" "$d"
done

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: libXRay ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
files: dist/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
needs: build
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
pattern: libxray-*
path: dist/
merge-multiple: false

- name: Zip each platform
run: |
cd dist
for d in */ ; do
zip -r "${d%/}.zip" "$d"
done

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: libXray ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
files: dist/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion desktop_bin/route_other.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !linux && !windows
//go:build !linux

package main

Expand Down
126 changes: 0 additions & 126 deletions desktop_bin/route_windows.go

This file was deleted.