diff --git a/.github/workflows/update_singbox_core_test.yaml b/.github/workflows/update_singbox_core_test.yaml index 000ca59..f2407c3 100644 --- a/.github/workflows/update_singbox_core_test.yaml +++ b/.github/workflows/update_singbox_core_test.yaml @@ -12,10 +12,59 @@ on: required: true type: string tag3: - description: 'a new prerelease name or not,such as _PuerNya' + description: 'a new prerelease name or not' + required: false + type: string + tag4: + description: 'build tags' required: false type: string jobs: + 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: + REPO: ${{ github.event.inputs.tag1 }} + TAGS: ${{ github.event.inputs.tag4 }} + outputs: + version: ${{steps.sing-box.outputs.version}} + tags: ${{steps.sing-box.outputs.tags}} + steps: + - uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + + - name: setup go + uses: actions/setup-go@v4.1.0 + 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) + echo version=$version >> $GITHUB_OUTPUT + if [ -z "$TAGS" ];then + if [ "$REPO" = 'SagerNet/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 cross: strategy: matrix: @@ -54,6 +103,7 @@ jobs: fail-fast: false runs-on: ubuntu-latest + needs: sing-box env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} @@ -61,7 +111,8 @@ jobs: 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 + TAGS: ${{needs.sing-box.outputs.tags}} + VERSION: ${{needs.sing-box.outputs.version}} steps: - name: Checkout sing-box uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 @@ -69,22 +120,22 @@ jobs: 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 + go-version: ${{ steps.go.outputs.version }} + + - name: build core id: build - run: make + run: go build -v -trimpath -ldflags "-X 'github.com/sagernet/sing-box/constant.Version=${VERSION}' -s -w -buildid=" -tags "${TAGS}" ./cmd/sing-box + - 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 @@ -95,10 +146,12 @@ jobs: 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) @@ -116,19 +169,18 @@ jobs: done rm -fr upx* rm -fr ./tmp/core.tar.gz - version=$(./bin/singbox/singbox-linux-amd64 version 2>/dev/null | grep version | awk '{print $3}') - echo $version > ./tmp/version - echo "version=${version}" >> ${GITHUB_ENV} + - name: Create Release and Upload Release Asset uses: softprops/action-gh-release@v1 with: tag_name: singbox_core${{ github.event.inputs.tag3 }} name: singbox_core${{ github.event.inputs.tag3 }} - body: "The ${version} version of ${{ github.event.inputs.tag1 }} \n这是${{ github.event.inputs.tag1 }}的${version}版本内核文件\nhttps://github.com/${{ github.event.inputs.tag1 }}/releases \nZip by upx\n使用了upx进行压缩\nOnly support for ShellCrash\n仅限于ShellCrash项目使用" + body: "The ${{steps.sing-box.outputs.version}} version of ${{ github.event.inputs.tag1 }} \n这是${{ github.event.inputs.tag1 }}的${{steps.sing-box.outputs.version}}版本内核文件\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: