86 lines
2.4 KiB
Batchfile
86 lines
2.4 KiB
Batchfile
REM @echo off
|
|
setlocal enabledelayedexpansion
|
|
|
|
REM Leer usuario y contraseña del archivo SECRETS
|
|
REM (deben ser líneas con formato REG_USER=xxx y REG_PASSWORD=xxx, sin espacios)
|
|
for /f "usebackq tokens=1,2 delims==" %%A in ("SECRETS") do (
|
|
if /I "%%A"=="REG_USER" set "REG_USER=%%B"
|
|
if /I "%%A"=="REG_PASSWORD" set "REG_PASSWORD=%%B"
|
|
)
|
|
|
|
REM Leer la versión del archivo VERSION
|
|
REM (asumimos que la primera línea tiene la versión, p.ej. 1.0)
|
|
for /f "usebackq tokens=* delims=" %%V in ("VERSION") do (
|
|
set "VERSION=%%V"
|
|
goto :GotVersion
|
|
)
|
|
|
|
:GotVersion
|
|
|
|
REM Verificar que los valores estén cargados
|
|
if not defined REG_USER (
|
|
echo Error: REG_USER no encontrado en SECRETS.
|
|
exit /b 1
|
|
)
|
|
|
|
if not defined REG_PASSWORD (
|
|
echo Error: REG_PASSWORD no encontrado en SECRETS.
|
|
exit /b 1
|
|
)
|
|
|
|
if not defined VERSION (
|
|
echo Error: VERSION no encontrado o vacío en VERSION.
|
|
exit /b 1
|
|
)
|
|
|
|
REM Login en el registro Docker
|
|
echo Realizando login en dockyard.spark-ops.com...
|
|
echo !REG_PASSWORD! | docker login dockyard.spark-ops.com --username !REG_USER! --password-stdin
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Error: Falló el login en el registro Docker.
|
|
exit /b 1
|
|
)
|
|
|
|
REM Construir la imagen Docker
|
|
echo Construyendo la imagen Docker launchsim:!VERSION!...
|
|
docker build -t launchsim:!VERSION! .
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Error: Falló la construcción de la imagen Docker.
|
|
exit /b 1
|
|
)
|
|
|
|
REM Etiquetar la imagen con la versión
|
|
echo Etiquetando la imagen para el registro...
|
|
docker tag launchsim:!VERSION! dockyard.spark-ops.com/launchsim/launchsim:!VERSION!
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Error: Falló al etiquetar la imagen Docker.
|
|
exit /b 1
|
|
)
|
|
|
|
REM Etiquetar la imagen como latest
|
|
echo Etiquetando la imagen como latest...
|
|
docker tag launchsim:!VERSION! dockyard.spark-ops.com/launchsim/launchsim:latest
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Error: Falló al etiquetar la imagen como latest.
|
|
exit /b 1
|
|
)
|
|
|
|
REM Subir la imagen con la versión
|
|
echo Subiendo la imagen al registro con la versión !VERSION!...
|
|
docker push dockyard.spark-ops.com/launchsim/launchsim:!VERSION!
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Error: Falló al subir la imagen con la versión.
|
|
exit /b 1
|
|
)
|
|
|
|
REM Subir la imagen como latest
|
|
echo Subiendo la imagen como latest al registro...
|
|
docker push dockyard.spark-ops.com/launchsim/launchsim:latest
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Error: Falló al subir la imagen como latest.
|
|
exit /b 1
|
|
)
|
|
|
|
echo Proceso completado exitosamente.
|
|
endlocal
|