-
-
Notifications
You must be signed in to change notification settings - Fork 1
145 lines (117 loc) · 4.74 KB
/
ci.yml
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Test and Release
on:
push:
branches: ["*"]
pull_request:
branches: ["*"]
jobs:
commitlint:
name: Commitlint
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'chore(release):') && !contains(github.event.head_commit.message, 'chore(merge_back):')"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5
test:
name: Tests
runs-on: ubuntu-latest
needs: commitlint
outputs:
branch: ${{ steps.branchinfo.outputs.branch }}
steps:
- uses: actions/checkout@v4
- name: Store the branch name
id: branchinfo
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
- name: Check if we were able to save branch info
run: echo ${{ steps.branchinfo.outputs.branch }}
- name: Setup Dart SDK
uses: dart-lang/setup-dart@v1
- name: Get dependencies
run: dart pub get
- name: Check dart formatting
run: dart format --set-exit-if-changed .
- name: Statically analyze the Dart code for any errors.
run: dart analyze .
- name: Run Tests with coverage
run: dart run coverage:test_with_coverage
- name: Upload coverage
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: coverage/lcov.info
release:
name: Prepare Release
runs-on: ubuntu-latest
needs: test
if: needs.test.outputs.branch == 'release'
steps:
- name: Setup Dart SDK
uses: dart-lang/setup-dart@v1
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- name: Get dependencies
run: dart pub get
- name: Get current version
id: currentVersion
run: echo "value=$(dart run release_tools current_version)" >> $GITHUB_OUTPUT
- name: Get commitId of last tag of that version
id: lastCommitId
run: echo "value=$(dart run release_tools remote_tag_id ${{ steps.currentVersion.outputs.value }})" >> $GITHUB_OUTPUT
- name: Use commitId to check if we should release
id: shouldRelease
run: echo "value=$(dart run release_tools should_release --from ${{ steps.lastCommitId.outputs.value }})" >> $GITHUB_OUTPUT
- run: echo "Should we release? ${{ steps.shouldRelease.outputs.value }}"
- name: If we should release get the next version
if: steps.shouldRelease.outputs.value == 'yes'
id: nextVersion
run: echo "value=$(dart run release_tools next_version --ensureMajor --from ${{ steps.lastCommitId.outputs.value }})" >> $GITHUB_OUTPUT
- run: echo "RELEASING ${{ steps.nextVersion.outputs.value }}"
- name: Update versions
if: steps.shouldRelease.outputs.value == 'yes'
id: updateVersion
run: |
dart run release_tools update_version ${{ steps.nextVersion.outputs.value }}
dart run release_tools update_version --file="lib/release_tools_version.dart" ${{ steps.nextVersion.outputs.value }}
dart run release_tools update_version --file="README.md" --template="pub global activate release_tools [VERSION]" ${{ steps.nextVersion.outputs.value }}
- name: Write changelog
id: changelog
if: steps.shouldRelease.outputs.value == 'yes'
run: |
output=$(dart run release_tools changelog --from ${{ steps.lastCommitId.outputs.value }} ${{ steps.nextVersion.outputs.value }})
output="${output//'%'/'%25'}"
output="${output//$'\n'/'%0A'}"
output="${output//$'\r'/'%0D'}"
echo "summary=$output" >> $GITHUB_OUTPUT
- name: Commit Release
if: steps.shouldRelease.outputs.value == 'yes'
run: |
git diff
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "chore(release): release for ${{ steps.nextVersion.outputs.value }}"
git push
- name: Create Release
if: steps.shouldRelease.outputs.value == 'yes'
id: createRelease
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.PAT }}
tag: ${{ steps.nextVersion.outputs.value }}
name: Release ${{ steps.nextVersion.outputs.value }}
body: |
Changes in this Release
${{ steps.nextVersion.outputs.value }}
- name: Merge back to main
if: steps.shouldRelease.outputs.value == 'yes'
run: |
git checkout main
git pull
git merge release
git commit -m "chore(merge_back): merge from release ${{ steps.nextVersion.outputs.value }}"
git push