Skip to content
代码片段 群组 项目
提交 0a2b7778 编辑于 作者: Zhou YANG's avatar Zhou YANG
浏览文件

ci: #145 use time as versionCode

上级 28865edf
No related branches found
No related tags found
无相关合并请求
......@@ -6,7 +6,7 @@ stages:
- deploy
variables:
ANDROID_APK_PATH: build/app/outputs/apk/release/*.apk
ANDROID_APK_PATH: build/app/outputs/apk/release/
code_quality:
stage: check
......@@ -34,21 +34,33 @@ check:
build-android:
stage: build
script:
- VERSION_NAME=$(cat pubspec.yaml | grep version | head -1 | awk '{print $2}' | awk -F+ '{print $1}')
- VERSION_CODE=$(cat pubspec.yaml | grep version | head -1 | awk '{print $2}' | awk -F+ '{print $1}')
- VERSION_CODE_NEW=$(date +%s)
- VERSION_NEW=$VERSION_NAME+$VERSION_CODE_NEW
- 'sed -i "s/version:.*/version: $VERSION_NEW/g" pubspec.yaml'
- 'sed -i "s/\"versionCode\":.*/\"versionCode\": $VERSION_CODE_NEW/g" updater.json'
- 'sed -i "s/\"versionName\":.*/\"versionName\": \"$VERSION_NAME\"/g" updater.json'
- flutter build apk --dart-define=REQUEST_ENV=prod_env
- VERSION_APK=$(/opt/android-sdk-linux/build-tools/30.0.3/aapt2 dump badging ${ANDROID_APK_PATH} | grep "versionName" | sed -e "s/.*versionName='//" -e "s/' .*//")
- echo "VERSION_APK=$VERSION_APK" > version.env
- echo "VERSION_NAME=$VERSION_NAME" >> build.env
artifacts:
name: "android-apk"
paths:
- ${ANDROID_APK_PATH}
- updater.json
expire_in: 2 days
reports:
dotenv: version.env
dotenv: build.env
upload-apk:
stage: deploy
script:
- echo $VERSION_APK
- 'curl -i --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ${ANDROID_APK_PATH} "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/jihu-gitlab-app/${VERSION_APK}/"'
- echo $VERSION_NAME
- APK_FILENAME=$(build/app/outputs/apk/release/*.apk | xargs -n 1 basename)
- APK_URL_PATH="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/jihu-gitlab-app/${VERSION_NAME}/"
- 'curl -i --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ${ANDROID_APK_PATH}/${APK_FILENAME} "${APK_URL_PATH}"'
- APK_URL="${CI_API_V4_URL}${APK_FILENAME}"
- 'sed -i "s/\"url\":.*/\"url\": \"$APK_URL\"/g" updater.json'
- 'curl -i --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file updater.json "${APK_URL_PATH}"'
only:
- main
{
"versionCode":3,
"versionName":"1.0.0",
"contentText":"Please update your app",
"minSupport":2,
"url":"/*App Download Url*/"
}
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册