2024-01-12 20:02:41 +08:00
|
|
|
name: Build Sing-Box Core for ShellCrash
|
|
|
|
|
|
|
|
on:
|
2024-01-08 21:30:36 +08:00
|
|
|
workflow_dispatch:
|
2024-01-08 21:28:03 +08:00
|
|
|
inputs:
|
2024-01-12 20:02:41 +08:00
|
|
|
tag:
|
|
|
|
description: 'tag of sing-box, such as v1.7.8'
|
2024-01-08 21:28:03 +08:00
|
|
|
required: true
|
|
|
|
type: string
|
2024-01-04 20:07:11 +08:00
|
|
|
jobs:
|
2024-01-12 20:02:41 +08:00
|
|
|
cross:
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
# linux
|
|
|
|
- name: linux-amd64
|
|
|
|
goos: linux
|
|
|
|
goarch: amd64
|
|
|
|
goamd64: v1
|
|
|
|
- name: linux-386
|
|
|
|
goos: linux
|
|
|
|
goarch: 386
|
|
|
|
- name: linux-arm64
|
|
|
|
goos: linux
|
|
|
|
goarch: arm64
|
|
|
|
- name: linux-armv5
|
|
|
|
goos: linux
|
|
|
|
goarch: arm
|
|
|
|
goarm: 5
|
|
|
|
- name: linux-armv7
|
|
|
|
goos: linux
|
|
|
|
goarch: arm
|
|
|
|
goarm: 7
|
|
|
|
- name: linux-mips-softfloat
|
|
|
|
goos: linux
|
|
|
|
goarch: mips
|
|
|
|
gomips: softfloat
|
|
|
|
- name: linux-mipsel-softfloat
|
|
|
|
goos: linux
|
|
|
|
goarch: mipsle
|
|
|
|
gomips: softfloat
|
|
|
|
- name: linux-mipsel-hardfloat
|
|
|
|
goos: linux
|
|
|
|
goarch: mipsle
|
|
|
|
gomips: hardfloat
|
|
|
|
|
|
|
|
fail-fast: false
|
2024-01-04 20:07:11 +08:00
|
|
|
runs-on: ubuntu-latest
|
2024-01-12 20:02:41 +08:00
|
|
|
env:
|
|
|
|
GOOS: ${{ matrix.goos }}
|
|
|
|
GOARCH: ${{ matrix.goarch }}
|
|
|
|
GOAMD64: ${{ matrix.goamd64 }}
|
|
|
|
GOARM: ${{ matrix.goarm }}
|
|
|
|
GOMIPS: ${{ matrix.gomips }}
|
|
|
|
CGO_ENABLED: 0
|
|
|
|
TAGS: with_quic,with_wireguard,with_ech,with_utls,with_reality_server,with_acme,with_clash_api
|
2024-01-04 20:07:11 +08:00
|
|
|
steps:
|
2024-01-12 20:02:41 +08:00
|
|
|
- name: Checkout sing-box
|
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
|
|
|
with:
|
|
|
|
repository: SagerNet/sing-box
|
|
|
|
ref: ${{ github.event.inputs.tag }}
|
|
|
|
fetch-depth: 0
|
|
|
|
- name: Get latest go version
|
|
|
|
id: version
|
|
|
|
run: |
|
|
|
|
echo go_version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') >> $GITHUB_OUTPUT
|
|
|
|
- name: Setup Go
|
|
|
|
uses: actions/setup-go@v5
|
|
|
|
with:
|
|
|
|
go-version: ${{ steps.version.outputs.go_version }}
|
|
|
|
- name: Build
|
|
|
|
id: build
|
|
|
|
run: make
|
|
|
|
- name: Rename
|
|
|
|
run: |
|
|
|
|
mv -f sing-box sing-box-${{ matrix.name }}
|
|
|
|
- name: Upload file to workspace
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
path: sing-box-${{ matrix.name }}
|
|
|
|
push_ShellCrash:
|
|
|
|
needs: cross
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout ShellCrash
|
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
|
|
|
with:
|
|
|
|
repository: juewuy/ShellCrash
|
|
|
|
ref: dev
|
|
|
|
- name: Get upx
|
|
|
|
run: |
|
|
|
|
wget https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz
|
|
|
|
wget https://github.com/upx/upx/releases/download/v3.93/upx-3.93-amd64_linux.tar.xz
|
|
|
|
tar xf upx-3.96-amd64_linux.tar.xz
|
|
|
|
tar xf upx-3.93-amd64_linux.tar.xz
|
|
|
|
- name: Download file from workspace
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
path: ./tmp
|
|
|
|
- name: Zip core by upx
|
|
|
|
run: |
|
|
|
|
dir=/home/runner/work/sing-box/sing-box/tmp/artifact
|
|
|
|
archs=(amd64 armv5 armv7 arm64 mips-softfloat mipsle-hardfloat mipsle-softfloat)
|
|
|
|
new_name=(amd64 armv5 armv7 armv8 mips-softfloat mipsle-hardfloat mipsle-softfloat)
|
|
|
|
for((i=0;i<7;i++));do
|
|
|
|
chmod +x $dir/sing-box-linux-${new_name[i]}
|
|
|
|
if [ "${archs[i]}" != "armv5" ];then
|
|
|
|
if [[ ${archs[i]} = mips* ]];then
|
|
|
|
./upx-3.93-amd64_linux/upx $dir/sing-box-linux-${new_name[i]}
|
|
|
|
else
|
|
|
|
./upx-3.96-amd64_linux/upx $dir/sing-box-linux-${new_name[i]}
|
|
|
|
fi
|
2024-01-04 20:07:11 +08:00
|
|
|
fi
|
2024-01-12 20:02:41 +08:00
|
|
|
done
|
|
|
|
rm -fr upx*
|
|
|
|
- name: Update
|
|
|
|
run: |
|
|
|
|
mkdir -p ./bin/singbox
|
|
|
|
rm -fr ./bin/singbox/*
|
|
|
|
mv -f $dir/sing-box-linux-* ./bin/singbox/
|
|
|
|
rm -fr ./tmp
|
|
|
|
sed -i "s/singbox_v=.*/singbox_v=$(./bin/singbox/singbox-linux-amd64 version 2>/dev/null | grep -Eo 'version .*' | sed 's/version //')/" bin/version
|
|
|
|
- name: Commit and push
|
|
|
|
run: |
|
|
|
|
git config --global user.email "juewuy@gmail.com" && git config --global user.name "Bot"
|
|
|
|
git add . && git commit -m "更新sing-box内核至${download_version}" || exit 0
|
|
|
|
git push
|
|
|
|
- name: Cleanup Workflow
|
|
|
|
uses: Mattraks/delete-workflow-runs@main
|
|
|
|
with:
|
|
|
|
retain_days: 1
|
|
|
|
keep_minimum_runs: 2
|
|
|
|
- name: Upload artifact
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: sing-box-${{ matrix.name }}
|
|
|
|
path: sing-box*
|