Skip to content

Commit c1102f7

Browse files
authored
Add version resource to Windows binaries (#59)
* Add file version for Windows binary * fix gopath * use gobin instead of gopath * update readme * templates cannot use variables * trying to debug path issue * still debugging path * use binariesdir for gobin * put go-winres in sources dir
1 parent fef1a31 commit c1102f7

File tree

5 files changed

+64
-3
lines changed

5 files changed

+64
-3
lines changed

Diff for: .gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
coverage.json
1818
coverage.txt
1919
coverage.xml
20-
testresults.xml
20+
testresults.xml
21+
22+
# .syso is generated by go-winres. Only needed for official builds
23+
*.syso

Diff for: README.md

+11
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ pkg/sqlcmd is consumable by other hosts. Go docs for the package are forthcoming
101101

102102
## Building
103103

104+
To add version data to your build using `go-winres`, add `GOBIN` to your `PATH` then use `go generate`
105+
The version on the binary will match the version tag of the branch.
106+
107+
```sh
108+
109+
go install https://github.com/tc-hib/go-winres
110+
cd cmd/sqlcmd
111+
go generate
112+
113+
```
114+
104115
Scripts to build the binaries and package them for release will be added in a build folder off the root. We will also add Azure Devops pipeline yml files there to initiate builds and releases. Until then just use `go build ./cmd/sqlcmd` to create a sqlcmd binary.
105116

106117
## Testing

Diff for: build/azure-pipelines/build-common.yml

+20-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ steps:
1212
- task: GoTool@0
1313
inputs:
1414
version: '1.16.5'
15+
goBin: $(Build.SourcesDirectory)
16+
17+
- task: Go@0
18+
displayName: 'Go install go-winres'
19+
inputs:
20+
command: 'custom'
21+
customCommand: 'install'
22+
arguments: 'github.com/tc-hib/go-winres@latest'
23+
workingDirectory: '$(Build.SourcesDirectory)/cmd/sqlcmd'
24+
env:
25+
GOBIN: $(Build.SourcesDirectory)
26+
27+
- task: CmdLine@2
28+
displayName: 'generate version resource'
29+
inputs:
30+
script: $(Build.SourcesDirectory)/go-winres make --file-version git-tag --product-version git-tag
31+
workingDirectory: '$(Build.SourcesDirectory)/cmd/sqlcmd'
1532

1633
- task: Go@0
1734
displayName: 'Go: get dependencies'
@@ -22,7 +39,8 @@ steps:
2239
env:
2340
GOOS: ${{ parameters.OS }}
2441
GOARCH: ${{ parameters.Arch }}
25-
42+
GOBIN: $(Build.SourcesDirectory)
43+
2644
- task: Go@0
2745
displayName: 'Go: build sqlcmd'
2846
inputs:
@@ -32,6 +50,7 @@ steps:
3250
env:
3351
GOOS: ${{ parameters.OS }}
3452
GOARCH: ${{ parameters.Arch }}
53+
GOBIN: $(Build.SourcesDirectory)
3554

3655
- task: CopyFiles@2
3756
inputs:

Diff for: cmd/sqlcmd/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
3-
3+
//go:generate go-winres make --file-version=git-tag --product-version=git-tag
44
package main
55

66
import (

Diff for: cmd/sqlcmd/winres/winres.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"RT_VERSION": {
3+
"#1": {
4+
"0000": {
5+
"fixed": {
6+
"file_version": "0.0.0.0",
7+
"product_version": "0.0.0.0"
8+
},
9+
"info": {
10+
"0409": {
11+
"Comments": "SQL",
12+
"CompanyName": "Microsoft Corporation",
13+
"FileDescription": "T-SQL execution command line utility",
14+
"FileVersion": "",
15+
"InternalName": "go-sqlcmd",
16+
"LegalCopyright": "Microsoft Corporation",
17+
"LegalTrademarks": "Microsoft SQL Server is a registered trademark of Microsoft Corporation",
18+
"OriginalFilename": "sqlcmd.exe",
19+
"PrivateBuild": "",
20+
"ProductName": "Microsoft SQL Server",
21+
"ProductVersion": "",
22+
"SpecialBuild": ""
23+
}
24+
}
25+
}
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)