fix monitoring ESP32-C3, fix github workflow #146
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://github.com/marketplace/actions/test-compile-for-arduino | |
| # https://github.com/marketplace/actions/test-compile-for-arduino#multiple-boards-with-parameter-using-the-script-directly | |
| # https://github.com/actions/upload-release-asset/issues/17 | |
| # https://github.com/dh1tw/remoteAudio/blob/master/.github/workflows/build.yml | |
| name: Build&Deploy | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - stable | |
| - prelive | |
| - development | |
| paths: | |
| - '**.cpp' | |
| - '**.h' | |
| - '**.yml' | |
| - '**.sh' | |
| - '**.py' | |
| - '**.json' | |
| - '**.js' | |
| - '**.css' | |
| - '**.html' | |
| jobs: | |
| build: | |
| name: BuildAndDeploy-${{ matrix.variant.firmware }} | |
| runs-on: ubuntu-latest | |
| env: | |
| REPOSITORY: ${{ github.event.repository.name }} | |
| BRANCH_NAME: ${{ github.base_ref || github.ref_name }} | |
| GITHUB_RUN: ${{ github.run_number }} | |
| outputs: | |
| fw_version: ${{ steps.json_params.outputs.version }} | |
| fw_build: ${{ steps.json_params.outputs.build }} | |
| strategy: | |
| matrix: | |
| variant: | |
| - firmware: firmware_ESP32 | |
| architecture: ESP32 | |
| subvariant: standard | |
| - firmware: firmware_ESP32-S2 | |
| architecture: ESP32-S2 | |
| subvariant: standard | |
| - firmware: firmware_ESP32-S3 | |
| architecture: ESP32-S3 | |
| subvariant: standard | |
| - firmware: firmware_ESP32-C3 | |
| architecture: ESP32-C3 | |
| subvariant: standard | |
| steps: | |
| - name: checkout repository | |
| uses: actions/checkout@v2 | |
| - name: Set up Python | |
| uses: actions/setup-python@main | |
| with: | |
| python-version: '3.x' | |
| - name: Install dependencies | |
| run: | | |
| pip install --upgrade pip | |
| pip install -U platformio | |
| pip install -U esptool | |
| - name: Run PlatformIO | |
| id: buildFw | |
| run: | | |
| mkdir -p firmware/ | |
| platformio run -e ${{ matrix.variant.firmware }} | |
| cp .pio/build/${{ matrix.variant.firmware }}/firmware.bin firmware/ | |
| cp .pio/build/${{ matrix.variant.firmware }}/partitions.bin firmware/ | |
| cp .pio/build/${{ matrix.variant.firmware }}/bootloader.bin firmware/ | |
| if [ -d "data" ]; then | |
| platformio run --target buildfs -e ${{ matrix.variant.firmware }} | |
| cp .pio/build/${{ matrix.variant.firmware }}/littlefs.bin firmware/ | |
| fi | |
| python .github/scripts/createMergedFirmware.py \ | |
| --ChipFamily ${{ matrix.variant.architecture }} \ | |
| --BuildDir firmware \ | |
| --PathOfPartitionsCSV partitions.csv \ | |
| >> "$GITHUB_OUTPUT" | |
| - name: Build merged Firmware | |
| if: ${{ steps.buildFw.outputs.command != 'None' }} | |
| run: | | |
| ${{steps.buildFw.outputs.command}} | |
| - name: Display generated files | |
| run: | | |
| ls -R firmware/ | |
| - name: Schreibe Json/Manifest File | |
| id: json_params | |
| run: | | |
| mkdir -p release artifacts | |
| python .github/scripts/createManifest.py \ | |
| --arch ${{ matrix.variant.architecture }} \ | |
| --variant ${{ matrix.variant.subvariant }} \ | |
| --stage ${{ env.BRANCH_NAME }} \ | |
| --repository ${{ env.REPOSITORY }} \ | |
| --binarypath firmware/ \ | |
| --firmwarename ${{ matrix.variant.firmware }} \ | |
| --releasepath release \ | |
| --artifactpath artifacts \ | |
| --build ${{ github.run_number }} \ | |
| --releasefile include/_Release.h \ | |
| >> "$GITHUB_OUTPUT" | |
| - name: Upload firmware artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.variant.firmware }} | |
| path: artifacts/* | |
| web-installer: | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| env: | |
| REPOSITORY: ${{ github.event.repository.name }} | |
| BRANCH_NAME: ${{ github.base_ref || github.ref_name }} | |
| VersDir: "web-installer/firmware/v${{ needs.build.outputs.fw_version }}-${{ needs.build.outputs.fw_build }}-${{ github.base_ref || github.ref_name }}" | |
| FwDir: "web-installer/firmware" | |
| steps: | |
| - name: Checkout web-installer Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: 'web-installer' | |
| path: 'web-installer' | |
| - name: Checkout Application Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| path: 'app' | |
| sparse-checkout: | | |
| .github | |
| - name: Set up Python | |
| uses: actions/setup-python@v2 | |
| with: | |
| python-version: '3.x' | |
| - name: Download all Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ${{ env.VersDir }} | |
| - name: Display generated files | |
| run: | | |
| ls -R ./ | |
| - name: create "manifestAll" and "versions" JSON | |
| run: | | |
| python -m pip install --upgrade pip | |
| python app/.github/scripts/createManifestAll_VersionsFile.py --FwDir ${{ env.FwDir }} --VersDir ${{ env.VersDir }} | |
| - name: Commit and push changes | |
| run: | | |
| cd web-installer | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "actions@github.com" | |
| git add * | |
| git commit -m "neue Firmware v${{ needs.build.outputs.fw_version }}-${{ needs.build.outputs.fw_build }}-${{ env.BRANCH_NAME }}" | |
| git push origin web-installer | |
| create_Release: | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| if: endsWith(github.ref, 'master') || endsWith(github.ref, 'stable') || endsWith(github.ref, 'prelive') | |
| env: | |
| GITHUB_REPOSITORY: ${{ github.event.repository.name }} | |
| BRANCH_NAME: ${{ github.base_ref || github.ref_name }} | |
| GITHUB_OWNER: ${{ github.repository_owner }} | |
| steps: | |
| - name: Checkout web-installer Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: 'web-installer' | |
| path: 'web-installer' | |
| - name: Checkout Application Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| path: 'app' | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./release | |
| - name: set Environment Variables | |
| id: set_env_var | |
| run: | | |
| VERSION=$(sed 's/[^0-9|.]//g' app/include/_Release.h) # zb. 2.4.2 | |
| if [[ "master stable" == *${{ env.BRANCH_NAME }}* ]]; then IS_PRE='false'; else IS_PRE='true'; fi | |
| if [[ "master stable" == *${{ env.BRANCH_NAME }}* ]]; then POSTFIX='' ; else POSTFIX='PRE'; fi | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "IS_PRERELEASE=${IS_PRE}" >> "$GITHUB_OUTPUT" | |
| echo "RELEASENAME_POSTFIX=${POSTFIX}" >> "$GITHUB_OUTPUT" | |
| RELEASEBODY=$(awk -v RS='Release ' '/'$VERSION':(.*)/ {print $0}' app/ChangeLog.md) | |
| echo "${RELEASEBODY}" > CHANGELOG.md | |
| echo "tagname=v.${VERSION}-${POSTFIX}-${{ github.run_id }}" >> "$GITHUB_OUTPUT" | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
| with: | |
| tag_name: ${{ steps.set_env_var.outputs.tagname }} | |
| release_name: Release ${{ steps.set_env_var.outputs.version }} ${{ steps.set_env_var.outputs.RELEASENAME_POSTFIX }} | |
| body_path: CHANGELOG.md | |
| draft: false | |
| prerelease: ${{ steps.set_env_var.outputs.IS_PRERELEASE }} | |
| # erstelle das manifestAll.json speziell für das release mit den korrekten Pfaden | |
| # füge gleichzeitg das ReleaseTag hinzu | |
| #--ReleaseTagName ${{ steps.set_env_var.outputs.tagname }} \ | |
| - name: Create Release manifestAll JSON | |
| run: | | |
| python app/.github/scripts/createReleaseAssetManifestAll.py \ | |
| --ReleaseDir release \ | |
| --ReleaseURL "${{github.server_url}}/${{env.GITHUB_OWNER}}/${{ env.GITHUB_REPOSITORY }}/releases/download/${{ steps.set_env_var.outputs.tagname }}" | |
| # suche alle Dateien aus dem Ordner release (siehe asset-download), incl aller unterordner und lade diese einzeln als release-asset hoch | |
| # jede Datei behält ihren originalen Namen und contenttype. Identische Dateinamen werden überschrieben | |
| - name: Upload Release Assets | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| for dir in $(find release -type d); do | |
| for file in "$dir"/*; do | |
| if [ -f "$file" ]; then | |
| if [[ "$file" == *files.json || "$file" == *manifest.json ]]; then | |
| continue | |
| fi | |
| echo "Uploading $file" | |
| gh release upload -R ${{env.GITHUB_OWNER}}/${{ env.GITHUB_REPOSITORY }} ${{ steps.set_env_var.outputs.tagname }} "$file" --clobber | |
| fi | |
| done | |
| done | |
| # gehe durch alle verfügbaren releases im Repository durch, suche die manifestAll.json und filesAll.json. | |
| # Lade diese herunter ins lokale verzeichnis ./manifests und erstelle auf dieser Grundlage die releases.json | |
| - name: Download all Manifests, create ReleaseVersions | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| mkdir -p manifests | |
| tagNames=$(gh release ls -R ${{env.GITHUB_OWNER}}/${{ env.GITHUB_REPOSITORY }} --json tagName) | |
| for tag in $(echo "$tagNames" | jq -r '.[].tagName'); do | |
| for asset in $(gh release view $tag -R ${{env.GITHUB_OWNER}}/${{ env.GITHUB_REPOSITORY }} --json assets --jq '.assets[].name' | grep -E 'manifestAll|filesAll'); do | |
| echo "Downloading file: gh release download $tag -R ${{env.GITHUB_OWNER}}/${{ env.GITHUB_REPOSITORY }} --pattern '$asset' --dir 'manifests/${tag}/'" | |
| gh release download $tag \ | |
| -R ${{env.GITHUB_OWNER}}/${{ env.GITHUB_REPOSITORY }} \ | |
| --pattern "$asset" \ | |
| --dir "manifests/${tag}/" || true | |
| done | |
| mkdir -p manifests/${tag}/ | |
| gh release view $tag -R ${{env.GITHUB_OWNER}}/${{ env.GITHUB_REPOSITORY }} --json assets > "manifests/${tag}/assets.json" | |
| done | |
| python app/.github/scripts/createReleaseVersions.py \ | |
| --ManifestDir manifests \ | |
| --TargetDir web-installer/firmware | |
| ls -R ./manifests | |
| ls -R ./release | |
| - name: Commit and push changes | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| cd web-installer | |
| git pull | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "actions@github.com" | |
| git add * | |
| git commit -m "update releases.json" | |
| git push origin web-installer | |
| - name: Upload Changelog artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: CHANGELOG.md | |
| path: CHANGELOG.md |