diff --git a/.github/workflows/manual-compile.yaml b/.github/workflows/manual-compile.yaml index 2c32ccc..b92b167 100644 --- a/.github/workflows/manual-compile.yaml +++ b/.github/workflows/manual-compile.yaml @@ -4,6 +4,15 @@ name: Manual Compile on: workflow_dispatch: inputs: + platform: + description: 'Platform to compile (bsom/b5som/both)' + required: true + default: 'bsom' + type: choice + options: + - bsom + - b5som + - both branch: description: 'Branch to compile' required: false @@ -14,6 +23,9 @@ jobs: compile: name: Compile Firmware runs-on: ubuntu-latest + strategy: + matrix: + platform: ['bsom', 'b5som'] steps: - name: Checkout code uses: actions/checkout@v4 @@ -21,16 +33,34 @@ jobs: submodules: recursive ref: ${{ github.event.inputs.branch || github.ref }} - - name: Compile application - id: compile + - name: Compile BSOM application + id: compile-bsom + if: matrix.platform == 'bsom' && (github.event.inputs.platform == 'bsom' || github.event.inputs.platform == 'both') uses: particle-iot/compile-action@9dbe1eb567c6268f1baa7458217d5d6e5553850d with: particle-platform-name: 'bsom' device-os-version: 6.2.1 - - name: Upload artifact + - name: Compile B5SOM application + id: compile-b5som + if: matrix.platform == 'b5som' && (github.event.inputs.platform == 'b5som' || github.event.inputs.platform == 'both') + uses: particle-iot/compile-action@9dbe1eb567c6268f1baa7458217d5d6e5553850d + with: + particle-platform-name: 'b5som' + device-os-version: 6.2.1 + + - name: Upload BSOM artifact + if: matrix.platform == 'bsom' && (github.event.inputs.platform == 'bsom' || github.event.inputs.platform == 'both') + uses: actions/upload-artifact@v4 + with: + name: bsom-firmware-binary + path: ${{ steps.compile-bsom.outputs.firmware-path }} + retention-days: 1 + + - name: Upload B5SOM artifact + if: matrix.platform == 'b5som' && (github.event.inputs.platform == 'b5som' || github.event.inputs.platform == 'both') uses: actions/upload-artifact@v4 with: - name: firmware-binary - path: ${{ steps.compile.outputs.firmware-path }} + name: b5som-firmware-binary + path: ${{ steps.compile-b5som.outputs.firmware-path }} retention-days: 1 \ No newline at end of file diff --git a/.github/workflows/manual-release.yaml b/.github/workflows/manual-release.yaml index e8a89a8..e5d6a95 100644 --- a/.github/workflows/manual-release.yaml +++ b/.github/workflows/manual-release.yaml @@ -4,6 +4,15 @@ name: Manual Release on: workflow_dispatch: inputs: + platform: + description: 'Platform to build (bsom/b5som/both)' + required: true + default: 'both' + type: choice + options: + - bsom + - b5som + - both branch: description: 'Branch to release' required: false @@ -24,10 +33,12 @@ jobs: name: Create Release runs-on: ubuntu-latest outputs: - firmware-path: ${{ steps.compile.outputs.firmware-path }} - firmware-version: ${{ steps.compile.outputs.firmware-version }} - firmware-version-updated: ${{ steps.compile.outputs.firmware-version-updated }} + firmware-version: ${{ steps.compile-bsom.outputs.firmware-version || steps.compile-b5som.outputs.firmware-version }} + firmware-version-updated: ${{ steps.compile-bsom.outputs.firmware-version-updated || steps.compile-b5som.outputs.firmware-version-updated }} release-url: ${{ steps.release.outputs.html_url }} + strategy: + matrix: + platform: ['bsom', 'b5som'] steps: - name: Checkout code uses: actions/checkout@v4 @@ -35,37 +46,83 @@ jobs: fetch-depth: 0 ref: ${{ github.event.inputs.branch || github.ref }} - - name: Compile application - id: compile + - name: Compile BSOM application + id: compile-bsom + if: matrix.platform == 'bsom' && (github.event.inputs.platform == 'bsom' || github.event.inputs.platform == 'both') uses: particle-iot/compile-action@v1 with: particle-platform-name: 'bsom' auto-version: ${{ github.event.inputs.force_version_increment == 'yes' }} device-os-version: 6.2.1 - - name: Upload artifacts + - name: Compile B5SOM application + id: compile-b5som + if: matrix.platform == 'b5som' && (github.event.inputs.platform == 'b5som' || github.event.inputs.platform == 'both') + uses: particle-iot/compile-action@v1 + with: + particle-platform-name: 'b5som' + auto-version: false + device-os-version: 6.2.1 + + - name: Upload BSOM artifacts + if: matrix.platform == 'bsom' && (github.event.inputs.platform == 'bsom' || github.event.inputs.platform == 'both') uses: actions/upload-artifact@v4 with: - name: release-artifacts + name: bsom-release-artifacts path: | - ${{ steps.compile.outputs.firmware-path }} - ${{ steps.compile.outputs.target-path }} + ${{ steps.compile-bsom.outputs.firmware-path }} + ${{ steps.compile-bsom.outputs.target-path }} + + - name: Upload B5SOM artifacts + if: matrix.platform == 'b5som' && (github.event.inputs.platform == 'b5som' || github.event.inputs.platform == 'both') + uses: actions/upload-artifact@v4 + with: + name: b5som-release-artifacts + path: | + ${{ steps.compile-b5som.outputs.firmware-path }} + ${{ steps.compile-b5som.outputs.target-path }} + + - name: Create archive and rename firmware files for BSOM + if: matrix.platform == 'bsom' && (github.event.inputs.platform == 'bsom' || github.event.inputs.platform == 'both') && steps.compile-bsom.outputs.firmware-version-updated == 'true' + run: | + tar -czf debug-objects-bsom.tar.gz ${{ steps.compile-bsom.outputs.target-path }} + cp ${{ steps.compile-bsom.outputs.firmware-path }} firmware-bsom-${{ steps.compile-bsom.outputs.firmware-version }}.bin - - name: Create archive of target directory - if: steps.compile.outputs.firmware-version-updated == 'true' + - name: Create archive and rename firmware files for B5SOM + if: matrix.platform == 'b5som' && (github.event.inputs.platform == 'b5som' || github.event.inputs.platform == 'both') run: | - tar -czf debug-objects.tar.gz ${{ steps.compile.outputs.target-path }} + tar -czf debug-objects-b5som.tar.gz ${{ steps.compile-b5som.outputs.target-path }} + VERSION=${{ steps.compile-bsom.outputs.firmware-version || steps.compile-b5som.outputs.firmware-version }} + cp ${{ steps.compile-b5som.outputs.firmware-path }} firmware-b5som-$VERSION.bin + + - name: Upload versioned firmware artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.platform }}-versioned-firmware + path: | + firmware-${{ matrix.platform }}-*.bin + debug-objects-${{ matrix.platform }}.tar.gz + + create-release: + name: Create GitHub Release + needs: release + runs-on: ubuntu-latest + if: needs.release.outputs.firmware-version-updated == 'true' + steps: + - name: Download all versioned firmware artifacts + uses: actions/download-artifact@v4 + with: + path: ./release-files - name: Create GitHub release id: release - if: steps.compile.outputs.firmware-version-updated == 'true' uses: ncipollo/release-action@v1 with: - artifacts: ${{ steps.compile.outputs.firmware-path }},debug-objects.tar.gz + artifacts: ./release-files/**/* generateReleaseNotes: ${{ github.event.inputs.release_notes == '' }} body: ${{ github.event.inputs.release_notes }} - name: "Firmware v${{ steps.compile.outputs.firmware-version }} (Manual)" - tag: "v${{ steps.compile.outputs.firmware-version }}-manual" + name: "Firmware v${{ needs.release.outputs.firmware-version }} (Manual)" + tag: "v${{ needs.release.outputs.firmware-version }}-manual" commit: ${{ github.sha }} token: ${{ secrets.GITHUB_TOKEN }} prerelease: true \ No newline at end of file diff --git a/.github/workflows/manual-upload.yaml b/.github/workflows/manual-upload.yaml index d308cd1..b05d760 100644 --- a/.github/workflows/manual-upload.yaml +++ b/.github/workflows/manual-upload.yaml @@ -4,6 +4,14 @@ name: Manual Upload to Particle on: workflow_dispatch: inputs: + platform: + description: 'Platform to upload (bsom/b5som)' + required: true + default: 'bsom' + type: choice + options: + - bsom + - b5som product_id: description: 'Custom product ID (defaults to secret)' required: false @@ -40,7 +48,7 @@ jobs: if: github.event.inputs.use_release_artifact != 'yes' uses: particle-iot/compile-action@v1 with: - particle-platform-name: 'bsom' + particle-platform-name: ${{ github.event.inputs.platform }} device-os-version: 6.2.1 - name: Download release artifacts @@ -48,7 +56,7 @@ jobs: uses: dawidd6/action-download-artifact@v6 with: workflow: manual-release.yaml - name: release-artifacts + name: ${{ github.event.inputs.platform }}-release-artifacts path: ./firmware - name: Find firmware binary @@ -60,7 +68,9 @@ jobs: FIRMWARE="${{ steps.compile.outputs.firmware-path }}" fi echo "Using firmware: $FIRMWARE" - echo "firmware-path=$FIRMWARE" >> $GITHUB_OUTPUT + # Create a properly named firmware file + cp "$FIRMWARE" "firmware-${{ github.event.inputs.platform }}-${{ github.event.inputs.version }}.bin" + echo "firmware-path=firmware-${{ github.event.inputs.platform }}-${{ github.event.inputs.version }}.bin" >> $GITHUB_OUTPUT - name: Upload product firmware to Particle uses: particle-iot/firmware-upload-action@v1 diff --git a/.github/workflows/pr-workflow.yaml b/.github/workflows/pr-workflow.yaml index 6b83b0b..1e93d82 100644 --- a/.github/workflows/pr-workflow.yaml +++ b/.github/workflows/pr-workflow.yaml @@ -53,24 +53,45 @@ jobs: name: Compile Firmware needs: test runs-on: ubuntu-latest + strategy: + matrix: + platform: ['bsom', 'b5som'] steps: - name: Checkout code uses: actions/checkout@v4 with: submodules: recursive - - name: Compile application - id: compile + - name: Compile BSOM application + id: compile-bsom + if: matrix.platform == 'bsom' uses: particle-iot/compile-action@9dbe1eb567c6268f1baa7458217d5d6e5553850d with: particle-platform-name: 'bsom' device-os-version: 6.2.1 - - name: Upload artifact + - name: Compile B5SOM application + id: compile-b5som + if: matrix.platform == 'b5som' + uses: particle-iot/compile-action@9dbe1eb567c6268f1baa7458217d5d6e5553850d + with: + particle-platform-name: 'b5som' + device-os-version: 6.2.1 + + - name: Upload BSOM artifact + if: matrix.platform == 'bsom' + uses: actions/upload-artifact@v4 + with: + name: bsom-firmware-artifact + path: ${{ steps.compile-bsom.outputs.firmware-path }} + retention-days: 1 + + - name: Upload B5SOM artifact + if: matrix.platform == 'b5som' uses: actions/upload-artifact@v4 with: - name: firmware-artifact - path: ${{ steps.compile.outputs.firmware-path }} + name: b5som-firmware-artifact + path: ${{ steps.compile-b5som.outputs.firmware-path }} retention-days: 1 flash: @@ -78,10 +99,10 @@ jobs: needs: compile runs-on: ubuntu-latest steps: - - name: Download firmware artifact + - name: Download BSOM firmware artifact uses: actions/download-artifact@v4 with: - name: firmware-artifact + name: bsom-firmware-artifact path: ./firmware - name: Find firmware binary diff --git a/.github/workflows/release-workflow.yaml b/.github/workflows/release-workflow.yaml index a169439..5f9e78f 100644 --- a/.github/workflows/release-workflow.yaml +++ b/.github/workflows/release-workflow.yaml @@ -28,10 +28,12 @@ jobs: if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest outputs: - firmware-path: ${{ steps.compile.outputs.firmware-path }} - firmware-version: ${{ steps.compile.outputs.firmware-version }} - firmware-version-updated: ${{ steps.compile.outputs.firmware-version-updated }} + firmware-version: ${{ steps.compile-bsom.outputs.firmware-version }} + firmware-version-updated: ${{ steps.compile-bsom.outputs.firmware-version-updated }} release-url: ${{ steps.release.outputs.html_url }} + strategy: + matrix: + platform: ['bsom', 'b5som'] steps: # Generate a GitHub App token using the official action - UNCONDITIONALLY - name: Create GitHub App token @@ -50,25 +52,45 @@ jobs: fetch-depth: 0 token: ${{ steps.app-token.outputs.token }} - - name: Compile application - id: compile + - name: Compile application for BSOM + id: compile-bsom + if: matrix.platform == 'bsom' uses: particle-iot/compile-action@9dbe1eb567c6268f1baa7458217d5d6e5553850d with: particle-platform-name: 'bsom' auto-version: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.version_increment != 'no' }} device-os-version: 6.2.1 - - name: Upload artifacts + - name: Compile application for B5SOM + id: compile-b5som + if: matrix.platform == 'b5som' + uses: particle-iot/compile-action@9dbe1eb567c6268f1baa7458217d5d6e5553850d + with: + particle-platform-name: 'b5som' + auto-version: false + device-os-version: 6.2.1 + + - name: Upload BSOM artifacts + if: matrix.platform == 'bsom' + uses: actions/upload-artifact@v4 + with: + name: bsom-release-artifacts + path: | + ${{ steps.compile-bsom.outputs.firmware-path }} + ${{ steps.compile-bsom.outputs.target-path }} + + - name: Upload B5SOM artifacts + if: matrix.platform == 'b5som' uses: actions/upload-artifact@v4 with: - name: release-artifacts + name: b5som-release-artifacts path: | - ${{ steps.compile.outputs.firmware-path }} - ${{ steps.compile.outputs.target-path }} + ${{ steps.compile-b5som.outputs.firmware-path }} + ${{ steps.compile-b5som.outputs.target-path }} - name: Commit updated version file id: commit - if: steps.compile.outputs.firmware-version-updated == 'true' + if: matrix.platform == 'bsom' && steps.compile-bsom.outputs.firmware-version-updated == 'true' run: | git config user.name 'github-actions[bot]' git config user.email 'github-actions[bot]@users.noreply.github.com' @@ -77,31 +99,76 @@ jobs: # When a GitHub Action pushes commits or tags, it does not trigger a new GitHub Action job - name: Push changes - if: steps.compile.outputs.firmware-version-updated == 'true' + if: matrix.platform == 'bsom' && steps.compile-bsom.outputs.firmware-version-updated == 'true' run: | git push origin HEAD:${{ github.ref_name }} - - name: Create archive of target directory - if: steps.compile.outputs.firmware-version-updated == 'true' + - name: Create archive and rename firmware files for BSOM + if: matrix.platform == 'bsom' && steps.compile-bsom.outputs.firmware-version-updated == 'true' + run: | + tar -czf debug-objects-bsom.tar.gz ${{ steps.compile-bsom.outputs.target-path }} + # Copy firmware binary with version in filename + cp ${{ steps.compile-bsom.outputs.firmware-path }} firmware-bsom-${{ steps.compile-bsom.outputs.firmware-version }}.bin + + - name: Create archive and rename firmware files for B5SOM + if: matrix.platform == 'b5som' run: | - tar -czf debug-objects.tar.gz ${{ steps.compile.outputs.target-path }} + tar -czf debug-objects-b5som.tar.gz ${{ steps.compile-b5som.outputs.target-path }} + # Copy firmware binary with version in filename + VERSION=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name' | sed 's/^v//') + if [ "$VERSION" == "null" ] || [ -z "$VERSION" ]; then + VERSION="0.0.1" + fi + cp ${{ steps.compile-b5som.outputs.firmware-path }} firmware-b5som-$VERSION.bin + + - name: Upload versioned firmware artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.platform }}-versioned-firmware + path: | + firmware-${{ matrix.platform }}-*.bin + debug-objects-${{ matrix.platform }}.tar.gz + + create-release: + name: Create GitHub Release + needs: release + runs-on: ubuntu-latest + if: needs.release.outputs.firmware-version-updated == 'true' + outputs: + release-url: ${{ steps.release.outputs.html_url }} + steps: + - name: Create GitHub App token + id: app-token + uses: actions/create-github-app-token@v2 + with: + app-id: ${{ secrets.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} + permission-contents: write + + - name: Download all versioned firmware artifacts + uses: actions/download-artifact@v4 + with: + path: ./release-files + + - name: Prepare release artifacts + run: | + find ./release-files -name "*.bin" -o -name "*.tar.gz" | head -10 + ls -la ./release-files/ - name: Create GitHub release id: release - if: steps.compile.outputs.firmware-version-updated == 'true' uses: ncipollo/release-action@v1 with: - artifacts: ${{ steps.compile.outputs.firmware-path }},debug-objects.tar.gz + artifacts: ./release-files/**/* generateReleaseNotes: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.release_notes == '' }} body: ${{ github.event.inputs.release_notes }} - name: "Firmware v${{ steps.compile.outputs.firmware-version }}" - tag: "v${{ steps.compile.outputs.firmware-version }}" - commit: ${{ steps.commit.outputs.updated-version-sha || github.sha }} + name: "Firmware v${{ needs.release.outputs.firmware-version }}" + tag: "v${{ needs.release.outputs.firmware-version }}" token: ${{ steps.app-token.outputs.token }} - upload-to-particle: - name: Upload to Particle Projects - needs: release + upload-bsom-to-particle: + name: Upload BSOM to Particle Projects + needs: [release, create-release] runs-on: ubuntu-latest # Only run if release job has completed and the firmware version was updated if: needs.release.outputs.firmware-version-updated == 'true' @@ -112,8 +179,6 @@ jobs: product_id_secret: "PARTICLE_GEMS_DEMO_PRODUCT_ID" - name: "Runk Lab (B SoM)" product_id_secret: "PARTICLE_RUNCK_LAB_BSOM_PRODUCT_ID" - #- name: "WinterTurf - v3 International" - #product_id_secret: "PARTICLE_WINTERTURF_INTERNATIONAL_PRODUCT_ID" - name: "WinterTurf - v3" product_id_secret: "PARTICLE_WINTERTURF_PRODUCT_ID" - name: "Plant Pathways" @@ -124,29 +189,74 @@ jobs: product_id_secret: "PARTICLE_ROADSIDE_TURF_PRODUCT_ID" - name: "PepsiCo" product_id_secret: "PARTICLE_PEPSICO_PRODUCT_ID" - #- name: "Stellenbosch" - #product_id_secret: "PARTICLE_STELLENBOSCH_PRODUCT_ID" - #- name: "Runk Lab (B5 SoM)" - #product_id_secret: "PARTICLE_RUNCK_LAB_B5SOM_PRODUCT_ID" - #- name: "LCCMR Irrigation Sensing" - #product_id_secret: "PARTICLE_LCCMR_IRRIGATION_SENSING_PRODUCT_ID" steps: - name: Checkout code uses: actions/checkout@v4 - - name: Download release artifacts + - name: Download BSOM release artifacts + uses: actions/download-artifact@v4 + with: + name: bsom-release-artifacts + path: ./bsom-release + + - name: Find BSOM firmware binary + id: find_binary + run: | + FIRMWARE=$(find ./bsom-release -name "*.bin" -type f | head -n 1) + # Create a properly named firmware file + cp "$FIRMWARE" "firmware-bsom-${{ needs.release.outputs.firmware-version }}.bin" + echo "firmware-path=firmware-bsom-${{ needs.release.outputs.firmware-version }}.bin" >> $GITHUB_OUTPUT + + - name: Upload BSOM firmware to ${{ matrix.project.name }} + uses: particle-iot/firmware-upload-action@v1 + with: + particle-access-token: ${{ secrets.PARTICLE_ACCESS_TOKEN }} + firmware-path: ${{ steps.find_binary.outputs.firmware-path }} + firmware-version: ${{ needs.release.outputs.firmware-version }} + product-id: ${{ secrets[matrix.project.product_id_secret] }} + title: 'Firmware v${{ needs.release.outputs.firmware-version }}' + description: '[Firmware v${{ needs.release.outputs.firmware-version }} GitHub Release](${{ needs.create-release.outputs.release-url }})' + + - name: Log upload success + run: | + echo "✅ Successfully uploaded BSOM firmware v${{ needs.release.outputs.firmware-version }} to ${{ matrix.project.name }}" + + upload-b5som-to-particle: + name: Upload B5SOM to Particle Projects + needs: [release, create-release] + runs-on: ubuntu-latest + # Only run if release job has completed and the firmware version was updated + if: needs.release.outputs.firmware-version-updated == 'true' + strategy: + matrix: + project: + - name: "WinterTurf - v3 International" + product_id_secret: "PARTICLE_WINTERTURF_INTERNATIONAL_PRODUCT_ID" + - name: "Stellenbosch" + product_id_secret: "PARTICLE_STELLENBOSCH_PRODUCT_ID" + - name: "Runk Lab (B5 SoM)" + product_id_secret: "PARTICLE_RUNCK_LAB_B5SOM_PRODUCT_ID" + - name: "LCCMR Irrigation Sensing" + product_id_secret: "PARTICLE_LCCMR_IRRIGATION_SENSING_PRODUCT_ID" + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download B5SOM release artifacts uses: actions/download-artifact@v4 with: - name: release-artifacts - path: ./release + name: b5som-release-artifacts + path: ./b5som-release - - name: Find firmware binary + - name: Find B5SOM firmware binary id: find_binary run: | - FIRMWARE=$(find ./release -name "*.bin" -type f | head -n 1) - echo "firmware-path=$FIRMWARE" >> $GITHUB_OUTPUT + FIRMWARE=$(find ./b5som-release -name "*.bin" -type f | head -n 1) + # Create a properly named firmware file + cp "$FIRMWARE" "firmware-b5som-${{ needs.release.outputs.firmware-version }}.bin" + echo "firmware-path=firmware-b5som-${{ needs.release.outputs.firmware-version }}.bin" >> $GITHUB_OUTPUT - - name: Upload firmware to ${{ matrix.project.name }} + - name: Upload B5SOM firmware to ${{ matrix.project.name }} uses: particle-iot/firmware-upload-action@v1 with: particle-access-token: ${{ secrets.PARTICLE_ACCESS_TOKEN }} @@ -154,8 +264,8 @@ jobs: firmware-version: ${{ needs.release.outputs.firmware-version }} product-id: ${{ secrets[matrix.project.product_id_secret] }} title: 'Firmware v${{ needs.release.outputs.firmware-version }}' - description: '[Firmware v${{ needs.release.outputs.firmware-version }} GitHub Release](${{ needs.release.outputs.release-url }})' + description: '[Firmware v${{ needs.release.outputs.firmware-version }} GitHub Release](${{ needs.create-release.outputs.release-url }})' - name: Log upload success run: | - echo "✅ Successfully uploaded firmware v${{ needs.release.outputs.firmware-version }} to ${{ matrix.project.name }}" \ No newline at end of file + echo "✅ Successfully uploaded B5SOM firmware v${{ needs.release.outputs.firmware-version }} to ${{ matrix.project.name }}" \ No newline at end of file