-
Notifications
You must be signed in to change notification settings - Fork 2
261 lines (224 loc) · 8.23 KB
/
build_dev.yaml
File metadata and controls
261 lines (224 loc) · 8.23 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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
name: Dev - 🚧 build package
on:
push:
branches:
- dev
jobs:
commit-check:
name: Commit Checker
outputs:
success: ${{ steps.check.outputs.success }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check last commit
id: check
run: |
LAST_COMMITTER=$(git log -1 --pretty=format:'%an')
if [[ "$LAST_COMMITTER" == "GitHub Actions" ]]; then
echo "Last commit was made by GitHub Actions. Exiting..."
echo "::set-output name=success::false"
else
echo "Last commit was made by a user. Executing..."
echo "::set-output name=success::true"
fi
version:
name: Version & Build
needs: commit-check
if: needs.commit-check.outputs.success == 'true'
runs-on: macos-latest
environment: release
permissions:
contents: write
outputs:
version: ${{ steps.get_new_version.outputs.result}}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{secrets.ELEVATED_TOKEN}}
- name: 📇 Configure git
run: |
git fetch --prune --unshallow
git config --global user.name "GitHub Actions"
git config --global user.email "gh-actions@merckgroup.com"
shell: bash
# Retrieve the new version
- name: 🔂 Run standard-version
uses: actions/github-script@v7
with:
script: |
const {execSync} = require('child_process');
execSync('npx standard-version --skip.tag --prerelease', {stdio: 'inherit'});
# Retrieve the new version
- name: ⏎ Get new version
uses: actions/github-script@v7
id: get_new_version
with:
result-encoding: string
script: |
const fs = require('fs');
const package = JSON.parse(fs.readFileSync('package.json', 'utf8'));
return package.version;
- name: Print new version
run: echo ${{ steps.get_new_version.outputs.result}}
# Bump the pubspec.yaml file
- name: ⬆️ Bump pubspec.yaml
uses: emdgroup/mtrust-urp/.github/shared_actions/update-pubspec@dev
with:
version: ${{ steps.get_new_version.outputs.result}}
directory: .
- name: 📝 Update version in readme
uses: emdgroup/mtrust-urp/.github/shared_actions/update-pubspec-readme-version@dev
with:
directory: .
# Create artifact with versioned files
- name: 📦 Create versioned files artifact
uses: actions/upload-artifact@v4
with:
name: versioned-files
path: |
package.json
pubspec.yaml
README.md
retention-days: 1
- name: Setup Dart
uses: dart-lang/setup-dart@v1
- name: Prepare Flutter
uses: emdgroup/mtrust-urp/.github/shared_actions/prepare-flutter@dev
with:
directory: "."
- name: Validate Flutter
uses: emdgroup/mtrust-urp/.github/shared_actions/validate-flutter@dev
with:
directory: "."
is_package: true
- name: Check licenses
uses: emdgroup/mtrust-urp/.github/shared_actions/check-dart-licenses@dev
with:
directory: "."
matrix-generation:
name: Generate Compatibility Matrix
needs: version
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Fetch firmware versions
uses: ./.github/actions/fetch-firmware-versions
id: fetch-firmware-versions
with:
token: ${{secrets.ELEVATED_TOKEN}}
- name: Generate compatibility matrix
id: generate-matrix
run: |
# Parse the JSON arrays and create a matrix
firmware_versions=$(echo '${{ steps.fetch-firmware-versions.outputs.versions }}' | jq -r '.[]')
sdk_versions='${{ needs.version.outputs.version }}'
echo "Latest 3 major.minor firmware versions:"
echo "$firmware_versions"
echo ""
echo "Current SDK version:"
echo "$sdk_versions"
echo ""
# Create matrix combinations using current SDK version with latest 3 firmware versions
matrix_combinations="[]"
count=0
while IFS= read -r firmware; do
# For each firmware version, use the current SDK version
combination=$(jq -n --arg fw "$firmware" --arg sdk "$sdk_versions" '{firmware: $fw, sdk: $sdk}')
# Add to matrix array
matrix_combinations=$(echo "$matrix_combinations" | jq --argjson combo "$combination" '. += [$combo]')
count=$((count + 1))
done <<< "$firmware_versions"
# Validate JSON before output
if echo "$matrix_combinations" | jq empty 2>/dev/null; then
# Use jq to compact the JSON for GitHub Actions output
compact_matrix=$(echo "$matrix_combinations" | jq -c .)
echo "matrix=$compact_matrix" >> $GITHUB_OUTPUT
echo "Generated matrix with $count combinations (latest 3 firmware × current SDK version)"
echo "Matrix preview:"
echo "$matrix_combinations" | jq '.[0:3]' # Show first 3 combinations
else
echo "Error: Invalid JSON generated"
echo "Generated content:"
echo "$matrix_combinations"
exit 1
fi
compatibility-tests:
name: Compatibility Tests
needs: matrix-generation
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.matrix-generation.outputs.matrix) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Test compatibility
uses: ./.github/actions/test-compatibility
with:
token: ${{secrets.ELEVATED_TOKEN}}
firmware_version: ${{ matrix.firmware }}
sdk_version: ${{ matrix.sdk }}
generate-compatibility-matrix:
name: Generate Compatibility Matrix
needs: [version, compatibility-tests]
if: always()
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate matrix
uses: ./.github/actions/generate-matrix
- name: Upload compatibility matrix artifact
uses: actions/upload-artifact@v4
with:
name: firmware-compatibility-matrix
path: assets/firmware_compatibility.json
release:
name: Release Package
needs: [version, generate-compatibility-matrix]
runs-on: macos-latest
environment: release
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{secrets.ELEVATED_TOKEN}}
- name: Download compatibility matrix
uses: actions/download-artifact@v4
with:
name: firmware-compatibility-matrix
path: assets/
# Restore versioned files from artifact
- name: 📦 Restore versioned files
uses: actions/download-artifact@v4
with:
name: versioned-files
path: .
- name: 📇 Configure git
run: |
git fetch --prune --unshallow
git config --global user.name "GitHub Actions"
git config --global user.email "gh-actions@merckgroup.com"
shell: bash
# We first commit with proper message and add an empty commit to keep the files history clean
- name: Update repo versions
run: |
git add .
git commit -m "chore(release): ${{ needs.version.outputs.version }}"
git commit --allow-empty -m "chore(release): ${{ needs.version.outputs.version }} [skip ci]"
git push origin dev
# For this part it is important to not push a commit with [skip ci] before the tag release
- name: Push tag for pub.dev
run: |
git commit --allow-empty -m "chore(release): ${{ needs.version.outputs.version }}"
git tag -a v${{ needs.version.outputs.version }} -m "Pub.dev version ${{ needs.version.outputs.version }}"
git push origin v${{ needs.version.outputs.version }}