Skip to content

Commit

Permalink
1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
x1y9 committed Feb 18, 2022
1 parent da0a479 commit c557287
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "stock"
version = "1.1.1"
version = "1.2.0"
edition = "2021"

[dependencies]
Expand Down
66 changes: 66 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
@setlocal enableDelayedExpansion
@REM set LANG for grep run correctly
@set LANG=zh_CN.UTF-8

@if "%1"=="" goto do_help
@if "%1"=="clean" goto do_clean
@if "%1"=="version" goto do_version
@if "%1"=="debug" goto do_debug
@if "%1"=="release" goto do_release
@if "%1"=="publish" goto do_publish

:do_help
@echo build script for android project
@echo.
@echo Build: build [debug^|release^|publish]
@echo Clean: build clean
@echo Version: build version [number]
@goto end

:do_debug
cargo run
@IF %ERRORLEVEL% NEQ 0 goto error_end
@call toast debug-run
@goto end

:do_release
cargo run --release
@IF %ERRORLEVEL% NEQ 0 goto error_end
@call toast release-run
@goto end

:do_publish
@echo check uncommit files...
@git diff-files --quiet
@IF %ERRORLEVEL% NEQ 0 goto error_end
cargo build --release
@IF %ERRORLEVEL% NEQ 0 goto error_end
for /f %%i in ('grep -m 1 -oP "name = ""\K([a-zA-Z0-9.]+)" Cargo.toml') do set PACKAGE=%%i
for /f %%i in ('grep -m 1 -oP "version = ""\K([0-9.]+)" Cargo.toml') do set VERSION=%%i
for /f %%i in ('git rev-parse --short HEAD') do set HASH=%%i
@echo publish to %PACKAGE%-%VERSION%-%HASH%.exe
copy target\release\%PACKAGE%.exe %PACKAGE%-%VERSION%-%HASH%.exe
@call toast publish-build
@goto end

:do_clean
cargo clean
@goto end

:do_version
@if "%2"=="" (
@grep -m 1 -oP "version = ""\K([0-9.]+)" Cargo.toml
) else (
sed -i -E "s/version = ""([0-9.]+)""$/version = ""%2""/" Cargo.toml
cargo build --release
@IF %ERRORLEVEL% NEQ 0 goto error_end
git commit -m "%2" -a
)
@goto end

:error_end
@call toast build-fail
@echo Oops... Something wrong!
@ver /ERROR >NUL 2>&1

:end

0 comments on commit c557287

Please sign in to comment.