From e8b2cf46600a7d2516d972182ce2916be6dfd8ec Mon Sep 17 00:00:00 2001 From: liyi Date: Mon, 22 Sep 2025 17:17:00 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d6ee8c02..8d2bf3ad 100755 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ keytool -list -v -keystore android/app/sky.jks ``` 输入密码(在android/app/build.gradle:38可以看到) - +测试ci 一般需要的是:证书指纹-SHA1 看起来像 95:6B:***********(共59个字符) ## 编译 From 31123e503a30df4a12f87b0a90dd0fc4e2164359 Mon Sep 17 00:00:00 2001 From: liyi Date: Mon, 22 Sep 2025 17:28:58 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=E6=B5=8B=E8=AF=95ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci.yml | 253 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 .gitea/workflows/ci.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 00000000..0ec3351a --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,253 @@ +# .gitea/workflows/ci.yml + +name: Flutter CI/CD Pipeline + +# 触发条件 +on: + push: + branches: + - develop_sky + - release_sky + - master_sky + - canary_release_sky + - /^feat_[a-zA-Z]+$/ # 注意:Gitea 不支持正则分支名直接写在 YAML 中,需用 if 判断 + tags: + - v* # 匹配 v1.0.0 等 tag + pull_request: + branches: + - develop_sky + - release_sky + - canary_release_sky + - /^feat_[a-zA-Z]+$/ + +# 全局环境变量 +env: + LC_ALL: en_US.UTF-8 + LANG: en_US.UTF-8 + PUB_HOSTED_URL: https://pub.flutter-io.cn + FLUTTER_STORAGE_BASE_URL: https://storage.flutter-io.cn + +# 所有 job 共用的 runner 标签 +defaults: + run: + shell: bash + +jobs: + # ============ 1. 打印环境信息 ============ + print_env: + name: Print Environment + runs-on: macos,flutter # 必须匹配你 Runner 的 labels + if: | + contains(github.ref, 'develop_sky') || + contains(github.ref, 'release_sky') || + contains(github.ref, 'canary_release_sky') || + startsWith(github.ref, 'refs/heads/feat_') || + startsWith(github.ref, 'refs/tags/v') + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Set up Ruby + run: | + export PATH="/opt/homebrew/bin:$PATH" + eval "$(rbenv init -)" + rbenv global 2.6.10 + ruby -v + which ruby + gem env + + - name: Print Env + run: | + java --version + printenv | sort + + - name: Set NEXT_VERSION from file + run: | + echo "NEXT_VERSION=$(cat app_new.version)" >> $GITHUB_ENV + if: always() && !cancelled() + + # ============ 2. 生成 Git Tag(仅 master_sky) ============ + generate_git_tag: + name: Generate Git Tag + needs: print_env + runs-on: macos,flutter + if: github.branch == 'master_sky' + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Setup SSH & Generate Tag + run: | + bash pre_build.sh sky + project_url=$(echo $CI_GITEA_SERVER_URL | sed 's|http://||') + git remote set-url origin git@gitea.example.com:your-namespace/your-repo.git + bash tag_generator.sh generate_tag + + # ============ 3. 生成下一个版本号 ============ + generate_next_version: + name: Generate Next Version + needs: print_env + runs-on: macos,flutter + if: | + contains(github.ref, 'develop_sky') || + contains(github.ref, 'release_sky') || + contains(github.ref, 'canary_release_sky') || + startsWith(github.ref, 'refs/heads/feat_') + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Generate Version + run: | + bash tag_generator.sh generate_version + id: version_gen + + - name: Save Version for Downstream + run: | + echo "NEXT_VERSION=$(cat app_new.version)" >> $GITHUB_ENV + if: always() + outputs: + next_version: ${{ env.NEXT_VERSION }} + + # ============ 4. 构建 Android ============ + build_android: + name: Build Android APK/AAB + needs: [print_env, generate_next_version] + runs-on: macos,flutter + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Setup Flutter & Fastlane (Android) + run: | + export PATH="/opt/homebrew/bin:$PATH" + eval "$(rbenv init -)" + rbenv global 2.6.10 + bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/ + bundle install --gemfile android/Gemfile --path vendor/bundle_android --quiet + flutter clean + flutter pub get + + - name: Build Android + run: | + bash android/build.sh + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: android-artifacts + path: build/app/outputs/flutter-apk/ + + # ============ 5. 构建 iOS ============ + build_ios: + name: Build iOS IPA + needs: [print_env, generate_next_version] + runs-on: macos,flutter + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Setup Flutter & Fastlane (iOS) + run: | + export PATH="/opt/homebrew/bin:$PATH" + eval "$(rbenv init -)" + rbenv global 2.6.10 + bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/ + bundle install --gemfile ios/Gemfile --path vendor/bundle_ios --quiet + flutter clean + flutter pub get + + - name: Build iOS + run: | + bash ios/build.sh + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: ios-artifacts + path: build/app/outputs/flutter-ipa/ + + # ============ 6. 发布 Release(仅当打 tag 时) ============ + create_release: + name: Create Release & Upload Assets + needs: [build_android, build_ios] + runs-on: macos,flutter + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Download Artifacts + uses: actions/download-artifact@v4 + + - name: Generate Release Description + run: | + bash release_description_generator.sh + cat changelog.md + + - name: Upload to Gitea Package Registry & Create Release + env: + STARLOCK_VERSION: ${{ split(github.ref, '/')[2] }} # 提取 tag 名,如 v1.0.0 -> v1.0.0 + run: | + TAG_NAME="${STARLOCK_VERSION}" + VERSION_PART="${TAG_NAME#v}" # 去掉 v 前缀 + + # 上传到 Gitea 通用包(Generic Package) + curl -f -i \ + -H "Authorization: Bearer $CI_GITEA_TOKEN" \ + --upload-file "starlock-sky-release-${TAG_NAME}.apk" \ + "$CI_GITEA_SERVER_URL/api/packages/$GITHUB_REPOSITORY_OWNER/StarLock/$VERSION_PART/starlock-sky-release-${TAG_NAME}.apk" + + curl -f -i \ + -H "Authorization: Bearer $CI_GITEA_TOKEN" \ + --upload-file "starlock-sky-release-${TAG_NAME}.aab" \ + "$CI_GITEA_SERVER_URL/api/packages/$GITHUB_REPOSITORY_OWNER/StarLock/$VERSION_PART/starlock-sky-release-${TAG_NAME}.aab" + + curl -f -i \ + -H "Authorization: Bearer $CI_GITEA_TOKEN" \ + --upload-file "starlock-sky-release-${TAG_NAME}.ipa" \ + "$CI_GITEA_SERVER_URL/api/packages/$GITHUB_REPOSITORY_OWNER/StarLock/$VERSION_PART/starlock-sky-release-${TAG_NAME}.ipa" + + # 创建 Gitea Release(使用 Gitea API) + RELEASE_NOTES="$(cat changelog.md)" + curl -f -i -X POST \ + -H "Authorization: Bearer $CI_GITEA_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "tag_name": "'"$TAG_NAME"'", + "target_commitish": "'"$GITHUB_SHA"'", + "title": "Release '"$TAG_NAME"'", + "note": '"$(printf '%s' "$RELEASE_NOTES" | jq -R -s '.')"', + "is_draft": false, + "is_prerelease": false + }' \ + "$CI_GITEA_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases" + + # ============ 7. 通知 ============ + notify_success: + name: Notify on Success + needs: [create_release, build_android, build_ios] + runs-on: macos,flutter + if: success() + steps: + - run: bash notify.sh success + + notify_failure: + name: Notify on Failure + needs: [build_android, build_ios, create_release] + runs-on: macos,flutter + if: failure() + steps: + - run: bash notify.sh failure + + # ============ 8. 清理 ============ + clean_up: + name: Clean Workspace + runs-on: macos,flutter + needs: [notify_success, notify_failure] + if: always() + steps: + - name: Reset Git + run: | + git reset --hard + git clean -fdx \ No newline at end of file From 1b70bd8b9247eaddb99c05585f679c5d6e866689 Mon Sep 17 00:00:00 2001 From: liyi Date: Mon, 22 Sep 2025 17:33:51 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20=E6=B5=8B=E8=AF=95ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci.yml | 262 +++------------------------------------- 1 file changed, 14 insertions(+), 248 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 0ec3351a..394c8076 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -1,253 +1,19 @@ -# .gitea/workflows/ci.yml - -name: Flutter CI/CD Pipeline - -# 触发条件 -on: - push: - branches: - - develop_sky - - release_sky - - master_sky - - canary_release_sky - - /^feat_[a-zA-Z]+$/ # 注意:Gitea 不支持正则分支名直接写在 YAML 中,需用 if 判断 - tags: - - v* # 匹配 v1.0.0 等 tag - pull_request: - branches: - - develop_sky - - release_sky - - canary_release_sky - - /^feat_[a-zA-Z]+$/ - -# 全局环境变量 -env: - LC_ALL: en_US.UTF-8 - LANG: en_US.UTF-8 - PUB_HOSTED_URL: https://pub.flutter-io.cn - FLUTTER_STORAGE_BASE_URL: https://storage.flutter-io.cn - -# 所有 job 共用的 runner 标签 -defaults: - run: - shell: bash +name: Gitea Actions Demo +run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 +on: [push] jobs: - # ============ 1. 打印环境信息 ============ - print_env: - name: Print Environment - runs-on: macos,flutter # 必须匹配你 Runner 的 labels - if: | - contains(github.ref, 'develop_sky') || - contains(github.ref, 'release_sky') || - contains(github.ref, 'canary_release_sky') || - startsWith(github.ref, 'refs/heads/feat_') || - startsWith(github.ref, 'refs/tags/v') + Explore-Gitea-Actions: + runs-on: ubuntu-latest steps: - - name: Checkout Code + - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" + - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." + - name: Check out repository code uses: actions/checkout@v4 - - - name: Set up Ruby + - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." + - run: echo "🖥️ The workflow is now ready to test your code on the runner." + - name: List files in the repository run: | - export PATH="/opt/homebrew/bin:$PATH" - eval "$(rbenv init -)" - rbenv global 2.6.10 - ruby -v - which ruby - gem env - - - name: Print Env - run: | - java --version - printenv | sort - - - name: Set NEXT_VERSION from file - run: | - echo "NEXT_VERSION=$(cat app_new.version)" >> $GITHUB_ENV - if: always() && !cancelled() - - # ============ 2. 生成 Git Tag(仅 master_sky) ============ - generate_git_tag: - name: Generate Git Tag - needs: print_env - runs-on: macos,flutter - if: github.branch == 'master_sky' - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Setup SSH & Generate Tag - run: | - bash pre_build.sh sky - project_url=$(echo $CI_GITEA_SERVER_URL | sed 's|http://||') - git remote set-url origin git@gitea.example.com:your-namespace/your-repo.git - bash tag_generator.sh generate_tag - - # ============ 3. 生成下一个版本号 ============ - generate_next_version: - name: Generate Next Version - needs: print_env - runs-on: macos,flutter - if: | - contains(github.ref, 'develop_sky') || - contains(github.ref, 'release_sky') || - contains(github.ref, 'canary_release_sky') || - startsWith(github.ref, 'refs/heads/feat_') - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Generate Version - run: | - bash tag_generator.sh generate_version - id: version_gen - - - name: Save Version for Downstream - run: | - echo "NEXT_VERSION=$(cat app_new.version)" >> $GITHUB_ENV - if: always() - outputs: - next_version: ${{ env.NEXT_VERSION }} - - # ============ 4. 构建 Android ============ - build_android: - name: Build Android APK/AAB - needs: [print_env, generate_next_version] - runs-on: macos,flutter - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Setup Flutter & Fastlane (Android) - run: | - export PATH="/opt/homebrew/bin:$PATH" - eval "$(rbenv init -)" - rbenv global 2.6.10 - bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/ - bundle install --gemfile android/Gemfile --path vendor/bundle_android --quiet - flutter clean - flutter pub get - - - name: Build Android - run: | - bash android/build.sh - - - name: Upload Artifacts - uses: actions/upload-artifact@v4 - with: - name: android-artifacts - path: build/app/outputs/flutter-apk/ - - # ============ 5. 构建 iOS ============ - build_ios: - name: Build iOS IPA - needs: [print_env, generate_next_version] - runs-on: macos,flutter - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Setup Flutter & Fastlane (iOS) - run: | - export PATH="/opt/homebrew/bin:$PATH" - eval "$(rbenv init -)" - rbenv global 2.6.10 - bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/ - bundle install --gemfile ios/Gemfile --path vendor/bundle_ios --quiet - flutter clean - flutter pub get - - - name: Build iOS - run: | - bash ios/build.sh - - - name: Upload Artifacts - uses: actions/upload-artifact@v4 - with: - name: ios-artifacts - path: build/app/outputs/flutter-ipa/ - - # ============ 6. 发布 Release(仅当打 tag 时) ============ - create_release: - name: Create Release & Upload Assets - needs: [build_android, build_ios] - runs-on: macos,flutter - if: startsWith(github.ref, 'refs/tags/') - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Download Artifacts - uses: actions/download-artifact@v4 - - - name: Generate Release Description - run: | - bash release_description_generator.sh - cat changelog.md - - - name: Upload to Gitea Package Registry & Create Release - env: - STARLOCK_VERSION: ${{ split(github.ref, '/')[2] }} # 提取 tag 名,如 v1.0.0 -> v1.0.0 - run: | - TAG_NAME="${STARLOCK_VERSION}" - VERSION_PART="${TAG_NAME#v}" # 去掉 v 前缀 - - # 上传到 Gitea 通用包(Generic Package) - curl -f -i \ - -H "Authorization: Bearer $CI_GITEA_TOKEN" \ - --upload-file "starlock-sky-release-${TAG_NAME}.apk" \ - "$CI_GITEA_SERVER_URL/api/packages/$GITHUB_REPOSITORY_OWNER/StarLock/$VERSION_PART/starlock-sky-release-${TAG_NAME}.apk" - - curl -f -i \ - -H "Authorization: Bearer $CI_GITEA_TOKEN" \ - --upload-file "starlock-sky-release-${TAG_NAME}.aab" \ - "$CI_GITEA_SERVER_URL/api/packages/$GITHUB_REPOSITORY_OWNER/StarLock/$VERSION_PART/starlock-sky-release-${TAG_NAME}.aab" - - curl -f -i \ - -H "Authorization: Bearer $CI_GITEA_TOKEN" \ - --upload-file "starlock-sky-release-${TAG_NAME}.ipa" \ - "$CI_GITEA_SERVER_URL/api/packages/$GITHUB_REPOSITORY_OWNER/StarLock/$VERSION_PART/starlock-sky-release-${TAG_NAME}.ipa" - - # 创建 Gitea Release(使用 Gitea API) - RELEASE_NOTES="$(cat changelog.md)" - curl -f -i -X POST \ - -H "Authorization: Bearer $CI_GITEA_TOKEN" \ - -H "Content-Type: application/json" \ - -d '{ - "tag_name": "'"$TAG_NAME"'", - "target_commitish": "'"$GITHUB_SHA"'", - "title": "Release '"$TAG_NAME"'", - "note": '"$(printf '%s' "$RELEASE_NOTES" | jq -R -s '.')"', - "is_draft": false, - "is_prerelease": false - }' \ - "$CI_GITEA_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases" - - # ============ 7. 通知 ============ - notify_success: - name: Notify on Success - needs: [create_release, build_android, build_ios] - runs-on: macos,flutter - if: success() - steps: - - run: bash notify.sh success - - notify_failure: - name: Notify on Failure - needs: [build_android, build_ios, create_release] - runs-on: macos,flutter - if: failure() - steps: - - run: bash notify.sh failure - - # ============ 8. 清理 ============ - clean_up: - name: Clean Workspace - runs-on: macos,flutter - needs: [notify_success, notify_failure] - if: always() - steps: - - name: Reset Git - run: | - git reset --hard - git clean -fdx \ No newline at end of file + ls ${{ gitea.workspace }} + - run: echo "🍏 This job's status is ${{ job.status }}." \ No newline at end of file From 725ef31640c1cc32201f0057b60935d0425fae96 Mon Sep 17 00:00:00 2001 From: liyi Date: Mon, 22 Sep 2025 17:38:39 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=E6=B5=8B=E8=AF=95ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 394c8076..f78b7449 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -4,7 +4,7 @@ on: [push] jobs: Explore-Gitea-Actions: - runs-on: ubuntu-latest + runs-on: flutter steps: - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" From a8cc945d61bb64176a6b72821d19269267658801 Mon Sep 17 00:00:00 2001 From: liyi Date: Mon, 22 Sep 2025 17:46:41 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E6=B5=8B=E8=AF=95ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci.yml | 262 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 248 insertions(+), 14 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index f78b7449..0ec3351a 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -1,19 +1,253 @@ -name: Gitea Actions Demo -run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 -on: [push] +# .gitea/workflows/ci.yml + +name: Flutter CI/CD Pipeline + +# 触发条件 +on: + push: + branches: + - develop_sky + - release_sky + - master_sky + - canary_release_sky + - /^feat_[a-zA-Z]+$/ # 注意:Gitea 不支持正则分支名直接写在 YAML 中,需用 if 判断 + tags: + - v* # 匹配 v1.0.0 等 tag + pull_request: + branches: + - develop_sky + - release_sky + - canary_release_sky + - /^feat_[a-zA-Z]+$/ + +# 全局环境变量 +env: + LC_ALL: en_US.UTF-8 + LANG: en_US.UTF-8 + PUB_HOSTED_URL: https://pub.flutter-io.cn + FLUTTER_STORAGE_BASE_URL: https://storage.flutter-io.cn + +# 所有 job 共用的 runner 标签 +defaults: + run: + shell: bash jobs: - Explore-Gitea-Actions: - runs-on: flutter + # ============ 1. 打印环境信息 ============ + print_env: + name: Print Environment + runs-on: macos,flutter # 必须匹配你 Runner 的 labels + if: | + contains(github.ref, 'develop_sky') || + contains(github.ref, 'release_sky') || + contains(github.ref, 'canary_release_sky') || + startsWith(github.ref, 'refs/heads/feat_') || + startsWith(github.ref, 'refs/tags/v') steps: - - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" - - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - - name: Check out repository code + - name: Checkout Code uses: actions/checkout@v4 - - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository + + - name: Set up Ruby run: | - ls ${{ gitea.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." \ No newline at end of file + export PATH="/opt/homebrew/bin:$PATH" + eval "$(rbenv init -)" + rbenv global 2.6.10 + ruby -v + which ruby + gem env + + - name: Print Env + run: | + java --version + printenv | sort + + - name: Set NEXT_VERSION from file + run: | + echo "NEXT_VERSION=$(cat app_new.version)" >> $GITHUB_ENV + if: always() && !cancelled() + + # ============ 2. 生成 Git Tag(仅 master_sky) ============ + generate_git_tag: + name: Generate Git Tag + needs: print_env + runs-on: macos,flutter + if: github.branch == 'master_sky' + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Setup SSH & Generate Tag + run: | + bash pre_build.sh sky + project_url=$(echo $CI_GITEA_SERVER_URL | sed 's|http://||') + git remote set-url origin git@gitea.example.com:your-namespace/your-repo.git + bash tag_generator.sh generate_tag + + # ============ 3. 生成下一个版本号 ============ + generate_next_version: + name: Generate Next Version + needs: print_env + runs-on: macos,flutter + if: | + contains(github.ref, 'develop_sky') || + contains(github.ref, 'release_sky') || + contains(github.ref, 'canary_release_sky') || + startsWith(github.ref, 'refs/heads/feat_') + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Generate Version + run: | + bash tag_generator.sh generate_version + id: version_gen + + - name: Save Version for Downstream + run: | + echo "NEXT_VERSION=$(cat app_new.version)" >> $GITHUB_ENV + if: always() + outputs: + next_version: ${{ env.NEXT_VERSION }} + + # ============ 4. 构建 Android ============ + build_android: + name: Build Android APK/AAB + needs: [print_env, generate_next_version] + runs-on: macos,flutter + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Setup Flutter & Fastlane (Android) + run: | + export PATH="/opt/homebrew/bin:$PATH" + eval "$(rbenv init -)" + rbenv global 2.6.10 + bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/ + bundle install --gemfile android/Gemfile --path vendor/bundle_android --quiet + flutter clean + flutter pub get + + - name: Build Android + run: | + bash android/build.sh + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: android-artifacts + path: build/app/outputs/flutter-apk/ + + # ============ 5. 构建 iOS ============ + build_ios: + name: Build iOS IPA + needs: [print_env, generate_next_version] + runs-on: macos,flutter + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Setup Flutter & Fastlane (iOS) + run: | + export PATH="/opt/homebrew/bin:$PATH" + eval "$(rbenv init -)" + rbenv global 2.6.10 + bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/ + bundle install --gemfile ios/Gemfile --path vendor/bundle_ios --quiet + flutter clean + flutter pub get + + - name: Build iOS + run: | + bash ios/build.sh + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: ios-artifacts + path: build/app/outputs/flutter-ipa/ + + # ============ 6. 发布 Release(仅当打 tag 时) ============ + create_release: + name: Create Release & Upload Assets + needs: [build_android, build_ios] + runs-on: macos,flutter + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Download Artifacts + uses: actions/download-artifact@v4 + + - name: Generate Release Description + run: | + bash release_description_generator.sh + cat changelog.md + + - name: Upload to Gitea Package Registry & Create Release + env: + STARLOCK_VERSION: ${{ split(github.ref, '/')[2] }} # 提取 tag 名,如 v1.0.0 -> v1.0.0 + run: | + TAG_NAME="${STARLOCK_VERSION}" + VERSION_PART="${TAG_NAME#v}" # 去掉 v 前缀 + + # 上传到 Gitea 通用包(Generic Package) + curl -f -i \ + -H "Authorization: Bearer $CI_GITEA_TOKEN" \ + --upload-file "starlock-sky-release-${TAG_NAME}.apk" \ + "$CI_GITEA_SERVER_URL/api/packages/$GITHUB_REPOSITORY_OWNER/StarLock/$VERSION_PART/starlock-sky-release-${TAG_NAME}.apk" + + curl -f -i \ + -H "Authorization: Bearer $CI_GITEA_TOKEN" \ + --upload-file "starlock-sky-release-${TAG_NAME}.aab" \ + "$CI_GITEA_SERVER_URL/api/packages/$GITHUB_REPOSITORY_OWNER/StarLock/$VERSION_PART/starlock-sky-release-${TAG_NAME}.aab" + + curl -f -i \ + -H "Authorization: Bearer $CI_GITEA_TOKEN" \ + --upload-file "starlock-sky-release-${TAG_NAME}.ipa" \ + "$CI_GITEA_SERVER_URL/api/packages/$GITHUB_REPOSITORY_OWNER/StarLock/$VERSION_PART/starlock-sky-release-${TAG_NAME}.ipa" + + # 创建 Gitea Release(使用 Gitea API) + RELEASE_NOTES="$(cat changelog.md)" + curl -f -i -X POST \ + -H "Authorization: Bearer $CI_GITEA_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "tag_name": "'"$TAG_NAME"'", + "target_commitish": "'"$GITHUB_SHA"'", + "title": "Release '"$TAG_NAME"'", + "note": '"$(printf '%s' "$RELEASE_NOTES" | jq -R -s '.')"', + "is_draft": false, + "is_prerelease": false + }' \ + "$CI_GITEA_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases" + + # ============ 7. 通知 ============ + notify_success: + name: Notify on Success + needs: [create_release, build_android, build_ios] + runs-on: macos,flutter + if: success() + steps: + - run: bash notify.sh success + + notify_failure: + name: Notify on Failure + needs: [build_android, build_ios, create_release] + runs-on: macos,flutter + if: failure() + steps: + - run: bash notify.sh failure + + # ============ 8. 清理 ============ + clean_up: + name: Clean Workspace + runs-on: macos,flutter + needs: [notify_success, notify_failure] + if: always() + steps: + - name: Reset Git + run: | + git reset --hard + git clean -fdx \ No newline at end of file