publish.bat 1.69 KB
Newer Older
peterjc123's avatar
peterjc123 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
@echo off

set SRC_DIR=%~dp0
pushd %SRC_DIR%

if NOT "%CUDA_VERSION%" == "cpu" (
    set PACKAGE_SUFFIX=_cuda%CUDA_VERSION%
) else (
    set PACKAGE_SUFFIX=
)

if "%PACKAGEFULLNAME%" == "Conda" (
    set PACKAGE=conda
) else (
    set PACKAGE=wheels
)

peterjc123's avatar
peterjc123 committed
18
19
20
21
22
if not defined PACKAGE_SUFFIX (
    set PUBLISH_BRANCH=vision_%PACKAGE%_%DESIRED_PYTHON%
) else (
    set PUBLISH_BRANCH=vision_%PACKAGE%_%DESIRED_PYTHON%%PACKAGE_SUFFIX%
)
peterjc123's avatar
peterjc123 committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

git clone %ARTIFACT_REPO_URL% -b %PUBLISH_BRANCH% --single-branch >nul 2>&1

IF ERRORLEVEL 1 (
    echo Branch %PUBLISH_BRANCH% not exist, falling back to master
    set NO_BRANCH=1
    git clone %ARTIFACT_REPO_URL% -b master --single-branch >nul 2>&1
)

IF ERRORLEVEL 1 (
    echo Clone failed
    goto err
)

cd pytorch_builder
attrib -s -h -r . /s /d

:: Empty repo
rd /s /q . || ver >nul

IF NOT EXIST %PACKAGE% mkdir %PACKAGE%

xcopy /S /E /Y ..\..\output\*.* %PACKAGE%\

git config --global user.name "Azure DevOps"
git config --global user.email peterghost86@gmail.com
git init
git checkout --orphan %PUBLISH_BRANCH%
git remote add origin %ARTIFACT_REPO_URL%
git add .
git commit -m "Update artifacts"

:push

if "%RETRY_TIMES%" == "" (
    set /a RETRY_TIMES=10
    set /a SLEEP_TIME=2
) else (
    set /a RETRY_TIMES=%RETRY_TIMES%-1
    set /a SLEEP_TIME=%SLEEP_TIME%*2
)

git push origin %PUBLISH_BRANCH% -f > nul 2>&1

IF ERRORLEVEL 1 (
    echo Git push retry times remaining: %RETRY_TIMES%
    echo Sleep time: %SLEEP_TIME% seconds
    IF %RETRY_TIMES% EQU 0 (
        echo Push failed
        goto err
    )
    waitfor SomethingThatIsNeverHappening /t %SLEEP_TIME% 2>nul || ver >nul
    goto push
) ELSE (
    set RETRY_TIMES=
    set SLEEP_TIME=
)

popd

exit /b 0

:err

popd

exit /b 1