mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-28 03:59:58 -07:00
* Unused icons to check later
* Exclude disabled icons from firmware
* Format
* Also report free flash in gh comment
* Fix free flash calc
* Fix?
* Fix??
* Split to next line
* Remove dead icons
* Some spring cleaning of icons cooker
* Improve unused icons script
* Disable icons that cant be used in asset packs
* These will need a workaround for external
* Revert "These will need a workaround for external"
This reverts commit fb23d97952.
* Here's the workaround: split assets lib
now there is "assets" and "fwassets"
firmware links with fwassets and includes all icons
however not all of them are exposed to api
if an app needs a firmware icon not in api, it can use fap_libs=["assets"]
this will link against this dummy assets lib
it only contains the icons that arent exposed to api
this way, an app using assets lib will still benefit from asset packs
but at same time, we can remove pointless icons from dfu blob
* Update changelog
194 lines
8.8 KiB
YAML
194 lines
8.8 KiB
YAML
name: "Build"
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "**"
|
|
- "!release"
|
|
tags:
|
|
- "*"
|
|
pull_request:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
DEFAULT_TARGET: f7
|
|
FBT_GIT_SUBMODULE_SHALLOW: 1
|
|
|
|
jobs:
|
|
build:
|
|
permissions:
|
|
issues: write
|
|
pull-requests: write
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
target: [f7]
|
|
steps:
|
|
- name: "Checkout code"
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
|
|
- name: "Get commit details"
|
|
id: names
|
|
run: |
|
|
BUILD_TYPE='DEBUG=0 COMPACT=1'
|
|
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" || cat "${{ github.event_path }}"
|
|
echo "event_type=$TYPE" >> $GITHUB_OUTPUT
|
|
echo "FBT_BUILD_TYPE=$BUILD_TYPE" >> $GITHUB_ENV
|
|
echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV
|
|
echo "TARGET_HW=$(echo "${{ matrix.target }}" | sed 's/f//')" >> $GITHUB_ENV
|
|
|
|
- name: "Check API versions for consistency between targets"
|
|
run: |
|
|
set -e
|
|
N_API_HEADER_SIGNATURES=`ls -1 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!
|
|
echo API versions are:
|
|
head -n2 targets/f*/api_symbols.csv
|
|
exit 1
|
|
fi
|
|
|
|
- name: "Check API version for consistency with OFW release-candidate"
|
|
run: |
|
|
set -e
|
|
symbols="targets/$TARGET/api_symbols.csv"
|
|
ofw_api="$(curl -s "https://raw.githubusercontent.com/flipperdevices/flipperzero-firmware/release-candidate/${symbols}" | head -n2)"
|
|
our_api="$(head -n2 "${symbols}")"
|
|
if [ "$our_api" != "$ofw_api" ] ; then
|
|
echo API versions aren\'t matching OFW. Please update!
|
|
echo API versions are:
|
|
echo "Official: $(tail -n1 <<< "$ofw_api")"
|
|
echo "Momentum: $(tail -n1 <<< "$our_api")"
|
|
exit 1
|
|
fi
|
|
|
|
- name: "Build the firmware and apps"
|
|
id: build-fw
|
|
run: |
|
|
./fbt TARGET_HW=$TARGET_HW $FBT_BUILD_TYPE copro_dist updater_package fap_dist
|
|
echo "firmware_api=$(./fbt TARGET_HW=$TARGET_HW get_apiversion)" >> $GITHUB_OUTPUT
|
|
|
|
- name: "Check for uncommitted changes"
|
|
run: |
|
|
git diff --exit-code
|
|
|
|
- name: "Upload artifacts to GitHub"
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
path: |
|
|
dist/${{ env.TARGET }}-*/flipper-z-${{ env.TARGET }}-update-*
|
|
dist/${{ env.TARGET }}-*/flipper-z-${{ env.TARGET }}-sdk-*
|
|
|
|
- name: "Copy build output"
|
|
env:
|
|
INDEXER_URL: ${{ secrets.INDEXER_URL }}
|
|
if: ${{ env.INDEXER_URL != '' && (github.event.pull_request || (github.event_name == 'push' && ((github.ref_name == 'dev' && !contains(github.event.head_commit.message, '--nobuild')) || startsWith(github.ref, 'refs/tags/')))) }}
|
|
run: |
|
|
set -e
|
|
rm -rf artifacts || true
|
|
mkdir artifacts
|
|
cp dist/${TARGET}-*/flipper-z-${TARGET}-{update-*.tgz,sdk-*.zip,full-*.dfu} artifacts/
|
|
tar czpf "artifacts/flipper-z-${TARGET}-resources-${SUFFIX}.tgz" \
|
|
-C build/latest resources
|
|
cd dist/${TARGET}-*/${TARGET}-update-*/
|
|
ARTIFACT_TAG=flipper-z-"$(basename "$(realpath .)")"
|
|
7z a ../../../artifacts/${ARTIFACT_TAG}.zip .
|
|
echo "ARTIFACT_TAG=$ARTIFACT_TAG" >> $GITHUB_ENV
|
|
VERSION_TAG="$(basename "$(realpath .)" | cut -d- -f3-)"
|
|
echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_ENV
|
|
|
|
- name: "Copy universal artifacts"
|
|
env:
|
|
INDEXER_URL: ${{ secrets.INDEXER_URL }}
|
|
if: ${{ env.INDEXER_URL != '' && (github.event.pull_request || (github.event_name == 'push' && ((github.ref_name == 'dev' && !contains(github.event.head_commit.message, '--nobuild')) || startsWith(github.ref, 'refs/tags/')))) }}
|
|
run: |
|
|
tar czpf "artifacts/flipper-z-any-scripts-${SUFFIX}.tgz" scripts
|
|
cp build/core2_firmware.tgz "artifacts/flipper-z-any-core2_firmware-${SUFFIX}.tgz"
|
|
|
|
- name: "Calculate DFU sizes"
|
|
env:
|
|
INDEXER_URL: ${{ secrets.INDEXER_URL }}
|
|
if: ${{ env.INDEXER_URL != '' && github.event.pull_request && matrix.target == env.DEFAULT_TARGET }}
|
|
run: |
|
|
curl -L "${{ secrets.INDEXER_URL }}"/firmware/development/f7/full_dfu -o dev.dfu
|
|
dfu_size_new=$(du --apparent-size -B 1 artifacts/flipper-z-${TARGET}-full-*.dfu | cut -f1)
|
|
dfu_size_dev=$(du --apparent-size -B 1 dev.dfu | cut -f1)
|
|
dfu_size_diff=$((dfu_size_new - dfu_size_dev))
|
|
DFU_SIZE=$(echo $dfu_size_new | numfmt --to=iec --format=%.2f)
|
|
DFU_DIFF=$(echo $dfu_size_diff | numfmt --to=iec --format=%.2f | sed -r 's/^([^-])/+\1/')
|
|
echo "DFU_SIZE=$DFU_SIZE" >> $GITHUB_ENV
|
|
echo "DFU_DIFF=$DFU_DIFF" >> $GITHUB_ENV
|
|
|
|
tar xzf build/core2_firmware.tgz
|
|
radio_addr=$(jq -r '.copro.radio.files[0].address' core2_firmware/Manifest.json)
|
|
flash_base=0x8000000
|
|
min_gap=$((2 * 4 * 1024))
|
|
flash_free_total=$((radio_addr - flash_base - dfu_size_new))
|
|
flash_free_usable=$((flash_free_total - min_gap))
|
|
FLASH_FREE=$(echo $flash_free_total | numfmt --to=iec --format=%.2f)
|
|
FLASH_USABLE=$(echo $flash_free_usable | numfmt --to=iec --format=%.2f)
|
|
echo "FLASH_FREE=$FLASH_FREE" >> $GITHUB_ENV
|
|
echo "FLASH_USABLE=$FLASH_USABLE" >> $GITHUB_ENV
|
|
|
|
- name: "Upload artifacts to update server"
|
|
env:
|
|
INDEXER_URL: ${{ secrets.INDEXER_URL }}
|
|
if: ${{ env.INDEXER_URL != '' && (github.event.pull_request || (github.event_name == 'push' && ((github.ref_name == 'dev' && !contains(github.event.head_commit.message, '--nobuild')) || startsWith(github.ref, 'refs/tags/')))) }}
|
|
run: |
|
|
curl "${{ secrets.INDEXER_URL }}"/firmware/directory.json > previndex.json
|
|
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
|
|
|
|
- name: "Find previous comment"
|
|
env:
|
|
INDEXER_URL: ${{ secrets.INDEXER_URL }}
|
|
if: ${{ env.INDEXER_URL != '' && github.event.pull_request && matrix.target == env.DEFAULT_TARGET }}
|
|
uses: peter-evans/find-comment@v3
|
|
id: find-comment
|
|
with:
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
comment-author: "github-actions[bot]"
|
|
body-includes: "Compiled ${{ matrix.target }} firmware for commit"
|
|
|
|
- name: "Create or update comment"
|
|
env:
|
|
INDEXER_URL: ${{ secrets.INDEXER_URL }}
|
|
if: ${{ env.INDEXER_URL != '' && github.event.pull_request && matrix.target == env.DEFAULT_TARGET }}
|
|
uses: peter-evans/create-or-update-comment@v4
|
|
with:
|
|
comment-id: ${{ steps.find-comment.outputs.comment-id }}
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
body: |
|
|
**Compiled ${{ matrix.target }} firmware for commit `${{steps.names.outputs.commit_sha}}`:**
|
|
- [☁️ Flipper Lab/App](https://lab.flipper.net/?url=${{secrets.INDEXER_URL}}/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz&channel=mntm-${{steps.names.outputs.branch_name}}&version=${{steps.names.outputs.commit_sha}})
|
|
- [📦 qFlipper Package](${{secrets.INDEXER_URL}}/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz)
|
|
- DFU Size: `${{ env.DFU_SIZE }}` (`${{ env.DFU_DIFF }}` from dev)
|
|
- Free Flash: `${{ env.FLASH_FREE }}` (`${{ env.FLASH_USABLE }}` usable)
|
|
edit-mode: replace
|
|
|
|
- name: Send devbuild webhook
|
|
env:
|
|
INDEXER_URL: ${{ secrets.INDEXER_URL }}
|
|
BUILD_WEBHOOK: ${{ secrets.BUILD_WEBHOOK }}
|
|
if: ${{ env.INDEXER_URL != '' && github.event_name == 'push' && github.ref_name == 'dev' && !contains(github.event.head_commit.message, '--nobuild') }}
|
|
run: |
|
|
python .github/workflow_data/devbuild.py
|