ostp/.github/workflows/release.yml

221 lines
8.7 KiB
YAML

name: Universal CI/CD Release Matrix
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
publish-release-matrix:
name: Release for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# ==========================================
# 🏁 WINDOWS ECOSYSTEM
# ==========================================
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: ostp.exe
release_name: ostp-windows-amd64.zip
tun2socks_arch: windows-amd64
wintun_arch: amd64
- os: windows-latest
target: i686-pc-windows-msvc
artifact_name: ostp.exe
release_name: ostp-windows-386.zip
tun2socks_arch: windows-386
wintun_arch: x86
- os: windows-latest
target: aarch64-pc-windows-msvc
artifact_name: ostp.exe
release_name: ostp-windows-arm64.zip
tun2socks_arch: windows-arm64
wintun_arch: arm64
# ==========================================
# 🍏 APPLE DARWIN (macOS)
# ==========================================
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: ostp
release_name: ostp-darwin-amd64.tar.gz
tun2socks_arch: darwin-amd64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: ostp
release_name: ostp-darwin-arm64.tar.gz
tun2socks_arch: darwin-arm64
# ==========================================
# 🐧 LINUX & FreeBSD STANDARD
# ==========================================
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: ostp
release_name: ostp-linux-amd64.tar.gz
tun2socks_arch: linux-amd64
- os: ubuntu-latest
target: i686-unknown-linux-musl
artifact_name: ostp
release_name: ostp-linux-386.tar.gz
tun2socks_arch: linux-386
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
artifact_name: ostp
release_name: ostp-linux-arm64.tar.gz
tun2socks_arch: linux-arm64
use_cross: true
- os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
artifact_name: ostp
release_name: ostp-linux-armv7.tar.gz
tun2socks_arch: linux-armv7
use_cross: true
- os: ubuntu-latest
target: x86_64-unknown-freebsd
artifact_name: ostp
release_name: ostp-freebsd-amd64.tar.gz
tun2socks_arch: freebsd-amd64
use_cross: true
# ==========================================
# 🛰️ ROUTER & SPECIAL ARCHITECTURES (Cross)
# ==========================================
- os: ubuntu-latest
target: mipsel-unknown-linux-musl
artifact_name: ostp
release_name: ostp-linux-mipsle.tar.gz
tun2socks_arch: linux-mipsle
use_cross: true
toolchain: nightly
- os: ubuntu-latest
target: riscv64gc-unknown-linux-gnu
artifact_name: ostp
release_name: ostp-linux-riscv64.tar.gz
tun2socks_arch: linux-riscv64
use_cross: true
# ==========================================
# 🤖 MOBILE & EMBEDDED SUITE (Cross)
# ==========================================
- os: ubuntu-latest
target: aarch64-linux-android
artifact_name: ostp
release_name: ostp-android-arm64.tar.gz
tun2socks_arch: android-arm64
use_cross: true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Initialize Rust ecosystem (Native Host)
if: ${{ !matrix.use_cross }}
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain || 'stable' }}
targets: ${{ matrix.target }}
- name: Initialize Rust ecosystem (Cross Container Host)
if: ${{ matrix.use_cross }}
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain || 'stable' }}
- name: Activate rust compilation caching
if: ${{ !matrix.use_cross }}
uses: swatinem/rust-cache@v2
- name: Setup local MUSL linker dependencies
if: ${{ matrix.os == 'ubuntu-latest' && !matrix.use_cross }}
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Execute Standard Native Compilation (Windows)
if: ${{ !matrix.use_cross && matrix.os == 'windows-latest' }}
run: cargo build --release --target ${{ matrix.target }} --bin ostp
- name: Execute Standard Native Compilation (Unix)
if: ${{ !matrix.use_cross && matrix.os != 'windows-latest' }}
shell: bash
run: |
rustup run ${{ matrix.toolchain || 'stable' }} cargo build --release --target ${{ matrix.target }} --bin ostp
- name: Execute Specialized Cross-Compilation
if: ${{ matrix.use_cross }}
run: |
cargo install cross --git https://github.com/cross-rs/cross.git
cross build --release --target ${{ matrix.target }} --bin ostp
- name: Inject Win32 Driver Dependencies (Windows)
if: ${{ matrix.os == 'windows-latest' && matrix.tun2socks_arch }}
shell: pwsh
run: |
cd target/${{ matrix.target }}/release
$ProgressPreference = 'SilentlyContinue'
# 1. Acquire tun2socks
Invoke-WebRequest -Uri "https://github.com/xjasonlyu/tun2socks/releases/download/v2.6.0/tun2socks-${{ matrix.tun2socks_arch }}.zip" -OutFile "tun2socks.zip"
Expand-Archive -Path "tun2socks.zip" -DestinationPath "tun_temp" -Force
Get-ChildItem -Path "tun_temp" -Filter "*.exe" -Recurse | Copy-Item -Destination "." -Force
# 2. Acquire wintun
Invoke-WebRequest -Uri "https://www.wintun.net/builds/wintun-0.14.1.zip" -OutFile "wintun.zip"
Expand-Archive -Path "wintun.zip" -DestinationPath "wintun_temp" -Force
Get-ChildItem -Path "wintun_temp" -Filter "wintun.dll" -Recurse | Where-Object { $_.FullName -match 'bin[\\/]${{ matrix.wintun_arch }}[\\/]' } | Copy-Item -Destination "." -Force
# Cleanup
Remove-Item "tun2socks.zip", "tun_temp", "wintun.zip", "wintun_temp" -Recurse -Force
- name: Inject Unix Driver Dependencies (Unix)
if: ${{ matrix.os != 'windows-latest' && matrix.tun2socks_arch }}
shell: bash
run: |
cd target/${{ matrix.target }}/release
# Fetch using correct extension (Linux = .tar.gz, Darwin/FreeBSD = .zip)
if [[ "${{ matrix.tun2socks_arch }}" == *"linux"* ]]; then
URL="https://github.com/xjasonlyu/tun2socks/releases/download/v2.6.0/tun2socks-${{ matrix.tun2socks_arch }}.tar.gz"
curl -L "$URL" -o "tun2socks.tar.gz"
tar -xzf "tun2socks.tar.gz"
find . -maxdepth 2 -name "tun2socks*" ! -name "*.tar.gz" -type f -exec mv {} ./tun2socks \;
rm -f "tun2socks.tar.gz"
else
URL="https://github.com/xjasonlyu/tun2socks/releases/download/v2.6.0/tun2socks-${{ matrix.tun2socks_arch }}.zip"
curl -L "$URL" -o "tun2socks.zip"
unzip -o "tun2socks.zip"
find . -maxdepth 2 -name "tun2socks*" ! -name "*.zip" -type f -exec mv {} ./tun2socks \;
rm -f "tun2socks.zip"
fi
chmod +x tun2socks || true
- name: Package release artifact (Windows)
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
cd target/${{ matrix.target }}/release
$files = @("${{ matrix.artifact_name }}")
if (Test-Path "tun2socks.exe") { $files += "tun2socks.exe" }
if (Test-Path "wintun.dll") { $files += "wintun.dll" }
Compress-Archive -Path $files -DestinationPath ../../../${{ matrix.release_name }}
- name: Package release artifact (Unix Systems)
if: ${{ matrix.os != 'windows-latest' }}
run: |
cd target/${{ matrix.target }}/release
FILES="${{ matrix.artifact_name }}"
if [ -f "tun2socks" ]; then
FILES="$FILES tun2socks"
fi
tar -czf ../../../${{ matrix.release_name }} $FILES
- name: Inject artifact to Global GitHub Release Assets
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: softprops/action-gh-release@v2
with:
files: ${{ matrix.release_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}