Skip to content

Commit ffcd086

Browse files
committed
add more os1
1 parent cc05505 commit ffcd086

File tree

3 files changed

+80
-10
lines changed

3 files changed

+80
-10
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ jobs:
3737
echo "version=${{ inputs.version }}" >> "$GITHUB_ENV"
3838
3939
- name: Check input version
40-
if: ${{ inputs.tag-name }} != "draft"
40+
if: github.event_name != 'workflow_dispatch' && "${{ inputs.tag-name }}" != "draft"
4141
run: |-
4242
echo "version=${{ inputs.tag-name }}"
4343
echo "version=${{ inputs.tag-name }}" >> "$GITHUB_ENV"
4444
4545
- name: Calculate version
46-
if: github.event_name != 'workflow_dispatch' && ${{ inputs.version }} == "draft"
46+
if: github.event_name != 'workflow_dispatch' && "${{ inputs.tag-name }}" == "draft"
4747
run: |-
48-
echo "version=$$(git describe --tags)" >> "$GITHUB_ENV"
48+
echo "version=$(git describe --tags)" >> "$GITHUB_ENV"
4949
- name: Set outputs
5050
id: outputs
5151
run: |-
@@ -197,6 +197,8 @@ jobs:
197197
runs-on: ubuntu-latest
198198
needs:
199199
- calculate_version
200+
201+
200202
strategy:
201203
fail-fast: false
202204
matrix:
@@ -281,7 +283,7 @@ jobs:
281283
if: matrix.naive
282284
run: |
283285
set -xeuo pipefail
284-
CRONET_GO_VERSION=$(cat .github/CRONET_GO_VERSION)
286+
CRONET_GO_VERSION=$(cat hiddify-sing-box/.github/CRONET_GO_VERSION)
285287
git init ~/cronet-go
286288
git -C ~/cronet-go remote add origin https://github.com/sagernet/cronet-go.git
287289
git -C ~/cronet-go fetch --depth=1 origin "$CRONET_GO_VERSION"
@@ -295,7 +297,7 @@ jobs:
295297
path: |
296298
~/cronet-go/naiveproxy/src/third_party/llvm-build/Release+Asserts
297299
~/cronet-go/naiveproxy/src/out/sysroot-build
298-
key: chromium-toolchain-${{ matrix.arch }}-${{ matrix.variant }}-${{ hashFiles('.github/CRONET_GO_VERSION') }}
300+
key: chromium-toolchain-${{ matrix.arch }}-${{ matrix.variant }}-${{ hashFiles('hiddify-sing-box/.github/CRONET_GO_VERSION') }}
299301
- name: Download Chromium toolchain
300302
if: matrix.naive
301303
run: |
@@ -339,7 +341,7 @@ jobs:
339341
set -xeuo pipefail
340342
mkdir -p dist
341343
go build -v -trimpath -o dist/hiddify-core -tags "${BUILD_TAGS}" \
342-
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
344+
-ldflags '-s -buildid= -X github.com/hiddify/hiddify-core/v2/hcommon/constants.Version${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
343345
./cmd/
344346
env:
345347
CGO_ENABLED: "0"
@@ -361,7 +363,7 @@ jobs:
361363
set -xeuo pipefail
362364
mkdir -p dist
363365
go build -v -trimpath -o dist/hiddify-core -tags "${BUILD_TAGS}" \
364-
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
366+
-ldflags '-s -buildid= -X github.com/hiddify/hiddify-core/v2/hcommon/constants.Version${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
365367
./cmd/
366368
env:
367369
CGO_ENABLED: "1"
@@ -376,7 +378,7 @@ jobs:
376378
set -xeuo pipefail
377379
mkdir -p dist
378380
go build -v -trimpath -o dist/hiddify-core -tags "${BUILD_TAGS}" \
379-
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
381+
-ldflags '-s -buildid= -X github.com/hiddify/hiddify-core/v2/hcommon/constants.Version${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
380382
./cmd/
381383
env:
382384
CGO_ENABLED: "1"
@@ -391,7 +393,7 @@ jobs:
391393
set -xeuo pipefail
392394
mkdir -p dist
393395
go build -v -trimpath -o dist/hiddify-core -tags "${BUILD_TAGS}" \
394-
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
396+
-ldflags '-s -buildid= -X github.com/hiddify/hiddify-core/v2/hcommon/constants.Version${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
395397
./cmd/
396398
env:
397399
CGO_ENABLED: "0"
@@ -411,7 +413,7 @@ jobs:
411413
export CXX="${CC}++"
412414
mkdir -p dist
413415
GOOS=$BUILD_GOOS GOARCH=$BUILD_GOARCH build go build -v -trimpath -o dist/hiddify-core -tags "${BUILD_TAGS}" \
414-
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
416+
-ldflags '-s -buildid= -X github.com/hiddify/hiddify-core/v2/hcommon/constants.Version${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
415417
./cmd/
416418
env:
417419
CGO_ENABLED: "1"

cmd/cmd_version.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package cmd
2+
3+
import (
4+
"os"
5+
"runtime"
6+
"runtime/debug"
7+
8+
HC "github.com/hiddify/hiddify-core/v2/hcommon/constants"
9+
C "github.com/sagernet/sing-box/constant"
10+
11+
"github.com/spf13/cobra"
12+
)
13+
14+
var commandVersion = &cobra.Command{
15+
Use: "version",
16+
Short: "Print current version of hiddify-core",
17+
Run: printVersion,
18+
Args: cobra.NoArgs,
19+
}
20+
21+
var nameOnly bool
22+
23+
func init() {
24+
commandVersion.Flags().BoolVarP(&nameOnly, "name", "n", false, "print version name only")
25+
mainCommand.AddCommand(commandVersion)
26+
}
27+
28+
func printVersion(cmd *cobra.Command, args []string) {
29+
if nameOnly {
30+
os.Stdout.WriteString(C.Version + "\n")
31+
return
32+
}
33+
version := "hiddify-core version " + HC.Version + " hiddify-sing-box version " + C.Version + "\n\n"
34+
version += "Environment: " + runtime.Version() + " " + runtime.GOOS + "/" + runtime.GOARCH + "\n"
35+
36+
var tags string
37+
var revision string
38+
39+
debugInfo, loaded := debug.ReadBuildInfo()
40+
if loaded {
41+
for _, setting := range debugInfo.Settings {
42+
switch setting.Key {
43+
case "-tags":
44+
tags = setting.Value
45+
case "vcs.revision":
46+
revision = setting.Value
47+
}
48+
}
49+
}
50+
51+
if tags != "" {
52+
version += "Tags: " + tags + "\n"
53+
}
54+
if revision != "" {
55+
version += "Revision: " + revision + "\n"
56+
}
57+
58+
if C.CGO_ENABLED {
59+
version += "CGO: enabled\n"
60+
} else {
61+
version += "CGO: disabled\n"
62+
}
63+
64+
os.Stdout.WriteString(version)
65+
}

v2/hcommon/constants/version.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package constants
2+
3+
var Version = "unknown"

0 commit comments

Comments
 (0)