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-28 22:24:53 +08:00
tag1 :
description : 'project name of sing-box, such as SagerNet/sing-box'
2024-01-08 21:28:03 +08:00
required : true
type : string
2024-01-28 22:24:53 +08:00
tag2 :
description : 'version of sing-box, such as v1.7.8'
required : true
type : string
tag3 :
2024-01-30 18:47:02 +08:00
description : 'a new prerelease name (such as singbox_core_178) or only upload-artifact'
required : false
type : string
tag4 :
description : 'git push as crashcore (such as singbox or singboxp) or only upload-artifact'
required : false
type : string
tag5 :
2024-01-28 22:24:53 +08:00
description : 'build tags'
required : false
type : string
2024-03-23 15:39:35 +08:00
workflow_call :
inputs :
tag1 :
required : true
type : string
tag2 :
required : true
type : string
tag3 :
required : false
type : string
tag4 :
required : false
type : string
tag5 :
required : false
type : string
2024-01-04 20:07:11 +08:00
jobs :
2024-01-28 22:24:53 +08:00
go :
runs-on : ubuntu-latest
outputs :
version : ${{steps.go.outputs.version}}
steps :
- name : get latest go version
id : go
run : |
echo version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/update-versions-manifest-file/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
sing-box :
runs-on : ubuntu-latest
needs : go
env :
2024-03-23 16:04:43 +08:00
REPO : ${{ inputs.tag1 }}
TAGS : ${{ inputs.tag5 }}
2024-01-28 22:24:53 +08:00
outputs :
version : ${{steps.sing-box.outputs.version}}
tags : ${{steps.sing-box.outputs.tags}}
steps :
- uses : actions/checkout@v4.1.1
with :
2024-03-23 16:04:43 +08:00
repository : ${{ inputs.tag1 }}
ref : ${{ inputs.tag2 }}
2024-01-28 22:24:53 +08:00
fetch-depth : 0
- name : setup go
2024-03-19 09:19:09 +08:00
uses : actions/setup-go@v5.0.0
2024-01-28 22:24:53 +08:00
with :
go-version : ${{needs.go.outputs.version}}
- name : get sing-box version
id : sing-box
run : |
git remote add sekai https://github.com/SagerNet/sing-box.git
git fetch --tags sekai
version=$(CGO_ENABLED=0 go run ./cmd/internal/read_tag)
2024-03-23 16:04:43 +08:00
[ -z "$version" ] && version=${{ inputs.tag2 }}
2024-01-28 22:24:53 +08:00
echo version=$version >> $GITHUB_OUTPUT
if [ -z "$TAGS" ];then
if [ "$REPO" = 'PuerNya/sing-box' ];then
echo tags=with_quic,with_shadowsocksr,with_ech,with_utls,with_reality_server,with_clash_api >> $GITHUB_OUTPUT
else
echo tags=with_quic,with_ech,with_utls,with_reality_server,with_clash_api >> $GITHUB_OUTPUT
fi
else
echo tags=$TAGS >> $GITHUB_OUTPUT
fi
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-02-08 11:41:25 +08:00
needs :
- go
- sing-box
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
2024-03-23 16:04:43 +08:00
REPO : ${{ inputs.tag1 }}
2024-01-28 22:24:53 +08:00
TAGS : ${{needs.sing-box.outputs.tags}}
VERSION : ${{needs.sing-box.outputs.version}}
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 :
2024-03-23 16:04:43 +08:00
repository : ${{ inputs.tag1 }}
ref : ${{ inputs.tag2 }}
2024-01-28 22:24:53 +08:00
fetch-depth : 1
2024-01-12 20:02:41 +08:00
- name : Setup Go
uses : actions/setup-go@v5
with :
2024-02-08 11:41:25 +08:00
go-version : ${{needs.go.outputs.version}}
2024-01-28 22:24:53 +08:00
2024-02-07 08:00:53 +08:00
- name : checkout sing repository
if : ${{ env.REPO == 'PuerNya/sing-box' }}
uses : actions/checkout@v4.1.1
with :
2024-03-19 09:19:09 +08:00
ref : building
2024-02-07 08:00:53 +08:00
path : sing
repository : PuerNya/sing
2024-01-28 22:24:53 +08:00
- name : build core
2024-01-12 20:02:41 +08:00
id : build
2024-01-28 22:24:53 +08:00
run : go build -v -trimpath -ldflags "-X 'github.com/sagernet/sing-box/constant.Version=${VERSION}' -s -w -buildid=" -tags "${TAGS}" ./cmd/sing-box
2024-01-12 20:02:41 +08:00
- name : Upload file to workspace
uses : actions/upload-artifact@v4
with :
2024-01-12 20:16:19 +08:00
name : ${{ matrix.name }}
path : sing-box
2024-01-28 22:24:53 +08:00
2024-01-30 18:47:02 +08:00
push_to_git :
2024-01-28 22:24:53 +08:00
needs :
- cross
- sing-box
2024-01-12 20:02:41 +08:00
runs-on : ubuntu-latest
2024-01-28 22:24:53 +08:00
env :
2024-03-23 16:04:43 +08:00
RELEASE : ${{ inputs.tag3 }}
PUSHDIR : ${{ inputs.tag4 }}
2024-01-28 22:24:53 +08:00
VERSION : ${{needs.sing-box.outputs.version}}
2024-01-12 20:02:41 +08:00
steps :
- name : Checkout ShellCrash
uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with :
repository : juewuy/ShellCrash
2024-01-28 22:24:53 +08:00
fetch-depth : 1
2024-01-12 20:02:41 +08:00
- name : Download file from workspace
uses : actions/download-artifact@v4
with :
path : ./tmp
2024-01-28 22:24:53 +08:00
- name : Zip core by tar
2024-01-12 20:02:41 +08:00
run : |
2024-01-28 22:24:53 +08:00
for arch in amd64 armv5 armv7 arm64 mips-softfloat mipsel-hardfloat mipsel-softfloat;do
mv -f ./tmp/linux-${arch}/sing-box ./tmp/CrashCore
chmod +x ./tmp/CrashCore
tar --no-same-owner -zcvf ./tmp/singbox-linux-${arch}.tar.gz -C ./tmp CrashCore
2024-01-12 20:02:41 +08:00
done
2024-02-04 09:08:55 +08:00
mv -f ./tmp/singbox-linux-mipsel-hardfloat.tar.gz ./tmp/singbox-linux-mipsle-hardfloat.tar.gz
mv -f ./tmp/singbox-linux-mipsel-softfloat.tar.gz ./tmp/singbox-linux-mipsle-softfloat.tar.gz
2024-03-30 12:39:48 +08:00
echo ${VERSION} > ./tmp/version
2024-01-28 22:24:53 +08:00
2024-01-12 20:02:41 +08:00
- name : Commit and push
2024-01-30 19:15:24 +08:00
if : ${{ env.PUSHDIR != '' }}
2024-01-12 20:02:41 +08:00
run : |
2024-03-23 16:04:43 +08:00
[ "${{ inputs.tag1 }}" = SagerNet/sing-box ] && crashcore='singbox'
[ "${{ inputs.tag1 }}" = PuerNya/sing-box ] && crashcore='singboxp'
2024-01-28 22:24:53 +08:00
mkdir -p ./bin/${crashcore}
rm -fr ./bin/${crashcore}/*
mv -f ./tmp/singbox-linux-*.tar.gz ./bin/${crashcore}/
rm -fr ./tmp
sed -i "s/${crashcore}_v=.*/${crashcore}_v=${VERSION}/" ./bin/version
2024-04-16 01:42:39 +08:00
git config --global user.email "github-actions[bot]@users.noreply.github.com" && git config --global user.name "github-actions[bot]"
2024-01-28 22:24:53 +08:00
git add . && git commit -m "更新${crashcore}内核至${VERSION}" || exit 0
2024-01-12 20:02:41 +08:00
git push
2024-01-28 22:24:53 +08:00
2024-01-30 18:47:02 +08:00
- name : Create Release and Upload Release Asset
if : ${{ env.RELEASE != '' && env.PUSHDIR == '' }}
uses : softprops/action-gh-release@v1
with :
2024-03-23 16:04:43 +08:00
tag_name : ${{ inputs.tag3 }}
name : ${{ inputs.tag3 }}
body : "The ${{env.VERSION}} version of ${{ inputs.tag1 }} \n这是${{ inputs.tag1 }}的${{env.VERSION}}版本内核文件\nhttps://github.com/${{ inputs.tag1 }}/releases \nOnly support for ShellCrash\n仅适配ShellCrash项目"
2024-01-30 18:47:02 +08:00
draft : false
prerelease : true
files : |
./tmp/singbox*.tar.gz
2024-03-30 12:39:48 +08:00
./tmp/version
2024-01-30 18:47:02 +08:00
2024-01-12 20:02:41 +08:00
- name : Cleanup Workflow
uses : Mattraks/delete-workflow-runs@main
with :
retain_days : 1
keep_minimum_runs : 2