Skip to content

Commit e038bbd

Browse files
authored
Merge pull request #665 from pavelpikta/fix/build-and-release-version
fix(ci): set version dynamically from git tag in build process
2 parents ea889fe + 962b797 commit e038bbd

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

.github/workflows/ts_release.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ jobs:
2828
go-version: ${{ matrix.go_version }}
2929
cache: true
3030

31+
- name: Set version from tag
32+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
33+
3134
- name: Install Swag
3235
run: go install github.com/swaggo/swag/cmd/swag@latest
3336

@@ -40,7 +43,7 @@ jobs:
4043
- name: Build Standard Platforms
4144
if: matrix.group == 'standard'
4245
run: |
43-
LDFLAGS="-s -w -checklinkname=0"
46+
LDFLAGS="-s -w -checklinkname=0 -X server/version.Version=${{ env.VERSION }}"
4447
mkdir -p "${{ github.workspace }}/dist"
4548
cd server
4649
@@ -75,7 +78,7 @@ jobs:
7578
run: |
7679
go run gen_web.go
7780
78-
LDFLAGS="-s -w -checklinkname=0"
81+
LDFLAGS="-s -w -checklinkname=0 -X server/version.Version=${{ env.VERSION }}"
7982
mkdir -p "${{ github.workspace }}/dist"
8083
export NDK_TOOLCHAIN="$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64"
8184
cd server

server/version/version.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import (
55
"runtime/debug"
66
)
77

8-
const Version = "MatriX.140"
8+
// Version is set at build time via -ldflags "-X server/version.Version=<tag>"
9+
var Version = "MatriX.140"
910

1011
func GetTorrentVersion() string {
1112
bi, ok := debug.ReadBuildInfo()

0 commit comments

Comments
 (0)