feat: dev,pre环境打包采用未来真实版本号.
This commit is contained in:
parent
70619b94be
commit
44bb803754
@ -1,6 +1,6 @@
|
||||
stages:
|
||||
- test
|
||||
- generate_tag
|
||||
- generate_tag_or_version
|
||||
- build-artifacts
|
||||
- release-artifacts
|
||||
- notification
|
||||
@ -20,13 +20,22 @@ variables:
|
||||
- if: $CI_COMMIT_BRANCH =~ /feat_[a-zA-Z]+/
|
||||
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$/
|
||||
|
||||
.tag_rule:
|
||||
.generate_tag_rule:
|
||||
tags:
|
||||
- macos
|
||||
- flutter
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == "master"
|
||||
|
||||
.generate_next_version_rule:
|
||||
tags:
|
||||
- macos
|
||||
- flutter
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == "develop"
|
||||
- if: $CI_COMMIT_BRANCH == "release"
|
||||
- if: $CI_COMMIT_BRANCH =~ /feat_[a-zA-Z]+/
|
||||
|
||||
.print_env:
|
||||
stage: test
|
||||
extends: .build_rule
|
||||
@ -39,6 +48,9 @@ variables:
|
||||
.setup_fastlane_android:
|
||||
extends: .build_rule
|
||||
before_script:
|
||||
- ls -li
|
||||
- export NEXT_VERSION="$(cat app_new.version)"
|
||||
- export NEXT_VERSION="$(cat app_new.version)"
|
||||
- flutter pub get
|
||||
- bundle install --gemfile android/Gemfile --quiet
|
||||
|
||||
@ -46,6 +58,7 @@ variables:
|
||||
.setup_fastlane_ios:
|
||||
extends: .build_rule
|
||||
before_script:
|
||||
- ls -li
|
||||
- flutter pub get
|
||||
- bundle install --gemfile ios/Gemfile --quiet
|
||||
|
||||
@ -58,9 +71,9 @@ test_lint_check:
|
||||
- macos
|
||||
- flutter
|
||||
|
||||
git_tag:
|
||||
stage: generate_tag
|
||||
extends: .tag_rule
|
||||
generate_git_tag:
|
||||
stage: generate_tag_or_version
|
||||
extends: .generate_tag_rule
|
||||
before_script:
|
||||
- project_url=$(echo $CI_PROJECT_URL | sed 's/http:\/\///')
|
||||
- echo "project_url:$project_url"
|
||||
@ -68,6 +81,15 @@ git_tag:
|
||||
script:
|
||||
- bash tag_generator.sh
|
||||
|
||||
generate_next_version:
|
||||
stage: generate_tag_or_version
|
||||
extends: .generate_next_version_rule
|
||||
script:
|
||||
- bash tag_generator.sh generate_version
|
||||
cache:
|
||||
paths:
|
||||
- app_new.version
|
||||
|
||||
build_android:
|
||||
stage: build-artifacts
|
||||
extends: .setup_fastlane_android
|
||||
|
||||
@ -18,10 +18,12 @@ default_platform(:android)
|
||||
$env_key_project_root = 'ENV_BUILD_WORKSPACE'
|
||||
$env_current_branch = 'ENV_BUILD_BRANCH'
|
||||
$env_current_tag = 'ENV_BUILD_TAG'
|
||||
$env_next_version = 'NEXT_VERSION'
|
||||
|
||||
$path_dir_build = File.join(ENV[$env_key_project_root],'')
|
||||
$current_branch = ENV[$env_current_branch]
|
||||
$current_tag = ENV[$env_current_tag]
|
||||
$next_version = ENV[$env_next_version]
|
||||
|
||||
$path_apk_output_dir = File.join($path_dir_build, 'build/app/outputs/flutter-apk')
|
||||
$path_bundle_output_dir = File.join($path_dir_build, 'build/app/outputs/bundle')
|
||||
@ -60,7 +62,7 @@ platform :android do
|
||||
print_log "build #{flavor} on #{env}"
|
||||
build_number = Time.now.strftime("%Y%m%d%H")
|
||||
print_log "BuildNo #{build_number}"
|
||||
build_version = '1.0.0'
|
||||
build_version = $next_version
|
||||
print_log "build_version #{build_version}"
|
||||
commit_hash = last_git_commit
|
||||
short_hash = commit_hash[:abbreviated_commit_hash]
|
||||
|
||||
@ -47,10 +47,12 @@ $env_current_tag = 'ENV_BUILD_TAG'
|
||||
$env_key_fastlane_apple_auth_key = 'APPLE_AUTH_CONTENT'
|
||||
$env_key_fastlane_apple_auth_issuer_key = 'APPLE_AUTH_ISSUER_ID'
|
||||
$env_key_fastlane_apple_auth_id_key = 'APPLE_AUTH_KEY_ID'
|
||||
$env_next_version = 'NEXT_VERSION'
|
||||
|
||||
$path_dir_build = File.join(ENV[$env_key_project_root], '')
|
||||
$current_branch = ENV[$env_current_branch]
|
||||
$current_tag = ENV[$env_current_tag]
|
||||
$next_version = ENV[$env_next_version]
|
||||
|
||||
$filename_ipa_default = 'app-starlock.ipa'
|
||||
$filename_beta_ipa_copy = 'app-starlock-'+$current_branch+'.ipa'
|
||||
@ -77,7 +79,7 @@ platform :ios do
|
||||
print_log "build #{flavor} on #{env}"
|
||||
build_number = Time.now.strftime("%Y%m%d%H")
|
||||
print_log "Build Commits #{build_number}"
|
||||
build_version = '1.0.0'; # Time.now.strftime("%Y%m%d%H%M%S")
|
||||
build_version = $next_version # Time.now.strftime("%Y%m%d%H%M%S")
|
||||
print_log "build_version #{build_version}"
|
||||
commit_hash = last_git_commit
|
||||
short_hash = commit_hash[:abbreviated_commit_hash]
|
||||
|
||||
@ -5,6 +5,7 @@ URL=$CI_API_V4_URL
|
||||
TOKEN=$GITLAB_ACCESS_TOKEN
|
||||
PROJECT_ID=$CI_PROJECT_ID
|
||||
next_tag=""
|
||||
newest_tag=""
|
||||
echo "PRIVATE-TOKEN: $TOKEN $URL/projects/$PROJECT_ID/repository/tags"
|
||||
tags_json=$(curl -H "Content-Type: application/json" -H "PRIVATE-TOKEN: $TOKEN" "$URL/projects/$PROJECT_ID/repository/tags")
|
||||
#echo "tags_json:$tags_json\n"
|
||||
@ -16,9 +17,14 @@ else
|
||||
newest_tag=$(echo "$tags" | head -n 1)
|
||||
IFS='.' read -r major minor patch <<< "$newest_tag"
|
||||
major="${major#v}"
|
||||
echo "newest_tag:$newest_tag-second_newest_tag:$second_newest_tag\n"
|
||||
# 比较两个tag之间的commits
|
||||
compare_json=$(curl -s --header "PRIVATE-TOKEN: $TOKEN" "$URL/projects/$PROJECT_ID/repository/compare?from=$newest_tag&to=master")
|
||||
compare_json=""
|
||||
if [[ "$1" == "generate_tag" ]];then
|
||||
echo "generate_tag:$newest_tag-to-master\n"
|
||||
compare_json=$(curl -s --header "PRIVATE-TOKEN: $TOKEN" "$URL/projects/$PROJECT_ID/repository/compare?from=$newest_tag&to=master")
|
||||
elif [[ "$1" == "generate_version" ]]; then
|
||||
echo "generate_version:master-to-$CI_COMMIT_BRANCH\n"
|
||||
compare_json=$(curl -s --header "PRIVATE-TOKEN: $TOKEN" "$URL/projects/$PROJECT_ID/repository/compare?from=master&to=$CI_COMMIT_BRANCH")
|
||||
fi
|
||||
echo "compare_json:$compare_json\n"
|
||||
while IFS= read -r commit_json; do
|
||||
# 使用 jq 解析每一行的 JSON 对象
|
||||
@ -36,12 +42,20 @@ else
|
||||
fi
|
||||
done < <(echo "$compare_json" | jq -c '.commits[] | {id: .id, message: .message}')
|
||||
next_tag="v$major.$minor.$patch"
|
||||
fi
|
||||
echo "New Tag:$newest_tag;New version: $next_tag;command: $1"
|
||||
if [[ "$1" == "generate_tag" ]];then
|
||||
if [ "$next_tag" == "$newest_tag" ]; then
|
||||
echo "no change from master,skip to generate tag"
|
||||
exit 0
|
||||
fi
|
||||
git config user.name
|
||||
git tag $next_tag
|
||||
git push -u origin $next_tag
|
||||
echo "generate tag: $next_tag"
|
||||
elif [[ "$1" == "generate_version" ]]; then
|
||||
export NEXT_VERSION="$next_tag"
|
||||
echo "generate version: $NEXT_VERSION"
|
||||
fi
|
||||
echo "New version: $next_tag"
|
||||
git config user.name
|
||||
git tag $next_tag
|
||||
git push -u origin $next_tag
|
||||
echo "$next_tag" > app_new.version
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user