-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconda_build.cmd
More file actions
43 lines (36 loc) · 1.24 KB
/
conda_build.cmd
File metadata and controls
43 lines (36 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@echo off
REM This script helps build conda package with proper version extraction from git
REM Get the git describe tag (e.g. v0.4.0)
FOR /F "tokens=*" %%g IN ('git describe --tags --abbrev^=0 2^>nul') DO (
SET GIT_DESCRIBE_TAG=%%g
)
REM Get the commit hash for all builds
FOR /F "tokens=*" %%h IN ('git rev-parse HEAD') DO (
SET GIT_FULL_HASH=%%h
)
SET SHORT_HASH=%GIT_FULL_HASH:~0,7%
REM Generate a date-based version component (YYYYMMDD)
FOR /F "tokens=2-4 delims=/ " %%a IN ('date /t') DO (
SET MONTH=%%a
SET DAY=%%b
SET YEAR=%%c
)
SET BUILD_DATE=%YEAR%%MONTH%%DAY%
REM Always use a version that includes commit info
IF "%GIT_DESCRIBE_TAG%"=="" (
REM No tag exists, use only commit hash
SET VERSION=0.0.0.dev%BUILD_DATE%+%SHORT_HASH%
echo No git tag found, using version: %VERSION%
) ELSE (
REM Remove 'v' prefix from tag for conda versioning
IF "%GIT_DESCRIBE_TAG:~0,1%"=="v" (
SET GIT_DESCRIBE_TAG=%GIT_DESCRIBE_TAG:~1%
)
REM Use tag + commit hash
SET VERSION=%GIT_DESCRIBE_TAG%.dev%BUILD_DATE%+%SHORT_HASH%
echo Using version: %VERSION%
)
REM Set the VERSION environment variable for conda-build to use
set VERSION=%VERSION%
REM Build the conda package
conda build conda.recipe/ %*