diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 988a319..960cce6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,20 +1,71 @@ -name: CI +name: Build on: # # Triggers the workflow on push but only for the master branch - push: - branches: [main, testing] - paths-ignore: - - "**.md" - - version.properties - - # Note: This is different from "pull_request". Need to specify ref when doing checkouts. - pull_request_target: - branches: [master, testing] - paths-ignore: - - "**.md" - #- "**.yml" + # push: + # branches: [main, testing] + # paths-ignore: + # - "**.md" + # - version.properties + + # # Note: This is different from "pull_request". Need to specify ref when doing checkouts. + # pull_request_target: + # branches: [master, testing] + # paths-ignore: + # - "**.md" + # #- "**.yml" + + schedule: + - cron: '0 23 * * *' # Nightly master build workflow_dispatch: + inputs: + meshtastic_firmware_ref: + description: Meshtastic firmware ref + required: true + type: string + default: master + release_name: + description: Release name + required: false + type: string + default: Meshtastic Firmware + release_prerelease: + description: Release as a prerelease + required: true + type: boolean + default: true + release_body: + description: Release body + required: false + type: string + default: | + Autogenerated by github action, developer should edit as required before publishing... + + workflow_call: + inputs: + meshtastic_firmware_ref: + description: Meshtastic firmware ref + required: true + type: string + default: master + release_name: + description: Release name + required: false + type: string + release_prerelease: + description: Release as a prerelease + required: true + type: boolean + default: true + release_body: + description: Release body + required: false + type: string + default: | + Autogenerated by github action, developer should edit as required before publishing... + +env: + meshtastic_firmware_ref: ${{ inputs.meshtastic_firmware_ref || 'master' }} jobs: build: @@ -23,6 +74,15 @@ jobs: fail-fast: false matrix: include: + - arch: nrf52840 + board: xiao_ble + build-script-path: bin/build-nrf52.sh + artifact-paths: | + release/*.hex + release/*.uf2 + release/*.elf + release/*.zip + - arch: esp32s3 board: t-energy-s3_e22 remove-debug-flags: >- @@ -38,15 +98,6 @@ jobs: release/*.elf include-web-ui: true - - arch: nrf52840 - board: xiao_ble - build-script-path: bin/build-nrf52.sh - artifact-paths: | - release/*.hex - release/*.uf2 - release/*.elf - release/*.zip - - arch: rp2040 board: rp2040-lora-slowclock build-script-path: bin/build-rpi2040.sh @@ -54,14 +105,16 @@ jobs: release/*.uf2 release/*.elf - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + outputs: + version: ${{ steps.build.outputs.version }} steps: - id: checkout_firmware name: Checkout Meshtastic firmware uses: actions/checkout@v4 with: repository: meshtastic/firmware - ref: master + ref: ${{ env.meshtastic_firmware_ref }} submodules: recursive - id: checkout_custom @@ -103,3 +156,31 @@ jobs: overwrite: true path: | ${{ matrix.artifact-paths }} + + release: + name: Release + if: (inputs.meshtastic_firmware_ref || 'master') != 'master' + runs-on: ubuntu-24.04 + needs: build + permissions: + contents: write + steps: + - id: gather_artifacts + name: Download artifacts + uses: actions/download-artifact@v4 + with: + pattern: "firmware-*-${{ needs.build.outputs.version }}.zip" + merge-multiple: true + path: ${{ github.workspace }}/release + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + draft: false + prerelease: ${{ inputs.release_prerelease }} + name: ${{ inputs.release_name }} + tag_name: v${{ needs.build.outputs.version }} + body: ${{ inputs.release_body }} + fail_on_unmatched_files: true + files: | + ${{ steps.gather_artifacts.outputs.download-path }}/firmware-* diff --git a/.github/workflows/check_upstream.yml b/.github/workflows/check_upstream.yml new file mode 100644 index 0000000..f06fd33 --- /dev/null +++ b/.github/workflows/check_upstream.yml @@ -0,0 +1,73 @@ +name: Check upstream releases +on: + schedule: + - cron: '0 0 * * *' # Nightly + workflow_dispatch: # Debugging +jobs: + check: + name: Check for meshtastic firmware changes + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + + # Get the latest meshtastic releases + - id: gh_meshtastic_firmware_release + name: Get latest Meshtastic firmware releases + run: | + beta_json=$(curl -s ${{ github.api_url }}/repos/meshtastic/firmware/releases/latest | jq) + echo "beta_ver=$(jq -r '.tag_name' <<< $beta_json)" >> $GITHUB_OUTPUT + echo "beta_name=$(jq -r '.name' <<< $beta_json)" >> $GITHUB_OUTPUT + echo "beta_body<> $GITHUB_OUTPUT + echo "$(jq -r '.body' <<< $beta_json)" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + alpha_json=$(curl -s ${{ github.api_url }}/repos/meshtastic/firmware/releases | jq 'map(select(.prerelease)) | first') + echo "alpha_ver=$(jq -r '.tag_name' <<< $alpha_json)" >> $GITHUB_OUTPUT + echo "alpha_name=$(jq -r '.name' <<< $alpha_json)" >> $GITHUB_OUTPUT + echo "alpha_body<> $GITHUB_OUTPUT + echo "$(jq -r '.body' <<< $alpha_json)" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + # Get the latest ${{ github.repository }} releases + - id: gh_currentrepo_release + name: Get latest release of this repo + run: | + beta_json=$(curl -s ${{ github.api_url }}/repos/${{ github.repository }}/releases/latest | jq) + echo "beta_ver=$(jq -r '.tag_name' <<< $beta_json)" >> $GITHUB_OUTPUT + alpha_json=$(curl -s ${{ github.api_url }}/repos/${{ github.repository }}/releases | jq 'map(select(.prerelease)) | first') + echo "alpha_ver=$(jq -r '.tag_name' <<< $alpha_json)" >> $GITHUB_OUTPUT + continue-on-error: true + outputs: + meshtastic_alpha_ver: ${{ steps.gh_meshtastic_firmware_release.outputs.alpha_ver }} + meshtastic_alpha_name: ${{ steps.gh_meshtastic_firmware_release.outputs.alpha_name }} + meshtastic_alpha_body: ${{ steps.gh_meshtastic_firmware_release.outputs.alpha_body }} + + meshtastic_beta_ver: ${{ steps.gh_meshtastic_firmware_release.outputs.beta_ver }} + meshtastic_beta_name: ${{ steps.gh_meshtastic_firmware_release.outputs.beta_name }} + meshtastic_beta_body: ${{ steps.gh_meshtastic_firmware_release.outputs.beta_body }} + + currentrepo_alpha_ver: ${{ steps.gh_currentrepo_release.outputs.alpha_ver }} + currentrepo_beta_ver: ${{ steps.gh_currentrepo_release.outputs.beta_ver }} + + # TODO: Matrix all of this + build_alpha: + needs: check + if: needs.check.outputs.currentrepo_alpha_ver != needs.check.outputs.meshtastic_alpha_ver + name: Build (Alpha) + uses: ./.github/workflows/build.yml + with: + meshtastic_firmware_ref: ${{ needs.check.outputs.meshtastic_alpha_ver }} + release_prerelease: true + release_name: ${{ needs.check.outputs.meshtastic_alpha_name }} + release_body: ${{ needs.check.outputs.meshtastic_alpha_body }} + + build_beta: + needs: check + if: needs.check.outputs.currentrepo_beta_ver != needs.check.outputs.meshtastic_beta_ver + name: Build (Beta) + uses: ./.github/workflows/build.yml + with: + meshtastic_firmware_ref: ${{ needs.check.outputs.meshtastic_beta_ver }} + release_prerelease: false + release_name: ${{ needs.check.outputs.meshtastic_beta_name }} + release_body: ${{ needs.check.outputs.meshtastic_beta_body }}