diff --git a/.github/workflows/build-apk.yml b/.github/workflows/build-apk.yml index 7fd20f6..2ecb472 100644 --- a/.github/workflows/build-apk.yml +++ b/.github/workflows/build-apk.yml @@ -65,6 +65,13 @@ jobs: - name: Install dependencies run: flutter pub get + - name: Read app version + run: | + VERSION=$(sed -n 's/^version: *\([^+]*\)+.*/\1/p' pubspec.yaml) + test -n "$VERSION" || { echo 'Unable to read app version'; exit 1; } + echo "RELEASE_VERSION=$VERSION" >> "$GITHUB_ENV" + echo "RELEASE_TAG=v$VERSION" >> "$GITHUB_ENV" + - name: Configure release signing env: SECRETS_PK8_BASE64: ${{ secrets.SECRETS_PK8_BASE64 }} @@ -95,13 +102,13 @@ jobs: - name: Rename APK run: | mv build/app/outputs/flutter-apk/app-release.apk \ - build/app/outputs/flutter-apk/AstrBot.apk + "build/app/outputs/flutter-apk/AstrBot-v${RELEASE_VERSION}.apk" - name: Upload APK artifact uses: actions/upload-artifact@v4 with: - name: AstrBot - path: build/app/outputs/flutter-apk/AstrBot.apk + name: AstrBot-v${{ env.RELEASE_VERSION }} + path: build/app/outputs/flutter-apk/AstrBot-v${{ env.RELEASE_VERSION }}.apk compression-level: 0 if-no-files-found: error @@ -110,20 +117,64 @@ jobs: github.event_name == 'pull_request' && github.event.pull_request.merged == true run: | - VERSION=$(sed -n 's/^version: *\([^+]*\)+.*/\1/p' pubspec.yaml) - TAG="v${VERSION}" PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || true) - { - printf '更新内容\n\n' - if [ -n "$PREVIOUS_TAG" ]; then - git log --pretty=format:'- %s (%h)' "${PREVIOUS_TAG}..HEAD" - else - git log --pretty=format:'- %s (%h)' HEAD + if [ -n "$PREVIOUS_TAG" ]; then + LOG_RANGE="${PREVIOUS_TAG}..HEAD" + else + LOG_RANGE=HEAD + fi + + NOTES_DIR=$(mktemp -d) + trap 'rm -rf "$NOTES_DIR"' EXIT + for CATEGORY in 新增 优化 修复 更新 修改 移除 其他; do + : > "$NOTES_DIR/$CATEGORY" + done + + python3 - "$LOG_RANGE" "$NOTES_DIR" <<'PY' + import re + import subprocess + import sys + + log_range, notes_dir = sys.argv[1:] + categories = ("新增", "优化", "修复", "更新", "修改", "移除", "其他") + separators = r",,、;;::|//\\\\\\s" + label_pattern = re.compile( + rf"(?:^|[{separators}])(?P