Skip to content

feat: 废弃 Python Agent 限速链路,改用 sing-box 原生限速 #202

feat: 废弃 Python Agent 限速链路,改用 sing-box 原生限速

feat: 废弃 Python Agent 限速链路,改用 sing-box 原生限速 #202

Workflow file for this run

name: Build Native Executables
on:
# ! 为了避免重复发布版本,应当通过独特 git tag 触发。
# ! 不再使用 workflow_dispatch 触发。
workflow_dispatch:
push:
# 只通过 v*.*.* 的 tag 触发发布,避免在 main 分支 push 时触发。
tags:
- "v*.*.*"
permissions: write-all
jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
platform: linux
executable_suffix: ""
# - os: windows-latest
# platform: windows
# executable_suffix: ".exe"
# artifact_name: airopscat-windows-amd64.exe
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: |
~/.m2
~/.m2/wrapper
key: ${{ runner.os }}-quarkus-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-quarkus-
${{ runner.os }}-m2-
- name: Verify GraalVM installation
run: |
echo "GRAALVM_HOME: $GRAALVM_HOME"
echo "JAVA_HOME: $JAVA_HOME"
java --version
native-image --version
# - name: Install UPX (Linux)
# if: matrix.os == 'ubuntu-latest'
# run: |
# wget https://github.com/upx/upx/releases/download/v5.0.2/upx-5.0.2-amd64_linux.tar.xz
# tar -xf upx-5.0.2-amd64_linux.tar.xz
# sudo mv upx-5.0.2-amd64_linux/upx /usr/local/bin/
# upx --version
# - name: Install UPX (Windows)
# if: matrix.os == 'windows-latest'
# run: |
# Invoke-WebRequest -Uri "https://github.com/upx/upx/releases/download/v5.0.2/upx-5.0.2-win64.zip" -OutFile "upx.zip"
# Expand-Archive upx.zip -DestinationPath .
# Move-Item upx-5.0.2-win64\upx.exe C:\Windows\System32\
# upx --version
# shell: powershell
# - name: Run tests
# run: ./mvnw test
# - name: Build native executable (Windows)
# if: matrix.os == 'windows-latest'
# run: ./mvnw clean package -Pnative -DskipTests -Dquarkus.native.additional-build-args=-J-Xmx8g
# shell: cmd
# timeout-minutes: 40
- name: Build native executable (Linux)
if: matrix.os == 'ubuntu-latest'
run: ./mvnw -B -ntp package -Pnative -DskipTests -Dquarkus.native.additional-build-args=-J-Xmx8g
timeout-minutes: 40
# - name: Rename executable (Windows)
# if: matrix.os == 'windows-latest'
# run: |
# move target\airopscat-*-runner.exe target\${{ matrix.artifact_name }}
# shell: cmd
- name: Create both Linux versions (regular and UPX)
if: matrix.os == 'ubuntu-latest'
run: |
# Create regular version
cp target/airopscat-*-runner target/airopscat-linux-amd64
# # Create UPX compressed version
# cp target/airopscat-*-runner target/airopscat-linux-amd64-upx
# upx --best target/airopscat-linux-amd64-upx
- name: Create distribution directories (Linux)
if: matrix.os == 'ubuntu-latest'
run: mkdir -p dist-regular dist-upx
# - name: Create distribution directories (Windows)
# if: matrix.os == 'windows-latest'
# run: mkdir dist
# shell: cmd
#
# - name: Copy executable to dist (Windows)
# if: matrix.os == 'windows-latest'
# run: copy target\${{ matrix.artifact_name }} dist\
# shell: cmd
- name: Copy executables to dist (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
cp target/airopscat-linux-amd64 dist-regular/
# cp target/airopscat-linux-amd64-upx dist-upx/
# - name: Create distribution archive (Windows)
# if: matrix.os == 'windows-latest'
# run: |
# 7z a -tzip ${{ matrix.artifact_name }}.zip dist\*
# shell: cmd
- name: Create distribution archives (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
tar -czf airopscat-linux-amd64.tar.gz -C dist-regular airopscat-linux-amd64
# tar -czf airopscat-linux-amd64-upx.tar.gz -C dist-upx airopscat-linux-amd64-upx
- name: Upload Linux regular distribution
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: airopscat-linux-amd64-distribution
path: airopscat-linux-amd64.tar.gz
retention-days: 30
# - name: Upload Linux UPX distribution
# if: matrix.os == 'ubuntu-latest'
# uses: actions/upload-artifact@v4
# with:
# name: airopscat-linux-amd64-upx-distribution
# path: airopscat-linux-amd64-upx.tar.gz
# retention-days: 30
# - name: Upload distribution archive (Windows)
# if: matrix.os == 'windows-latest'
# uses: actions/upload-artifact@v4
# with:
# name: ${{ matrix.artifact_name }}-distribution
# path: ${{ matrix.artifact_name }}.zip
# retention-days: 30
release:
name: Create Release
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
**/airopscat-*
body: |
## AirOpsCat ${{ github.ref_name }}
Native Linux build for this version.
Artifact:
- `airopscat-linux-amd64.tar.gz`
Usage:
- Extract the archive
- Run `./airopscat-linux-amd64`
- Open `http://localhost:8080`
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}