Skip to content

Commit

Permalink
Build upon upstream change
Browse files Browse the repository at this point in the history
  • Loading branch information
vidplace7 committed Oct 7, 2024
1 parent c63d586 commit 2a9c7bd
Show file tree
Hide file tree
Showing 2 changed files with 186 additions and 30 deletions.
141 changes: 111 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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: >-
Expand All @@ -38,30 +98,23 @@ 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
artifact-paths: |
release/*.uf2
release/*.elf
# - arch: rp2040
# board: rp2040-lora-slowclock
# build-script-path: bin/build-rpi2040.sh
# artifact-paths: |
# 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
Expand Down Expand Up @@ -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-*
75 changes: 75 additions & 0 deletions .github/workflows/check_upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
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=$(jq -r '.body' <<< $beta_json)" >> $GITHUB_OUTPUT
echo "beta_body<<EOF" >> $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=$(jq -r '.body' <<< $alpha_json)" >> $GITHUB_OUTPUT
echo "alpha_body<<EOF" >> $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 firmware (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 firmware (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 }}

0 comments on commit 2a9c7bd

Please sign in to comment.