diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 827ebcb..f29d206 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -95,10 +95,24 @@ jobs: fetch-depth: 1 - name: Setup Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version: ${{needs.go.outputs.version}} - + - name: Set variables + run: | + VERSION="${GITHUB_REF_NAME,,}-$(git rev-parse --short HEAD)" + VERSION="${VERSION//\//-}" + PackageVersion="$(curl -s "https://api.github.com/repos/MetaCubeX/mihomo/releases/latest" | jq -r '.tag_name' | sed 's/v//g' | awk -F '.' '{$NF = $NF + 1; print}' OFS='.').${VERSION/-/.}" + if [ -n "${{ github.event.inputs.version }}" ]; then + VERSION=${{ github.event.inputs.version }} + PackageVersion="${VERSION#v}" + fi + echo "VERSION=${VERSION}" >> $GITHUB_ENV + echo "PackageVersion=${PackageVersion}" >> $GITHUB_ENV + echo "BUILDTIME=$(date)" >> $GITHUB_ENV + echo "CGO_ENABLED=0" >> $GITHUB_ENV + echo "BUILDTAG=-extldflags --static" >> $GITHUB_ENV + echo "GOTOOLCHAIN=local" >> $GITHUB_ENV - name: Set ENV run: | sudo timedatectl set-timezone "Asia/Shanghai" @@ -114,8 +128,9 @@ jobs: - name: build core id: build - run: go build -v -trimpath -ldflags "-X 'github.com/metacubex/mihomo/constant.Version=${VERSION}' -X 'github.com/metacubex/mihomo/constant.BuildTime=${BUILDTIME}' -s -w -buildid=" -tags "${TAGS}" -o meta - + run: | + go env + go build -v -tags "with_gvisor" -trimpath -ldflags "${BUILDTAG} -X 'github.com/metacubex/mihomo/constant.Version=${VERSION}' -X 'github.com/metacubex/mihomo/constant.BuildTime=${BUILDTIME}' -w -s -buildid=" - name: Upload file to workspace uses: actions/upload-artifact@v4 with: