2021-07-24 16:53:02 +03:00
|
|
|
name: 'Build'
|
|
|
|
|
2021-12-24 22:35:25 +03:00
|
|
|
on:
|
2021-08-17 17:45:23 +03:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- dev
|
|
|
|
tags:
|
2021-08-19 12:56:42 +03:00
|
|
|
- '*'
|
2021-08-17 17:45:23 +03:00
|
|
|
pull_request:
|
2021-07-24 16:53:02 +03:00
|
|
|
|
|
|
|
env:
|
2021-10-12 18:30:55 +03:00
|
|
|
DEFAULT_TARGET: f7
|
2022-12-19 16:07:23 +03:00
|
|
|
FBT_TOOLCHAIN_PATH: /runner/_work
|
2021-07-24 16:53:02 +03:00
|
|
|
|
|
|
|
jobs:
|
2021-12-24 22:35:25 +03:00
|
|
|
main:
|
2023-09-01 06:09:48 +03:00
|
|
|
runs-on: [self-hosted, FlipperZeroShell]
|
2023-09-05 14:49:39 +03:00
|
|
|
strategy:
|
2023-09-05 17:17:16 +03:00
|
|
|
fail-fast: false
|
2023-09-05 14:49:39 +03:00
|
|
|
matrix:
|
|
|
|
target: [f7, f18]
|
2021-07-24 16:53:02 +03:00
|
|
|
steps:
|
2023-03-22 20:26:40 +09:00
|
|
|
- name: 'Wipe workspace'
|
2023-04-28 17:25:20 +03:00
|
|
|
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
|
2021-07-24 16:53:02 +03:00
|
|
|
|
|
|
|
- name: 'Checkout code'
|
2022-12-10 16:10:51 +03:00
|
|
|
uses: actions/checkout@v3
|
2021-07-24 16:53:02 +03:00
|
|
|
with:
|
2023-03-15 19:24:56 +04:00
|
|
|
fetch-depth: 1
|
2021-08-26 20:59:23 +03:00
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
2021-07-24 16:53:02 +03:00
|
|
|
|
2022-09-03 10:09:03 +03:00
|
|
|
- name: 'Get commit details'
|
2022-12-10 16:10:51 +03:00
|
|
|
id: names
|
2021-08-20 20:31:07 +03:00
|
|
|
run: |
|
2023-09-11 19:18:04 +03:00
|
|
|
BUILD_TYPE='DEBUG=1 COMPACT=0'
|
2021-08-20 20:31:07 +03:00
|
|
|
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
2022-09-05 16:40:54 +03:00
|
|
|
TYPE="pull"
|
|
|
|
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
|
|
|
|
TYPE="tag"
|
2023-09-11 19:18:04 +03:00
|
|
|
BUILD_TYPE='DEBUG=0 COMPACT=1'
|
2021-08-20 20:31:07 +03:00
|
|
|
else
|
2022-09-05 16:40:54 +03:00
|
|
|
TYPE="other"
|
2021-08-20 20:31:07 +03:00
|
|
|
fi
|
2023-04-06 17:06:19 +08:00
|
|
|
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE" || cat "${{ github.event_path }}"
|
2022-12-26 23:22:22 +03:00
|
|
|
echo "event_type=$TYPE" >> $GITHUB_OUTPUT
|
2023-09-11 19:18:04 +03:00
|
|
|
echo "FBT_BUILD_TYPE=$BUILD_TYPE" >> $GITHUB_ENV
|
2023-09-05 14:49:39 +03:00
|
|
|
echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV
|
|
|
|
echo "TARGET_HW=$(echo "${{ matrix.target }}" | sed 's/f//')" >> $GITHUB_ENV
|
2022-12-26 23:22:22 +03:00
|
|
|
|
2023-09-05 14:49:39 +03:00
|
|
|
- name: 'Check API versions for consistency between targets'
|
2023-03-05 09:17:33 +04:00
|
|
|
run: |
|
|
|
|
set -e
|
|
|
|
N_API_HEADER_SIGNATURES=`ls -1 firmware/targets/f*/api_symbols.csv | xargs -I {} sh -c "head -n2 {} | md5sum" | sort -u | wc -l`
|
|
|
|
if [ $N_API_HEADER_SIGNATURES != 1 ] ; then
|
|
|
|
echo API versions aren\'t matching for available targets. Please update!
|
2023-09-05 14:49:39 +03:00
|
|
|
echo API versions are:
|
2023-03-05 09:17:33 +04:00
|
|
|
head -n2 firmware/targets/f*/api_symbols.csv
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-09-05 14:49:39 +03:00
|
|
|
- name: 'Build the firmware and apps'
|
2023-09-11 13:51:03 +03:00
|
|
|
id: build-fw
|
2022-12-26 23:22:22 +03:00
|
|
|
run: |
|
2023-09-05 14:49:39 +03:00
|
|
|
./fbt TARGET_HW=$TARGET_HW $FBT_BUILD_TYPE copro_dist updater_package fap_dist
|
2023-09-11 13:51:03 +03:00
|
|
|
echo "firmware_api=$(./fbt TARGET_HW=$TARGET_HW get_apiversion)" >> $GITHUB_OUTPUT
|
2022-04-13 23:50:25 +03:00
|
|
|
|
2023-09-05 14:49:39 +03:00
|
|
|
- name: 'Check for uncommitted changes'
|
2021-12-01 13:21:26 +03:00
|
|
|
run: |
|
2023-09-05 14:49:39 +03:00
|
|
|
git diff --exit-code
|
2021-12-01 13:21:26 +03:00
|
|
|
|
2023-09-05 14:49:39 +03:00
|
|
|
- name: 'Copy build output'
|
2022-08-02 17:05:31 +03:00
|
|
|
run: |
|
|
|
|
set -e
|
2023-09-05 14:49:39 +03:00
|
|
|
rm -rf artifacts map_analyser_files || true
|
|
|
|
mkdir artifacts map_analyser_files
|
|
|
|
cp dist/${TARGET}-*/* artifacts/ || true
|
|
|
|
tar czpf "artifacts/flipper-z-${TARGET}-resources-${SUFFIX}.tgz" \
|
|
|
|
-C assets resources
|
|
|
|
tar czpf "artifacts/flipper-z-${TARGET}-debugapps-${SUFFIX}.tgz" \
|
|
|
|
-C dist/${TARGET}-*/apps/Debug .
|
|
|
|
tar czpf "artifacts/flipper-z-${TARGET}-appsymbols-${SUFFIX}.tgz" \
|
|
|
|
-C dist/${TARGET}-*/debug_elf .
|
|
|
|
|
|
|
|
- name: 'Copy universal artifacts'
|
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork && matrix.target == env.DEFAULT_TARGET }}
|
2022-08-02 16:29:16 +03:00
|
|
|
run: |
|
2023-09-05 14:49:39 +03:00
|
|
|
tar czpf "artifacts/flipper-z-any-scripts-${SUFFIX}.tgz" scripts
|
|
|
|
cp build/core2_firmware.tgz "artifacts/flipper-z-any-core2_firmware-${SUFFIX}.tgz"
|
2022-08-02 16:29:16 +03:00
|
|
|
|
2023-09-05 14:49:39 +03:00
|
|
|
- name: 'Upload artifacts to update server'
|
2021-08-17 18:46:12 +02:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
2022-08-02 17:05:31 +03:00
|
|
|
run: |
|
2023-09-05 14:49:39 +03:00
|
|
|
FILES=$(for ARTIFACT in $(find artifacts -maxdepth 1 -not -type d); do echo "-F files=@${ARTIFACT}"; done)
|
|
|
|
curl --fail -L -H "Token: ${{ secrets.INDEXER_TOKEN }}" \
|
|
|
|
-F "branch=${BRANCH_NAME}" \
|
|
|
|
-F "version_token=${COMMIT_SHA}" \
|
|
|
|
${FILES[@]} \
|
|
|
|
"${{ secrets.INDEXER_URL }}"/firmware/uploadfiles
|
2021-08-17 12:41:08 +03:00
|
|
|
|
2023-09-05 14:49:39 +03:00
|
|
|
- name: 'Copy & analyse map analyser files'
|
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork && matrix.target == env.DEFAULT_TARGET }}
|
2022-08-23 14:29:26 +03:00
|
|
|
run: |
|
2023-06-08 10:16:01 +04:00
|
|
|
cp build/${DEFAULT_TARGET}-firmware-*/firmware.elf.map map_analyser_files/firmware.elf.map
|
|
|
|
cp build/${DEFAULT_TARGET}-firmware-*/firmware.elf map_analyser_files/firmware.elf
|
2022-12-26 23:22:22 +03:00
|
|
|
cp ${{ github.event_path }} map_analyser_files/event.json
|
2023-06-05 14:25:43 +04:00
|
|
|
source scripts/toolchain/fbtenv.sh
|
|
|
|
get_size()
|
|
|
|
{
|
|
|
|
SECTION="$1";
|
|
|
|
arm-none-eabi-size \
|
|
|
|
-A map_analyser_files/firmware.elf \
|
|
|
|
| grep "^$SECTION" | awk '{print $2}'
|
|
|
|
}
|
|
|
|
export BSS_SIZE="$(get_size ".bss")"
|
|
|
|
export TEXT_SIZE="$(get_size ".text")"
|
|
|
|
export RODATA_SIZE="$(get_size ".rodata")"
|
|
|
|
export DATA_SIZE="$(get_size ".data")"
|
|
|
|
export FREE_FLASH_SIZE="$(get_size ".free_flash")"
|
|
|
|
python3 -m pip install mariadb==1.1.6 cxxfilt==0.3.0
|
|
|
|
python3 scripts/map_parser.py map_analyser_files/firmware.elf.map map_analyser_files/firmware.elf.map.all
|
|
|
|
python3 scripts/map_mariadb_insert.py \
|
|
|
|
${{ secrets.AMAP_MARIADB_USER }} \
|
|
|
|
${{ secrets.AMAP_MARIADB_PASSWORD }} \
|
|
|
|
${{ secrets.AMAP_MARIADB_HOST }} \
|
|
|
|
${{ secrets.AMAP_MARIADB_PORT }} \
|
|
|
|
${{ secrets.AMAP_MARIADB_DATABASE }} \
|
|
|
|
map_analyser_files/firmware.elf.map.all
|
2022-12-26 23:22:22 +03:00
|
|
|
|
2023-09-05 14:49:39 +03:00
|
|
|
- name: 'Find previous comment'
|
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork && matrix.target == env.DEFAULT_TARGET && github.event.pull_request }}
|
2023-04-19 15:08:13 +04:00
|
|
|
uses: peter-evans/find-comment@v2
|
2023-09-05 14:49:39 +03:00
|
|
|
id: find-comment
|
2021-08-26 20:59:23 +03:00
|
|
|
with:
|
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
comment-author: 'github-actions[bot]'
|
2023-09-05 14:49:39 +03:00
|
|
|
body-includes: 'Compiled ${{ matrix.target }} firmware for commit'
|
2021-08-26 20:59:23 +03:00
|
|
|
|
2021-09-10 15:05:09 +03:00
|
|
|
- name: 'Create or update comment'
|
2023-09-05 14:49:39 +03:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork && matrix.target == env.DEFAULT_TARGET && github.event.pull_request }}
|
2023-04-19 15:08:13 +04:00
|
|
|
uses: peter-evans/create-or-update-comment@v3
|
2021-08-26 20:59:23 +03:00
|
|
|
with:
|
2023-09-05 14:49:39 +03:00
|
|
|
comment-id: ${{ steps.find-comment.outputs.comment-id }}
|
2021-08-26 20:59:23 +03:00
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
body: |
|
2023-09-05 14:49:39 +03:00
|
|
|
**Compiled ${{ matrix.target }} firmware for commit `${{steps.names.outputs.commit_sha}}`:**
|
2022-09-03 10:09:03 +03:00
|
|
|
- [📦 Update package](https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz)
|
|
|
|
- [📥 DFU file](https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-full-${{steps.names.outputs.suffix}}.dfu)
|
2022-10-26 00:48:33 +02:00
|
|
|
- [☁️ Web/App updater](https://lab.flipper.net/?url=https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz&channel=${{steps.names.outputs.branch_name}}&version=${{steps.names.outputs.commit_sha}})
|
2021-08-26 20:59:23 +03:00
|
|
|
edit-mode: replace
|
2023-09-05 14:49:39 +03:00
|
|
|
|
2023-09-11 13:51:03 +03:00
|
|
|
- name: 'SDK submission to dev catalog'
|
2023-09-05 14:49:39 +03:00
|
|
|
if: ${{ steps.names.outputs.event_type == 'tag' && matrix.target == env.DEFAULT_TARGET }}
|
2023-09-11 13:51:03 +03:00
|
|
|
uses: ./.github/actions/submit_sdk
|
|
|
|
with:
|
|
|
|
catalog-url: ${{ secrets.CATALOG_STAGING_URL }}
|
|
|
|
catalog-api-token: ${{ secrets.CATALOG_STAGING_API_TOKEN }}
|
|
|
|
firmware-api: ${{ steps.build-fw.outputs.firmware_api }}
|
|
|
|
firwmare-target: ${{ matrix.target }}
|
|
|
|
firmware-version: ${{ steps.names.outputs.suffix }}
|
|
|
|
|
|
|
|
- name: 'SDK submission to prod catalog'
|
|
|
|
if: ${{ steps.names.outputs.event_type == 'tag' && matrix.target == env.DEFAULT_TARGET }}
|
|
|
|
uses: ./.github/actions/submit_sdk
|
|
|
|
with:
|
|
|
|
catalog-url: ${{ secrets.CATALOG_URL }}
|
|
|
|
catalog-api-token: ${{ secrets.CATALOG_API_TOKEN }}
|
|
|
|
firmware-api: ${{ steps.build-fw.outputs.firmware_api }}
|
|
|
|
firwmare-target: ${{ matrix.target }}
|
|
|
|
firmware-version: ${{ steps.names.outputs.suffix }}
|