develop_sky #3
@ -1,4 +1,4 @@
|
||||
name: Flutter Build - Sky
|
||||
name: Flutter Build - Sky Develop
|
||||
|
||||
on:
|
||||
push:
|
||||
@ -23,20 +23,53 @@ jobs:
|
||||
- name: Determine Version
|
||||
id: version
|
||||
run: |
|
||||
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.0.0_sky")
|
||||
# 获取上一次构建成功的tag(匹配vX.X.X_sky格式)
|
||||
LAST_TAG=$(git describe --tags --match "v*.*.*_sky" --abbrev=0 2>/dev/null || echo "v1.0.0_sky")
|
||||
echo "Last tag found: $LAST_TAG"
|
||||
|
||||
# 提取基础版本号(去除_sky后缀)
|
||||
BASE_VERSION=$(echo "$LAST_TAG" | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | head -1)
|
||||
[ -z "$BASE_VERSION" ] && BASE_VERSION="v1.0.0"
|
||||
echo "Base version: $BASE_VERSION"
|
||||
|
||||
# 解析版本号各部分
|
||||
MAJOR=$(echo $BASE_VERSION | cut -d'.' -f1 | sed 's/v//')
|
||||
MINOR=$(echo $BASE_VERSION | cut -d'.' -f2)
|
||||
PATCH=$(echo $BASE_VERSION | cut -d'.' -f3)
|
||||
echo "Current version: Major=$MAJOR, Minor=$MINOR, Patch=$PATCH"
|
||||
|
||||
# 计算不重复的commit消息数量
|
||||
COMMIT_COUNT=$(git log --pretty=%B "${LAST_TAG}.." | grep -v '^$' | sort -u | wc -l | tr -d ' ')
|
||||
echo "Unique commit messages count: $COMMIT_COUNT"
|
||||
|
||||
# 计算新的patch版本,并处理进位
|
||||
NEW_PATCH=$((PATCH + COMMIT_COUNT))
|
||||
NEXT_VERSION="v${MAJOR}.${MINOR}.${NEW_PATCH}"
|
||||
NEXT_VERSION_FULL="${NEXT_VERSION}_sky_dev"
|
||||
NEW_MINOR=$MINOR
|
||||
NEW_MAJOR=$MAJOR
|
||||
|
||||
# 处理第三位版本号进位(超过1000时进位到第二位)
|
||||
if [ $NEW_PATCH -ge 1000 ]; then
|
||||
NEW_MINOR=$((MINOR + NEW_PATCH / 1000))
|
||||
NEW_PATCH=$((NEW_PATCH % 1000))
|
||||
echo "Patch overflow detected, new Minor: $NEW_MINOR, new Patch: $NEW_PATCH"
|
||||
fi
|
||||
|
||||
# 处理第二位版本号进位(超过10时进位到第一位)
|
||||
if [ $NEW_MINOR -ge 10 ]; then
|
||||
NEW_MAJOR=$((MAJOR + NEW_MINOR / 10))
|
||||
NEW_MINOR=$((NEW_MINOR % 10))
|
||||
echo "Minor overflow detected, new Major: $NEW_MAJOR, new Minor: $NEW_MINOR"
|
||||
fi
|
||||
|
||||
# 生成新版本号
|
||||
NEXT_VERSION="v${NEW_MAJOR}.${NEW_MINOR}.${NEW_PATCH}"
|
||||
NEXT_VERSION_FULL="${NEXT_VERSION}_sky_develop" # develop环境标识
|
||||
BUILD_NUMBER=$NEW_PATCH
|
||||
|
||||
echo "Next version: $NEXT_VERSION"
|
||||
echo "Next version full: $NEXT_VERSION_FULL"
|
||||
echo "Build number: $BUILD_NUMBER"
|
||||
|
||||
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITEA_ENV
|
||||
echo "NEXT_VERSION_FULL=$NEXT_VERSION_FULL" >> $GITEA_ENV
|
||||
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITEA_ENV
|
||||
@ -46,9 +79,9 @@ jobs:
|
||||
echo "::set-output name=next_version_full::$NEXT_VERSION_FULL"
|
||||
echo "::set-output name=build_number::$BUILD_NUMBER"
|
||||
|
||||
# 并行 Job 1:Android APK
|
||||
# 并行 Job 1:Android APK (Develop环境)
|
||||
build-apk:
|
||||
name: 📦 Build APK
|
||||
name: 📦 Build APK (Develop)
|
||||
needs: determine-version
|
||||
runs-on: sky
|
||||
steps:
|
||||
@ -58,24 +91,33 @@ jobs:
|
||||
- name: Setup Flutter
|
||||
run: flutter pub get
|
||||
|
||||
- name: Build APK
|
||||
- name: Build APK (Develop环境)
|
||||
run: |
|
||||
flutter build apk \
|
||||
--no-tree-shake-icons \
|
||||
--flavor sky \
|
||||
-t lib/main_sky_dev.dart \
|
||||
--build-number=${{ needs.determine-version.outputs.build_number }} \
|
||||
--build-name=${{ needs.determine-version.outputs.next_version }}
|
||||
--build-name=${{ needs.determine-version.outputs.next_version }} \
|
||||
--debug # Develop环境使用debug构建
|
||||
|
||||
- name: Rename APK with Version
|
||||
run: |
|
||||
# 重命名APK文件,添加版本号
|
||||
OLD_PATH="build/app/outputs/flutter-apk/app-sky_dev-debug.apk"
|
||||
NEW_NAME="starlock-sky-${{ needs.determine-version.outputs.next_version_full }}.apk"
|
||||
cp "$OLD_PATH" "$NEW_NAME"
|
||||
echo "Renamed APK to: $NEW_NAME"
|
||||
|
||||
- name: Upload APK Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: starlock-sky-dev-${{ needs.determine-version.outputs.next_version_full }}.apk
|
||||
path: build/app/outputs/flutter-apk/app-sky_dev-release.apk
|
||||
name: ${{ needs.determine-version.outputs.next_version_full }}-apk
|
||||
path: starlock-sky-${{ needs.determine-version.outputs.next_version_full }}.apk
|
||||
|
||||
# 并行 Job 2:Android AAB
|
||||
# 并行 Job 2:Android AAB (Develop环境)
|
||||
build-aab:
|
||||
name: 📦 Build AAB
|
||||
name: 📦 Build AAB (Develop)
|
||||
needs: determine-version
|
||||
runs-on: sky
|
||||
steps:
|
||||
@ -85,24 +127,33 @@ jobs:
|
||||
- name: Setup Flutter
|
||||
run: flutter pub get
|
||||
|
||||
- name: Build App Bundle
|
||||
- name: Build App Bundle (Develop环境)
|
||||
run: |
|
||||
flutter build appbundle \
|
||||
--no-tree-shake-icons \
|
||||
--flavor sky \
|
||||
-t lib/main_sky_dev.dart \
|
||||
--build-number=${{ needs.determine-version.outputs.build_number }} \
|
||||
--build-name=${{ needs.determine-version.outputs.next_version }}
|
||||
--build-name=${{ needs.determine-version.outputs.next_version }} \
|
||||
--debug # Develop环境使用debug构建
|
||||
|
||||
- name: Rename AAB with Version
|
||||
run: |
|
||||
# 重命名AAB文件,添加版本号
|
||||
OLD_PATH="build/app/outputs/bundle/skyDebug/app-sky-debug.aab"
|
||||
NEW_NAME="starlock-sky-${{ needs.determine-version.outputs.next_version_full }}.aab"
|
||||
cp "$OLD_PATH" "$NEW_NAME"
|
||||
echo "Renamed AAB to: $NEW_NAME"
|
||||
|
||||
- name: Upload AAB Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: starlock-sky-dev-${{ needs.determine-version.outputs.next_version_full }}.aab
|
||||
path: build/app/outputs/bundle/skyRelease/app-sky-release.aab
|
||||
name: ${{ needs.determine-version.outputs.next_version_full }}-aab
|
||||
path: starlock-sky-${{ needs.determine-version.outputs.next_version_full }}.aab
|
||||
|
||||
# 并行 Job 3:iOS IPA
|
||||
# 并行 Job 3:iOS IPA (Develop环境)
|
||||
build-ios:
|
||||
name: 🍎 Build iOS
|
||||
name: 🍎 Build iOS (Develop)
|
||||
needs: determine-version
|
||||
runs-on: macos # 必须使用 macOS runner
|
||||
steps:
|
||||
@ -112,22 +163,36 @@ jobs:
|
||||
- name: Setup Flutter
|
||||
run: flutter pub get
|
||||
|
||||
- name: Build iOS
|
||||
- name: Build iOS (Develop环境)
|
||||
run: |
|
||||
flutter build ios \
|
||||
--no-codesign \
|
||||
--flavor sky \
|
||||
-t lib/main_sky_dev.dart \
|
||||
--build-number=${{ needs.determine-version.outputs.build_number }} \
|
||||
--build-name=${{ needs.determine-version.outputs.next_version }}
|
||||
--build-name=${{ needs.determine-version.outputs.next_version }} \
|
||||
--debug # Develop环境使用debug构建
|
||||
|
||||
- name: Rename IPA with Version
|
||||
run: |
|
||||
# 重命名IPA文件,添加版本号
|
||||
OLD_PATH="build/ios/iphoneos/Runner.app"
|
||||
NEW_NAME="starlock-sky-${{ needs.determine-version.outputs.next_version_full }}.ipa"
|
||||
# 对于iOS,需要先打包成IPA
|
||||
xcodebuild -exportArchive -archivePath build/ios/archive/Runner.xcarchive \
|
||||
-exportOptionsPlist ExportOptions.plist \
|
||||
-exportPath build/ios/ipa \
|
||||
-allowProvisioningUpdates
|
||||
cp "build/ios/ipa/Runner.ipa" "$NEW_NAME"
|
||||
echo "Renamed IPA to: $NEW_NAME"
|
||||
|
||||
- name: Upload IPA Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: starlock-sky-dev-${{ needs.determine-version.outputs.next_version_full }}.ipa
|
||||
path: build/ios/ipa/Runner.ipa
|
||||
name: ${{ needs.determine-version.outputs.next_version_full }}-ipa
|
||||
path: starlock-sky-${{ needs.determine-version.outputs.next_version_full }}.ipa
|
||||
|
||||
# 最后一个 job:汇总并打 tag
|
||||
# 最后一个 job:汇总、打tag并通知
|
||||
publish:
|
||||
name: 🏷️ Create Tag & Notify
|
||||
needs: [build-apk, build-aab, build-ios]
|
||||
@ -136,11 +201,41 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Create and Push New Tag
|
||||
run: |
|
||||
NEW_TAG=${{ needs.determine-version.outputs.next_version_full }}
|
||||
git config user.name "Gitea Runner"
|
||||
git config user.email "runner@gitea.local"
|
||||
git tag "$NEW_TAG"
|
||||
git push origin "$NEW_TAG" || echo "Tag $NEW_TAG already exists"
|
||||
|
||||
# 检查tag是否已存在,如果不存在则创建并推送
|
||||
if ! git rev-parse "$NEW_TAG" >/dev/null 2>&1; then
|
||||
git tag "$NEW_TAG"
|
||||
git push origin "$NEW_TAG"
|
||||
echo "✅ New tag created and pushed: $NEW_TAG"
|
||||
else
|
||||
echo "ℹ️ Tag $NEW_TAG already exists, skipping creation"
|
||||
fi
|
||||
|
||||
- name: Notify Build Success
|
||||
run: |
|
||||
echo "🚀 Build Successful!"
|
||||
echo "📦 Generated artifacts:"
|
||||
echo " - APK: starlock-sky-${{ needs.determine-version.outputs.next_version_full }}.apk"
|
||||
echo " - AAB: starlock-sky-${{ needs.determine-version.outputs.next_version_full }}.aab"
|
||||
echo " - IPA: starlock-sky-${{ needs.determine-version.outputs.next_version_full }}.ipa"
|
||||
echo "🏷️ New version tag: ${{ needs.determine-version.outputs.next_version_full }}"
|
||||
echo "🔢 Version: ${{ needs.determine-version.outputs.next_version }}"
|
||||
echo "📊 Build number: ${{ needs.determine-version.outputs.build_number }}"
|
||||
|
||||
- name: Upload All Artifacts to Gitea
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: starlock-sky-develop-${{ needs.determine-version.outputs.next_version_full }}
|
||||
path: |
|
||||
starlock-sky-${{ needs.determine-version.outputs.next_version_full }}.apk
|
||||
starlock-sky-${{ needs.determine-version.outputs.next_version_full }}.aab
|
||||
starlock-sky-${{ needs.determine-version.outputs.next_version_full }}.ipa
|
||||
retention-days: 30
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user