This repository has been archived by the owner on Apr 23, 2023. It is now read-only.
forked from Flipper-XFW/Xtreme-Firmware
-
Notifications
You must be signed in to change notification settings - Fork 3
160 lines (139 loc) · 4.66 KB
/
build.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: 'Build'
on:
push:
branches:
- dev
- "release*"
tags:
- '*'
pull_request:
env:
TARGETS: f7 f18
DEFAULT_TARGET: f7
FBT_TOOLCHAIN_PATH: /home/runner/work
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]; then
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get commit details'
id: names
run: |
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
TYPE="pull"
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
TYPE="tag"
else
TYPE="other"
fi
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE"
echo random_hash=$(openssl rand -base64 40 | shasum -a 256 | awk '{print $1}') >> $GITHUB_OUTPUT
echo "event_type=$TYPE" >> $GITHUB_OUTPUT
- name: 'Make artifacts directory'
run: |
rm -rf artifacts
mkdir artifacts
- name: 'Bundle scripts'
run: |
tar czpf artifacts/flipper-z-any-scripts-${SUFFIX}.tgz scripts debug
- name: 'Build the firmware'
run: |
set -e
for TARGET in ${TARGETS}; do
TARGET="$(echo "${TARGET}" | sed 's/f//')"; \
./fbt TARGET_HW=$TARGET copro_dist updater_package \
${{ startsWith(github.ref, 'refs/tags') && 'DEBUG=0 COMPACT=1' || '' }}
done
- name: 'Move upload files'
run: |
set -e
for TARGET in ${TARGETS}; do
mv dist/${TARGET}-*/* artifacts/
done
- name: "Check for uncommitted changes"
run: |
git diff --exit-code
- name: 'Bundle resources'
run: |
tar czpf "artifacts/flipper-z-any-resources-${SUFFIX}.tgz" -C assets resources
- name: 'Bundle core2 firmware'
run: |
cp build/core2_firmware.tgz "artifacts/flipper-z-any-core2_firmware-${SUFFIX}.tgz"
- name: 'Updater artifact'
uses: actions/upload-artifact@v3
with:
name: updater
path: |
artifacts/f7-*
- name: 'Firmware artifact'
uses: actions/upload-artifact@v3
with:
name: firmware
path: |
artifacts
# - name: 'Find Previous Comment'
# if: ${{ github.event.pull_request }}
# uses: peter-evans/find-comment@v1
# id: fc
# with:
# issue-number: ${{ github.event.pull_request.number }}
# comment-author: 'github-actions[bot]'
# body-includes: 'Compiled firmware for commit'
# - name: Artifact info
# id: artifact-info
# uses: dawidd6/action-download-artifact@v2
# with:
# dry_run: true
# - name: 'Create or update comment'
# if: ${{ github.event.pull_request}}
# uses: peter-evans/create-or-update-comment@v1
# with:
# comment-id: ${{ steps.fc.outputs.comment-id }}
# issue-number: ${{ github.event.pull_request.number }}
# body: |
# **Compiled firmware for commit `${{steps.names.outputs.commit_sha}}`:**
# - [📦 Update package](${{steps.artifact-info.outputs.artifacts[0].archive_download_url}})
# edit-mode: replace
compact:
if: ${{ !startsWith(github.ref, 'refs/tags') }}
runs-on: ubuntu-latest
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]
then
git submodule status \
|| git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get commit details'
run: |
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
TYPE="pull"
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
TYPE="tag"
else
TYPE="other"
fi
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE"
- name: 'Build the firmware'
run: |
set -e
for TARGET in ${TARGETS}; do
TARGET="$(echo "${TARGET}" | sed 's/f//')"; \
./fbt TARGET_HW=$TARGET DEBUG=0 COMPACT=1 updater_package
done