-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (129 loc) · 5.01 KB
/
build.yml
File metadata and controls
149 lines (129 loc) · 5.01 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
name: 'Build'
on:
push:
branches:
- dev
tags:
- 'v*'
pull_request:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
ARM_NONE_EABI_GCC_VERSION: 14.2.1-1.1
PICO_SDK_VERSION: 2.2.0
# 'softprops/action-gh-release' needs write access to create releases and upload assets.
# Builds on 'dev'/PRs never reach the release step, so this is harmless for them.
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clean workspace
run: |
echo "Cleaning up previous run"
rm -rf "${{ github.workspace }}"
mkdir -p "${{ github.workspace }}"
- name: Restore cached toolchain and pico-sdk
id: cache
uses: actions/cache/restore@v5
with:
path: |
arm-none-eabi-gcc
pico-sdk
key: gcc-${{ env.ARM_NONE_EABI_GCC_VERSION }}-pico-sdk-${{ env.PICO_SDK_VERSION }}
- name: Install cmake
run: |
sudo apt-get install cmake
- name: Install ARM GCC ${{ env.ARM_NONE_EABI_GCC_VERSION }}
if: steps.cache.outputs.cache-hit != 'true'
run: |
wget https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v${{ env.ARM_NONE_EABI_GCC_VERSION }}/xpack-arm-none-eabi-gcc-${{ env.ARM_NONE_EABI_GCC_VERSION }}-linux-x64.tar.gz
tar -xzf xpack-arm-none-eabi-gcc-${{ env.ARM_NONE_EABI_GCC_VERSION }}-linux-x64.tar.gz
mv xpack-arm-none-eabi-gcc-${{ env.ARM_NONE_EABI_GCC_VERSION }} arm-none-eabi-gcc
- name: Add ARM GCC to PATH
run: |
export PATH=$PWD/arm-none-eabi-gcc/bin:$PATH
echo "$PWD/arm-none-eabi-gcc/bin" >> $GITHUB_PATH
arm-none-eabi-gcc --version
- name: Checkout firmware
uses: actions/checkout@v6
with:
path: firmware
submodules: recursive
- name: 'Get commit details'
id: names
env:
GH_TOKEN: ${{ github.token }}
run: |
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
TYPE="pull"
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
TYPE="tag"
else
TYPE="other"
fi
python3 firmware/scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE"
echo "event_type=$TYPE" >> $GITHUB_OUTPUT
- name: Checkout pico-sdk/${{ env.PICO_SDK_VERSION }}
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/checkout@v6
with:
repository: raspberrypi/pico-sdk
ref: ${{ env.PICO_SDK_VERSION }}
path: pico-sdk
- name: Checkout pico-sdk submodules
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}/pico-sdk
run: git submodule update --init
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
working-directory: ${{github.workspace}}/firmware
run: cmake -E make_directory ${{github.workspace}}/firmware/build
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/firmware/build
run: PICO_SDK_PATH=../../pico-sdk cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE
- name: Build
working-directory: ${{github.workspace}}/firmware/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE --parallel $(nproc)
- name: Save Cache
id: cache-save
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: |
arm-none-eabi-gcc
pico-sdk
key: ${{ steps.cache.outputs.cache-primary-key }}
- name: 'Prepare artifact'
shell: bash
run: |
rm -rf artifacts
mkdir artifacts
cp "${{github.workspace}}/firmware/build/flipperone_debug_probe.uf2" \
"artifacts/flipper-one-debug-probe-f150-firmware-${SUFFIX}.uf2"
- name: 'Upload artifact'
uses: actions/upload-artifact@v7
with:
# archive: false uploads the .uf2 as-is, with no .zip wrapper (v7+ feature).
# Only a single file is allowed, and the artifact name is taken from the file
# name itself, so the 'name' input is omitted (it would be ignored anyway).
path: artifacts/*.uf2
if-no-files-found: error
archive: false
- name: 'Create GitHub Release'
# Only on version-tag pushes (v*). Creates the release for the tag and
# attaches the .uf2 built above. action-gh-release uses the built-in
# GITHUB_TOKEN by default, so no secret needs to be configured.
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v3
with:
files: artifacts/*.uf2
generate_release_notes: true
fail_on_unmatched_files: true