-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (68 loc) · 2.4 KB
/
Copy pathrelease.yml
File metadata and controls
81 lines (68 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Build & Release
# tag 驱动发版:版本语义由 tag 唯一定义(打 tag 用 tag.yml 一键入口)。
# Flutter 单目标(Android APK),无 byte-code 那样的多平台 matrix 与前端预构建。
# 版本经 --build-name 注入(不改 pubspec,保持"零发版提交")。
# 触发方式:手动推 tag(on:push);或被 tag.yml 以 workflow_call 链式调用——
# 后者必须存在,因为 GITHUB_TOKEN 推的 tag 不会触发 on:push(GitHub 防递归)。
on:
push:
tags: ['v*']
workflow_call:
inputs:
version:
description: '版本号(tag.yml 传入;留空则从 GITHUB_REF_NAME 解析)'
required: false
type: string
default: ''
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# cliff 生成发版说明需要全历史与 tag
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- uses: subosito/flutter-action@v2
with:
flutter-version: 3.47.2
channel: stable
cache: true
- name: Resolve version
id: ver
run: |
RAW="${{ inputs.version || github.ref_name }}"
echo "VERSION=${RAW#v}" >> $GITHUB_OUTPUT
- name: Pub get
run: flutter pub get
# 发版前门禁:静态检查与测试不过则中止
- name: Analyze
run: flutter analyze
- name: Test
run: flutter test
- name: Build APK
run: flutter build apk --release --build-name=${{ steps.ver.outputs.VERSION }} --build-number=${{ github.run_number }}
- name: Rename APK
run: |
mv build/app/outputs/flutter-apk/app-release.apk \
byte_code_app_v${{ steps.ver.outputs.VERSION }}.apk
- name: Generate changelog
uses: orhun/git-cliff-action@v4
id: cliff
with:
config: cliff.toml
args: --latest --strip header
env:
# 多行内容经文件传给 release 更稳;outputs.changelog 是文件路径
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: byte_code_app_v${{ steps.ver.outputs.VERSION }}.apk
body_path: CHANGELOG.md