-
-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (75 loc) · 2.82 KB
/
ci.yaml
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
82
83
name: Dart Tests
on:
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
# optional parameters follow
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:" # optional, change this to force refresh cache
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:" # optional, change this to specify the cache path
pub-cache-key: "flutter-pub:os:-:channel:-:version:-:arch:-:hash:" # optional, change this to force refresh cache of dart pub get dependencies
pub-cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:" # optional, change this to specify the cache path
- name: Install dependencies
run: flutter pub get
- name: Prepare env file
run: cp .env.sample .env
- name: Run tests
run: |
dart run full_coverage
flutter test --coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
prepare-release:
runs-on: ubuntu-latest
if: startsWith(github.head_ref, 'release-v')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from branch
id: extract_version
run: |
branch_name="${{ github.head_ref }}"
version="${branch_name#release-v}"
echo "version=v$version" >> $GITHUB_ENV
- name: Generate changelog
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --tag ${{ env.version }}
env:
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
- name: Commit Changelog
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git checkout ${{ github.head_ref }}
git add CHANGELOG.md
git commit -m "Update CHANGELOG for version ${{ env.version }}"
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git ${{ github.head_ref }}
- name: Update version in pubspec.yaml
run: |
version_without_v=${{ env.version }}
version_without_v=${version_without_v#v}
sed -i "s/^version: .*/version: $version_without_v/" pubspec.yaml
git add pubspec.yaml
git commit -m "Update pubspec.yaml version to ${{ env.version }}"
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git ${{ github.head_ref || github.ref_name }}