Skip to content

Instantly share code, notes, and snippets.

@manavortex
Forked from haggen/package.bat
Last active June 11, 2019 11:32
Show Gist options
  • Save manavortex/68f3bfe57937346f68a40024532a0c29 to your computer and use it in GitHub Desktop.
Save manavortex/68f3bfe57937346f68a40024532a0c29 to your computer and use it in GitHub Desktop.
Package your ESO add-on ready for distribution.
:: Package your ESO add-on ready for distribution.
:: Version 1.3 Sat, 14 Nov 2015 22:36:23 +0000
@echo off
setlocal enableextensions enabledelayedexpansion
REM set to location where you want this zipped. Leave it empty if you want to zip to current dir.
set EXPORTPATH=%USERPROFILE%\Dropbox
REM delete zips of previous versions? Delete or clear if not
set DELETEOLDZIPS=true
REM open URL in browser after?
set PUBLISHURL=https://www.esoui.com
REM find 7z.exe
call :findzip
REM read name from *.TXT
call :findname
REM delete all zips of previous versions if flag is set
call :deleteoldfiles
for /F "tokens=3" %%i in ('findstr /C:"## Version:" %name%.txt') do set version=%%i
set archive=%name%-%version%.zip
REM for output
if not ""=="%EXPORTPATH%" set topath=%EXPORTPATH%\
echo * Packaging %topath%%archive%...
md .package\%name%
set files=%name%.txt
for /F %%i in ('findstr /B /R "[^#;]" %name%.txt') do (
set file=%%~nxi
set files=!files! !file:$^(language^)=*!
)
if exist package.manifest (
for /F "tokens=*" %%i in (package.manifest) do (
set files=!files! %%~nxi
)
)
robocopy . .package\%name% %files% /S /XD .* /NJH /NJS /NFL /NDL > nul
pushd .package
"%zip%" a -tzip -bd ..\%archive% %name% > nul
popd
rd /S /Q .package
REM move zip to target directory, unless equal
if not ""=="%EXPORTPATH%" move %archive% %EXPORTPATH%\%archive% > nul
call :dogit
echo.
echo * Done^^!
echo.
pause
exit /B
:findzip
for /f "tokens=*" %%i in ('where 7z.exe') do set zip="%%i"
if exist "%zip%" goto :eof
set zip=%ProgramFiles%\7-Zip\7z.exe
if exist "%zip%" goto :eof
goto :zipnotfound
:findname
for /F "tokens=3" %%i in ('findstr /C:"## Title:" *.txt') do set name=%%i
REM fallback: Set name to folder name
if ""=="%name%" for %%* in (.) do set name=%%~nx*
if not exist %name%.txt (
echo * Please enter the name of your add-on:
set /P name=^>
)
goto :eof
:dogit
where 7z.exe >nul 2>nul
IF NOT ERRORLEVEL 0 (
goto :eof
)
echo.
git status | find /v "" | findstr /r /c:"no changes added to commit" > NUL & IF ERRORLEVEL 0 (
git add .
git commit -am "%version%"
echo pushing to git...
git push
git push esoui
) else (
echo git is up-to-date
)
if not ""=="%PUBLISHURL%" start "" %PUBLISHURL%
goto :eof
:deleteoldfiles
if "%DELETEOLDZIPS%"=="" goto :eof
pushd "%EXPORTPATH%"
for %%i in (%name%*.zip) do if not "%%~i"=="%archive%" del /S "%%~i"
popd
goto :eof
:zipnotfound
echo 7-Zip cannot be found, get it free at http://www.7-zip.org
pause
exit /B
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment