Skip to content

Commit 8055898

Browse files
committed
Add version support
1 parent 64240ea commit 8055898

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ jobs:
7171
run: |
7272
ext=""
7373
if [ "$GOOS" = "windows" ]; then ext=".exe"; fi
74-
go build -o ${BINARY_NAME}-${GOOS}-${GOARCH}${ext} ./cmd/server/
74+
VERSION="${GITHUB_SHA::7}"
75+
go build -ldflags "-X main.version=${VERSION}" -o ${BINARY_NAME}-${GOOS}-${GOARCH}${ext} ./cmd/server/
7576
7677
- uses: actions/upload-artifact@v4
7778
with:

cmd/server/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@ import (
2121
"github.com/mockzilla/connexions/v2/pkg/loader"
2222
)
2323

24+
var version = "dev"
25+
2426
func main() {
27+
if len(os.Args) == 2 && (os.Args[1] == "--version" || os.Args[1] == "-v") {
28+
fmt.Println(version)
29+
return
30+
}
31+
2532
appDir := getAppDir()
2633
_ = godotenv.Load(fmt.Sprintf("%s/.env", appDir), fmt.Sprintf("%s/.env.dist", appDir))
2734

0 commit comments

Comments
 (0)