Mod version (#9)

* 统计当前分支第一父提交数作为子版本号

* 打印version变量

* 修正version的格式错误

* 修正语法错误

* 检查当前HEAD?

* 检查当前HEAD

* 末端提交应由HEAD改为FETCH_HEAD

* 避免替换Flutter build-number

* 限制仅在push到main分支时触发Action

* Revert "末端提交应由HEAD改为FETCH_HEAD"

This reverts commit df5b6d0552d173f22e4e40a27366ee3ea4178c65.

* 使用参数`fetch-depth: 0`取得所有分支和tags, 改回HEAD作为统计中的末端提交

* 匹配*.*.*+*格式tag

* 修正filter语法错误

* 改为根据上一个tag计算版本号

* 逻辑短路改为if-else结构

* fix typo
This commit is contained in:
VillagerTom
2024-06-03 01:20:48 +08:00
committed by GitHub
parent 0ed3f6c192
commit 6aca1bbb2f
2 changed files with 63 additions and 22 deletions

View File

@@ -5,7 +5,8 @@ on:
push:
# push tag时触发
tags:
- "v*.*.*"
- "[0-9]+.[0-9]+.[0-9]+*"
- "!*beta*"
# 可以有多个jobs
jobs:
@@ -47,6 +48,14 @@ 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:
@@ -61,9 +70,6 @@ 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
@@ -71,7 +77,6 @@ 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"
@@ -100,19 +105,22 @@ 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"
@@ -143,7 +151,7 @@ jobs:
- name: Get version
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >>$GITHUB_OUTPUT
run: echo "version=${GITHUB_REF#refs/tags/}" >>$GITHUB_OUTPUT
- name: Upload Release
uses: ncipollo/release-action@v1