Update update_singbox_core.yaml

改为直接从主干编译指定版本并上传到bin目录
This commit is contained in:
juewuy 2024-01-12 20:02:41 +08:00 committed by GitHub
parent b073c55d90
commit d07edc66dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,60 +1,138 @@
name: Update Sing-Box Core name: Build Sing-Box Core for ShellCrash
on:
on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
version: tag:
description: 'version of singbox, such as 1.7.8' description: 'tag of sing-box, such as v1.7.8'
required: true required: true
type: string type: string
env:
download_version: ${{ github.event.inputs.version }}
download_project: SagerNet/sing-box
jobs: jobs:
Update: 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
runs-on: ubuntu-latest
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
steps:
- 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 runs-on: ubuntu-latest
steps: steps:
- name: Clone Repository - name: Checkout ShellCrash
uses: actions/checkout@main uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Init Dependencies with:
run: | repository: juewuy/ShellCrash
wget https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz ref: dev
wget https://github.com/upx/upx/releases/download/v3.93/upx-3.93-amd64_linux.tar.xz - name: Get upx
tar xf upx-3.96-amd64_linux.tar.xz run: |
tar xf upx-3.93-amd64_linux.tar.xz wget https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz
- name: Download Core wget https://github.com/upx/upx/releases/download/v3.93/upx-3.93-amd64_linux.tar.xz
run: | tar xf upx-3.96-amd64_linux.tar.xz
#download_version=$(curl -s -L -o /dev/null -w '%{url_effective}' https://github.com/${download_project}/releases/latest | grep -oE "[^/]+$" | awk -F 'v' '{print $2}') tar xf upx-3.93-amd64_linux.tar.xz
echo "download_version=${download_version}" >> ${GITHUB_ENV} - name: Download file from workspace
archs=(386 amd64 armv7 arm64) uses: actions/download-artifact@v4
new_name=(386 amd64 armv7 armv8) with:
mkdir tmp path: ./tmp
for((i=0;i<4;i++));do - name: Zip core by upx
wget "https://github.com/${download_project}/releases/download/v${download_version}/sing-box-${download_version}-linux-${archs[i]}.tar.gz" -O ./tmp/core.tar.gz run: |
tar -zxvf ./tmp/core.tar.gz -C './tmp' dir=/home/runner/work/sing-box/sing-box/tmp/artifact
mv -f ./tmp/sing-box-${download_version}-linux-${archs[i]}/sing-box ./tmp/singbox-linux-${new_name[i]} archs=(amd64 armv5 armv7 arm64 mips-softfloat mipsle-hardfloat mipsle-softfloat)
chmod +x ./tmp/singbox-linux-${new_name[i]} new_name=(amd64 armv5 armv7 armv8 mips-softfloat mipsle-hardfloat mipsle-softfloat)
if [ "${archs[i]}" != "armv5" ];then for((i=0;i<7;i++));do
if [[ ${archs[i]} = mips* ]];then chmod +x $dir/sing-box-linux-${new_name[i]}
./upx-3.93-amd64_linux/upx ./tmp/singbox-linux-${new_name[i]} if [ "${archs[i]}" != "armv5" ];then
else if [[ ${archs[i]} = mips* ]];then
./upx-3.96-amd64_linux/upx ./tmp/singbox-linux-${new_name[i]} ./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
fi fi
fi done
done rm -fr upx*
rm -rf ./tmp/LICENSE - name: Update
rm -fr upx* run: |
- name: Create Release and Upload Release Asset mkdir -p ./bin/singbox
uses: softprops/action-gh-release@v1 rm -fr ./bin/singbox/*
with: mv -f $dir/sing-box-linux-* ./bin/singbox/
tag_name: singbox_core rm -fr ./tmp
name: singbox_core sed -i "s/singbox_v=.*/singbox_v=$(./bin/singbox/singbox-linux-amd64 version 2>/dev/null | grep -Eo 'version .*' | sed 's/version //')/" bin/version
body: "The alpha version of singbox core \n这是singbox的官方${{ github.event.inputs.version }}版本内核文件\nhttps://github.com/SagerNet/sing-box/releases \nZip by upx\n使用了upx进行压缩\nOnly support for ShellCrash\n仅限于ShellCrash项目使用" - name: Commit and push
draft: false run: |
prerelease: true git config --global user.email "juewuy@gmail.com" && git config --global user.name "Bot"
files: | git add . && git commit -m "更新sing-box内核至${download_version}" || exit 0
./tmp/* git push
- name: Cleanup Workflow - name: Cleanup Workflow
uses: Mattraks/delete-workflow-runs@main uses: Mattraks/delete-workflow-runs@main
with: with:
retain_days: 1 retain_days: 1
keep_minimum_runs: 2 keep_minimum_runs: 2
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: sing-box-${{ matrix.name }}
path: sing-box*