From 0e316335f3508cfa1e07ac716bb33bc61cf71593 Mon Sep 17 00:00:00 2001 From: juewuy Date: Sun, 21 Jan 2024 19:41:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0singbox=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=89=88actions=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/update_singbox_core_test.yaml | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 .github/workflows/update_singbox_core_test.yaml diff --git a/.github/workflows/update_singbox_core_test.yaml b/.github/workflows/update_singbox_core_test.yaml new file mode 100644 index 0000000..c7dccc6 --- /dev/null +++ b/.github/workflows/update_singbox_core_test.yaml @@ -0,0 +1,128 @@ +name: Build Sing-Box Core for ShellCrash + +on: + workflow_dispatch: + inputs: + tag1: + description: 'project name of sing-box, such as SagerNet/sing-box' + required: true + type: string + tag2: + description: 'tag of sing-box, such as v1.7.8' + required: true + type: string +jobs: + 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: ${{ github.event.inputs.tag1 }} + ref: ${{ github.event.inputs.tag2 }} + 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: Upload file to workspace + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.name }} + path: sing-box + push_prerelease: + needs: cross + runs-on: ubuntu-latest + steps: + - 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: | + archs=(amd64 armv5 armv7 arm64 mips-softfloat mipsel-hardfloat mipsel-softfloat) + new_name=(amd64 armv5 armv7 armv8 mips-softfloat mipsle-hardfloat mipsle-softfloat) + for((i=0;i<7;i++));do + mv -f ./tmp/linux-${archs[i]}/sing-box ./tmp/singbox-linux-${new_name[i]} + chmod +x ./tmp/singbox-linux-${new_name[i]} + if [ "${archs[i]}" != "armv5" ];then + if [[ ${archs[i]} = mips* ]];then + ./upx-3.93-amd64_linux/upx ./tmp/singbox-linux-${new_name[i]} + else + ./upx-3.96-amd64_linux/upx ./tmp/singbox-linux-${new_name[i]} + fi + fi + done + rm -fr upx* + - name: Create Release and Upload Release Asset + uses: softprops/action-gh-release@v1 + with: + tag_name: singbox_core + name: singbox_core + body: "The alpha version of singbox core \n这是${{ github.event.inputs.tag1 }}的${{ github.event.inputs.tag2 }}版本内核文件\nhttps://github.com/${{ github.event.inputs.tag1 }}/releases \nZip by upx\n使用了upx进行压缩\nOnly support for ShellCrash\n仅限于ShellCrash项目使用" + draft: false + prerelease: true + files: | + ./tmp/* + - name: Cleanup Workflow + uses: Mattraks/delete-workflow-runs@main + with: + retain_days: 1 + keep_minimum_runs: 2