setup_ci.bat 1.66 KB
Newer Older
1
2
3
4
5
6
@echo off

cd "%MDANSE_SOURCE_DIR%"

rem To understand this syntax "set cmd=...... for /F %%ii ......", see https://stackoverflow.com/questions/2323292/assign-output-of-a-program-to-a-variable

7
rem Update the __pkginfo__ file with the current commit
8
echo "Commit id %MDANSE_GIT_CURRENT_COMMIT%"
9
echo "Branch name %MDANSE_GIT_BRANCH_NAME%"
10
11
12
13
rem sed -i unfortunately creates backup file, see https://stackoverflow.com/questions/1823591/sed-creates-un-deleteable-files-in-windows
rem so we do not use the -i option
sed "s/.*__commit__.*/__commit__ = \"%MDANSE_GIT_CURRENT_COMMIT%\"/" Src\\__pkginfo__.py >> Src\\__pkginfo__.pybak
move Src\\__pkginfo__.pybak Src\\__pkginfo__.py
14
15

rem Get MDANSE version
16
set cmd="sed -n "s/__version__.*=.*\"\(.*\)\"/\1/p" Src/__pkginfo__.py"
17
18
19
for /F %%i in (' %cmd% ') do set MDANSE_VERSION=%%i

rem Check if branch is master, tag as draft otherwise
20
if "%MDANSE_GIT_BRANCH_NAME%" == "master" (
21
    set VERSION_NAME=%MDANSE_VERSION%
22
23
    sed "s/.*__beta__.*/__beta__ = None/" Src\\__pkginfo__.py >> Src\\__pkginfo__.pybak
    move Src\\__pkginfo__.pybak Src\\__pkginfo__.py
24
) else (
25
    rem Check if branch is release*
26
    if "%MDANSE_GIT_BRANCH_NAME:~0,7%" == "release" (
27
        set VERSION_NAME=%MDANSE_VERSION%-rc-%MDANSE_GIT_CURRENT_COMMIT%
28
29
        sed "s/.*__beta__.*/__beta__ = \"rc\"/" Src\\__pkginfo__.py >> Src\\__pkginfo__.pybak
        move Src\\__pkginfo__.pybak Src\\__pkginfo__.py
30
31
    ) else (
        set VERSION_NAME=%MDANSE_VERSION%-beta-%MDANSE_GIT_CURRENT_COMMIT%
32
33
        sed "s/.*__beta__.*/__beta__ = \"beta\"/" Src\\__pkginfo__.py >> Src\\__pkginfo__.pybak
        move Src\\__pkginfo__.pybak Src\\__pkginfo__.py
34
    )
Remi Perenon's avatar
Remi Perenon committed
35
)