diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 30c5c00..7bef6d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,20 +1,43 @@ name: Build +# TODO: update if you want to allow from forked repositories on: [pull_request] +env: + # TODO: Update the below variables for your project + APP_NAME: "Template" + IDF_TARGET: 'esp32' + IDF_VERSION: 'v5.5' + IDF_COMPONENT_MANAGER: "1" # whether to enable the component manager or not + FLASH_TOTAL_OVERRIDE: '1500000' # number of bytes of total flash (for percentage calculations) + jobs: build: runs-on: ubuntu-latest + permissions: + issues: write + steps: - name: Checkout repo - uses: actions/checkout@v4 + uses: actions/checkout@v5 + # TODO: update this if you have submodules - name: Build main uses: espressif/esp-idf-ci-action@v1 with: - esp_idf_version: release-v5.5 - path: '.' - # TODO: set the target here to be the chip you are building for - # target: esp32s3 + esp_idf_version: ${{ env.IDF_VERSION }} + path: "." + target: ${{ env.IDF_TARGET }} + + - name: Determine Size Delta + uses: esp-cpp/esp-idf-size-delta@v1 + with: + app_name: ${{ env.APP_NAME }} + app_path: "." + idf_target: ${{ env.IDF_TARGET }} + idf_version: ${{ env.IDF_VERSION }} + idf_component_manager: ${{ env.IDF_COMPONENT_MANAGER }} + base_ref: ${{ github.event.pull_request.base.sha }} + flash_total_override: ${{ env.FLASH_TOTAL_OVERRIDE }} diff --git a/.github/workflows/package_main.yml b/.github/workflows/package_main.yml index 2a2fcdc..7bd5a7f 100644 --- a/.github/workflows/package_main.yml +++ b/.github/workflows/package_main.yml @@ -7,27 +7,38 @@ on: types: [published] workflow_dispatch: +env: + # TODO: Update the below variables for your project + APP_NAME: "Template" + IDF_TARGET: 'esp32' + IDF_VERSION: 'v5.5' + IDF_COMPONENT_MANAGER: "1" # whether to enable the component manager or not + FLASH_TOTAL_OVERRIDE: '1500000' # number of bytes of total flash (for percentage calculations) + jobs: build: runs-on: ubuntu-latest continue-on-error: false + permissions: + contents: write + outputs: zipfile-id: ${{ steps.zip_step.outputs.artifact-id }} steps: - name: Checkout repo - uses: actions/checkout@v4 + uses: actions/checkout@v5 + with: + fetch-depth: 0 - name: Build Main Code uses: espressif/esp-idf-ci-action@v1 with: - esp_idf_version: release-v5.5 + esp_idf_version: ${{ env.IDF_VERSION }} path: '.' - command: 'idf.py build' - # TODO: set the target here to be the chip you are building for - # target: esp32s3 + target: ${{ env.IDF_TARGET }} - name: Upload Build Outputs uses: actions/upload-artifact@v4 @@ -60,6 +71,35 @@ jobs: build/flasher_args.json build/flash_args + - name: Determine base ref + if: ${{ github.event.release && github.event.action == 'published' }} + id: base + shell: bash + run: | + set -euo pipefail + COMPARE_TAG_INPUT="${{ github.event.inputs.compare_tag || '' }}" + if [ -n "$COMPARE_TAG_INPUT" ]; then + echo "ref=$COMPARE_TAG_INPUT" >> "$GITHUB_OUTPUT" + else + # use the previous tag chronologically + prev=$(git tag --sort=-creatordate | sed -n '2p') + if [ -z "$prev" ]; then prev=$(git tag --sort=-v:refname | sed -n '2p'); fi + echo "ref=$prev" >> "$GITHUB_OUTPUT" + fi + + - name: Determine Size Delta + if: ${{ github.event.release && github.event.action == 'published' }} + uses: esp-cpp/esp-idf-size-delta@v1 + with: + app_name: ${{ env.APP_NAME }} + app_path: "." + idf_target: ${{ env.IDF_TARGET }} + idf_version: ${{ env.IDF_VERSION }} + idf_component_manager: ${{ env.IDF_COMPONENT_MANAGER }} + base_ref: ${{ steps.base.outputs.ref }} + flash_total_override: ${{ env.FLASH_TOTAL_OVERRIDE }} + post_comment: 'false' + package: name: Package the binaries into an executables for Windows, MacOS, and Linux (Ubuntu) needs: build diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml index fa36942..4d442d6 100644 --- a/.github/workflows/static_analysis.yml +++ b/.github/workflows/static_analysis.yml @@ -11,9 +11,12 @@ jobs: static_analysis: runs-on: ubuntu-latest + permissions: + issues: write + steps: - name: Checkout repo - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Run static analysis uses: esp-cpp/StaticAnalysis@master diff --git a/README.md b/README.md index f5ec701..56290e6 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ After setting this as the template, make sure to update the following: - The [./sdkconfig.defaults](./sdkconfig.defaults) to configure the defaults for your project / processor. - Update the [./.github/workflows/build.yml](./.github/workflows/build.yml) file - to have the correct target architecture (e.g. `esp32s3`) for your project. + to have the correct information for your project. - Update the [./.github/workflows/package_main.yml](./.github/workflows/package_main.yml) file to: - have the correct target architecture (e.g. `esp32s3`) for your project diff --git a/main/main.cpp b/main/main.cpp index 00f22dd..5db2a8e 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1,3 +1,4 @@ +#include #include #include