Skip to content

Commit

Permalink
derive version num from git tag
Browse files Browse the repository at this point in the history
  • Loading branch information
stanaka committed May 24, 2016
1 parent 7f263d6 commit 3d5ef98
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 8 additions & 2 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
echo on

FOR /F "usebackq" %%w IN (`git rev-parse --short HEAD`) DO SET COMMIT=%%w

FOR /F "usebackq" %%w IN (`git describe --tags --abbrev^=0`) DO SET VERSION=%%w
FOR /F "usebackq" %%w IN (`git tag -l --sort=-version:refname "v*"`) DO (
IF NOT DEFINED VERSION (
SET VERSION=%%w
)
)

set VERSION=%VERSION:v=%

echo %VERSION%

go build -o build/mackerel-agent.exe -ldflags="-X github.com/mackerelio/mackerel-agent/version.GITCOMMIT %COMMIT% -X github.com/mackerelio/mackerel-agent/version.VERSION %VERSION% " github.com/mackerelio/mackerel-agent
go build -o build/mackerel-agent.exe -ldflags="-X github.com/mackerelio/mackerel-agent/version.GITCOMMIT %COMMIT% -X github.com/mackerelio/mackerel-agent/version.VERSION %VERSION% " github.com/mackerelio/mackerel-agent
6 changes: 5 additions & 1 deletion wix/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ go build -o ..\build\wrapper.exe wrapper\wrapper_windows.go
go build -o ..\build\replace.exe replace\replace_windows.go

REM retrieve numeric version from git tag
FOR /F "usebackq" %%w IN (`git describe --tags --abbrev^=0`) DO SET VERSION=%%w
FOR /F "usebackq" %%w IN (`git tag -l --sort=-version:refname "v*"`) DO (
IF NOT DEFINED VERSION (
SET VERSION=%%w
)
)
set VERSION=%VERSION:v=%
FOR /F "tokens=1 delims=-+" %%w IN ('ECHO %%VERSION%%') DO SET VERSION=%%w
IF "%VERSION%"=="staging" (
Expand Down

0 comments on commit 3d5ef98

Please sign in to comment.