From d2c47d6a949b460aa6c9286370ce00cd3e62bb15 Mon Sep 17 00:00:00 2001 From: orz12 Date: Sat, 25 May 2024 12:06:43 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E4=BF=AE=E6=94=B9=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E7=89=88=E6=9C=AC=E5=8F=B7=E7=94=9F=E6=88=90?= =?UTF-8?q?=E9=80=BB=E8=BE=91"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 94b9516a4e2116aa4b059e11dfb6846c2e0d6c51. --- .github/workflows/CI.yml | 50 +++++++++----------------------------- .github/workflows/main.yml | 28 ++++++++------------- 2 files changed, 21 insertions(+), 57 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e311cc97..6b71f0b3 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: push: branches: - - 'main' + - '*' paths-ignore: - '**.md' - '**.txt' @@ -23,46 +23,19 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - #- name: 获取first parent commit次数 - # id: get-first-parent-commit-count - # run: | - # version=$(yq e .version pubspec.yaml | cut -d "+" -f 1) - # recent_release_tag=$(git tag -l | grep $version | egrep -v "[-|+]" || true) - # if [[ "x$recent_release_tag" == "x" ]]; then - # echo "当前版本tag不存在,请手动生成tag." - # exit 1 - # fi - # git log --oneline HEAD - # first_parent_commit_count=$(git rev-list --first-parent --count $recent_release_tag..HEAD) - # echo "count=$first_parent_commit_count" >> $GITHUB_OUTPUT - - - name: 从tag获取之前的version_code与beta版本号 - id: get-previous-codes - run: | - version=$(yq e .version pubspec.yaml | cut -d "+" -f 1) - last_tag=$(git describe --tags | awk -F"-" '{for(i=1;i<=NF-2;i++) printf "%s", $i}') - echo $last_tag | grep "+" || echo "Tag格式不正确" && exit 1 - echo $last_tag | grep $version || echo "当前版本tag不存在,请手动添加tag." && exit 1 - - version_code=$(echo $last_tag | cut -d "+" -f 2) - beta_code=0$(echo $last_tag | cut -d "+" -f 1 | cut -d "." -f 4) - - echo "beta-code=$beta_code" >> $GITHUB_OUTPUT - echo "version-code=$version_code" >> $GITHUB_OUTPUT + uses: actions/checkout@v2 - name: 更新版本号 id: version run: | # 读取版本号 - version_name=$(yq e .version pubspec.yaml | cut -d "+" -f 1) - let beta_code=${{ steps.get-previous-codes.outputs.beta-code }}+1 - let version_code=${{ steps.get-previous-codes.outputs.version-code }}+1 + VERSION=$(yq e .version pubspec.yaml) + + # 获取GitHub Actions的run_number + RUN_NUMBER=${{ github.run_number }} + # 构建新版本号 - NEW_VERSION=${version_name}-beta.${beta_code}+${version_code} + NEW_VERSION=$(echo $VERSION | awk -F+ -v run_number="$RUN_NUMBER" '{print $1"+"run_number}') # 输出新版本号 echo "New version: $NEW_VERSION" @@ -132,10 +105,9 @@ jobs: - name: 重命名应用 run: | - version_name=$(yq e .version pubspec.yaml | cut -d "+" -f 1) for file in build/app/outputs/flutter-apk/app-*.apk; do if [[ $file =~ app-(.?*)release.apk ]]; then - new_file_name="build/app/outputs/flutter-apk/Pili-${BASH_REMATCH[1]}${version_name}.apk" + new_file_name="build/app/outputs/flutter-apk/Pili-${BASH_REMATCH[1]}${{ needs.update_version.outputs.new_version }}.apk" mv "$file" "$new_file_name" fi done @@ -177,9 +149,9 @@ jobs: - name: 重命名应用 run: | - version_name=$(yq e .version pubspec.yaml | cut -d "+" -f 1) + DATE=${{ steps.date.outputs.date }} for file in app.ipa; do - new_file_name="build/Pili-${version_name}.ipa" + new_file_name="build/Pili-${{ needs.update_version.outputs.new_version }}.ipa" mv "$file" "$new_file_name" done diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 454e55e6..78230645 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,8 +5,7 @@ on: push: # push tag时触发 tags: - - "[0-9]+.[0-9]+.[0-9]+*" - - "!*beta*" + - "v*.*.*" # 可以有多个jobs jobs: @@ -48,14 +47,6 @@ jobs: env: KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} - - name: 获取版本号 - id: version - run: echo "version=${GITHUB_REF#refs/tags/}" >>$GITHUB_OUTPUT - - - name: 修改pubspec.yaml - run: | - sed -i "s/version: .*/version: ${{ steps.version.outputs.version }}/g" pubspec.yaml - - name: flutter build apk run: flutter build apk --release --split-per-abi env: @@ -70,6 +61,9 @@ jobs: KEY_ALIAS: ${{ secrets.KEY_ALIAS }} KEY_PASSWORD: ${{ secrets.KEY_PASSWORD}} + - name: 获取版本号 + id: version + run: echo "version=${GITHUB_REF#refs/tags/v}" >>$GITHUB_OUTPUT # - name: 获取当前日期 # id: date @@ -77,6 +71,7 @@ jobs: - name: 重命名应用 run: | + # DATE=${{ steps.date.outputs.date }} for file in build/app/outputs/flutter-apk/app-*.apk; do if [[ $file =~ app-(.?*)release.apk ]]; then new_file_name="build/app/outputs/flutter-apk/Pili-${BASH_REMATCH[1]}${{ steps.version.outputs.version }}.apk" @@ -105,22 +100,19 @@ jobs: cache: true flutter-version: 3.16.5 - - name: 获取版本号 - id: version - run: echo "version=${GITHUB_REF#refs/tags/}" >>$GITHUB_OUTPUT - - - name: 修改pubspec.yaml - run: | - sed -i "s/version: .*/version: ${{ steps.version.outputs.version }}/g" pubspec.yaml - - name: flutter build ipa run: | flutter build ios --release --no-codesign ln -sf ./build/ios/iphoneos Payload zip -r9 app.ipa Payload/runner.app + - name: 获取版本号 + id: version + run: echo "version=${GITHUB_REF#refs/tags/v}" >>$GITHUB_OUTPUT + - name: 重命名应用 run: | + DATE=${{ steps.date.outputs.date }} for file in app.ipa; do new_file_name="build/Pili-${{ steps.version.outputs.version }}.ipa" mv "$file" "$new_file_name"