flutter.yml: 修改当 Git 浅克隆时生成版本号的方式为依据编译编号或者日期
服务器只是浅克隆1层代码,有 GITHUB_RUN_NUMBER 的就依据此环境变量。 对于本地如果浅克隆,没有 GITHUB_RUN_NUMBER 的就依据编译日期。
This commit is contained in:
parent
9795f08fcd
commit
43ac139d90
|
@ -26,11 +26,17 @@ jobs:
|
|||
with:
|
||||
channel: 'stable' # or: 'dev' or 'beta'
|
||||
|
||||
- name: Export environment valiables
|
||||
run: export
|
||||
|
||||
- name: Create App version
|
||||
run: git fetch --tags; git tag; git log -n1; bash -x ./version.sh
|
||||
|
||||
- name: Print Flutter SDK version
|
||||
run: flutter --version
|
||||
|
||||
- name: Install dependencies
|
||||
run: ./version.sh; cd src/ui/flutter; flutter pub get; flutter pub global activate intl_utils; flutter --no-color pub global run intl_utils:generate
|
||||
run: cd src/ui/flutter; flutter pub get; flutter pub global activate intl_utils; flutter --no-color pub global run intl_utils:generate
|
||||
|
||||
# Uncomment this step to verify the use of 'dart format' on each commit.
|
||||
# - name: Verify formatting
|
||||
|
@ -41,7 +47,7 @@ jobs:
|
|||
# want to change this to 'flutter test'.
|
||||
#- name: Run tests
|
||||
# run: dart test
|
||||
|
||||
|
||||
# Build
|
||||
- name: Build apk
|
||||
run: cd src/ui/flutter; flutter build apk
|
||||
|
|
29
version.sh
29
version.sh
|
@ -13,19 +13,26 @@ LOCALVER="$(wc -l config.git-hash | awk '{print $1}')"
|
|||
TAG="$(git describe --tags "$(git rev-list --tags --max-count=1)")"
|
||||
|
||||
if [ "$LOCALVER" -gt "1" ] ; then
|
||||
VER=$(git rev-list origin/$GIT_BRANCH | sort | join config.git-hash - | wc -l | awk '{print $1}')
|
||||
if [ "$VER" != "$LOCALVER" ] ; then
|
||||
VER="$VER+$((LOCALVER-VER))"
|
||||
fi
|
||||
if git status | grep -q "modified:" ; then
|
||||
VER="${VER}M"
|
||||
fi
|
||||
VER="$VER g$(git rev-list HEAD -n 1 | cut -c 1-7)"
|
||||
GIT_VERSION="$TAG r$VER"
|
||||
VER=$(git rev-list origin/$GIT_BRANCH | sort | join config.git-hash - | wc -l | awk '{print $1}')
|
||||
if [ "$VER" != "$LOCALVER" ] ; then
|
||||
VER="$VER+$((LOCALVER-VER))"
|
||||
fi
|
||||
if git status | grep -q "modified:" ; then
|
||||
VER="${VER}M"
|
||||
fi
|
||||
VER="$VER g$(git rev-list HEAD -n 1 | cut -c 1-7)"
|
||||
GIT_VERSION="$TAG r$VER"
|
||||
APP_VERSION="${TAG:1}+${LOCALVER-VER}"
|
||||
else
|
||||
GIT_VERSION=
|
||||
VER="x"
|
||||
DATE=$(date +%Y%m%d)
|
||||
if [ -n "$GITHUB_RUN_NUMBER" ] ; then
|
||||
VER="$GITHUB_RUN_NUMBER"
|
||||
GIT_VERSION="$TAG #$VER"
|
||||
else
|
||||
VER="${DATE:2}"
|
||||
GIT_VERSION="$TAG Build $VER"
|
||||
fi
|
||||
APP_VERSION="${TAG:1}+${VER}"
|
||||
fi
|
||||
|
||||
rm -f config.git-hash
|
||||
|
|
Loading…
Reference in New Issue