Skip to content

Commit

Permalink
Merge pull request #4 from ApolloAutomation/ManagedUpdates
Browse files Browse the repository at this point in the history
Managed updates
  • Loading branch information
TrevorSchirmer authored Jul 3, 2024
2 parents 37a2123 + 035bc58 commit 99d7b19
Show file tree
Hide file tree
Showing 13 changed files with 208 additions and 22 deletions.
142 changes: 142 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Build
env:
DEVICE_NAME: msr-2
RELEASE_URL: ${{ github.server_url }}/${{ github.repository }}/releases/latest

on:
push:
branches:
- main

jobs:
build:
name: Build And Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set uppercase DEVICE_NAME
run: |
echo "UPPERCASE_DEVICE_NAME=$(echo $DEVICE_NAME | tr '[:lower:]' '[:upper:]')" >> $GITHUB_ENV
- name: Build Firmware
uses: esphome/build-action@v3.0.0
id: esphome-build
with:
yaml_file: Integrations/ESPHome/${{ env.UPPERCASE_DEVICE_NAME }}.yaml
version: 'latest'
cache: true

- name: Read version from YAML file
id: read_version
run: |
version=$(awk '/substitutions:/ {found=1} found && /version:/ {print $2; exit}' Integrations/ESPHome/${{ env.UPPERCASE_DEVICE_NAME }}.yaml | tr -d '"')
echo "project_version=$version" >> $GITHUB_ENV
- name: Move generated files to output
run: |
mkdir -p output
mv ${{ steps.esphome-build.outputs.name }}/* output/
echo ${{ steps.esphome-build.outputs.version }} > output/version
# Extract MD5 checksum of firmware.ota.bin
MD5_CHECKSUM=$(jq -r '.ota.md5' output/manifest.json)
echo "MD5_CHECKSUM=$MD5_CHECKSUM" >> $GITHUB_ENV
# Create new manifest.json with jq
jq -n --arg name "${{ env.DEVICE_NAME }}" \
--arg version "${{ env.project_version }}" \
--arg md5 "$MD5_CHECKSUM" \
'{name: $name, version: $version, home_assistant_domain: "esphome", new_install_prompt_erase: false, builds: [{chipFamily: "ESP32-C3", parts: [{path: "apollo-${{ env.DEVICE_NAME }}-esp32c3.factory.bin", offset: 0}], ota: {path: "apollo-${{ env.DEVICE_NAME }}-esp32c3.ota.bin", md5: $md5}}]}' > output/manifest.json
- uses: actions/upload-artifact@v4.3.3
with:
path: output/
retention-days: 1

- name: Collect merge commits
id: collect_commits
run: |
MERGE_COMMITS=$(git log --merges --pretty=format:"%h %s" $(git describe --tags --abbrev=0 @^)..@)
echo "MERGE_COMMITS=$MERGE_COMMITS" >> $GITHUB_ENV
- name: Create Release
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
with:
tag_name: ${{ env.project_version }}
release_name: "Release ${{ env.project_version }}"
body: Release of version ${{ env.project_version }}

draft: false
prerelease: false

- name: Upload firmware.factory.bin to Release
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: output/apollo-${{ env.DEVICE_NAME }}-esp32c3.factory.bin
asset_name: apollo-${{ env.DEVICE_NAME }}-esp32c3.factory.bin
asset_content_type: application/octet-stream

- name: Upload firmware.ota.bin to Release
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: output/apollo-${{ env.DEVICE_NAME }}-esp32c3.ota.bin
asset_name: apollo-${{ env.DEVICE_NAME }}-esp32c3.ota.bin
asset_content_type: application/octet-stream
- name: Upload firmware.ota.bin to Release
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: output/manifest.json
asset_name: manifest.json
asset_content_type: application/octet-stream


prep:
name: Consolidate firmwares
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4.1.7
with:
path: output
- run: cp -R static/* output/
- uses: actions/upload-pages-artifact@v3.0.1
with:
path: output
retention-days: 1

deploy:
if: contains(fromJSON('["workflow_dispatch", "push", "schedule"]'), github.event_name) && github.ref == 'refs/heads/main'
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
needs: prep
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4.0.5
33 changes: 33 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 'Discord Publisher'

on:
workflow_dispatch:
push:
branches:
- main
pull_request:

permissions:
contents: read
pull-requests: read
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
check-links:
runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }}
steps:
- name: Discord Commits
uses: Sniddl/discord-commits@v1.6
with:
# discord webhook url without /github
webhook: ${{ secrets.DISCORDHOOK }}
# A general message that is displayed for all commits. Defaults to the repo name.
message: 'MSR-2'
# Boolean - Include extra embeds provided from templates.
#include-extras: # optional
# The name of of a premade template.
#template: # optional
# Boolean - only show the last commit.
#last-commit-only: # optional
Binary file removed 3D Files/MSR-2 Articulating Back.stl
Binary file not shown.
Binary file removed 3D Files/MSR-2 Back Female USB.stl
Binary file not shown.
Binary file removed 3D Files/MSR-2 Backplate.stl
Binary file not shown.
Binary file removed 3D Files/MSR-2 GPIO Backplate.stl
Binary file not shown.
Binary file removed 3D Files/MSR-2_Ball.stl
Binary file not shown.
Binary file removed 3D Files/MSR-2_Case.stl
Binary file not shown.
35 changes: 30 additions & 5 deletions Integrations/ESPHome/MSR-2.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Define Project
substitutions:
name: apollo-msr-2
version: "24.6.20.1"
version: "24.7.2.1"
device_description: ${name} made by Apollo Automation - version ${version}.

esphome:
Expand Down Expand Up @@ -41,8 +41,30 @@ dashboard_import:
package_import_url: github://ApolloAutomation/MSR-2/Integrations/ESPHome/MSR-2.yaml
import_full_config: false


ota:
- platform: esphome
id: ota_default
- platform: http_request
id: ota_managed

http_request:
useragent: esphome/device
timeout: 10s
verify_ssl: false

update:
- platform: http_request
id: firmware_update
name: Firmware Update
source: https://apolloautomation.github.io/MSR-2/artifact/manifest.json

improv_serial:

esp32_improv:
authorizer: none

logger:
level: WARN

globals:
- id: button_press_timestamp
Expand Down Expand Up @@ -103,12 +125,14 @@ api:
id: ld2410_radar
password: !lambda 'return password;'

ota:
- platform: esphome

wifi:
on_connect:
- delay: 5s # Gives time for improv results to be transmitted
- ble.disable:
on_disconnect:
- ble.enable:

power_save_mode: none

# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
Expand Down Expand Up @@ -333,6 +357,7 @@ binary_sensor:
pin:
number: GPIO9
inverted: true
ignore_strapping_warning: true
mode:
input: true
pullup: true
Expand Down
Binary file removed Integrations/ESPHome/firmware.factory.bin
Binary file not shown.
13 changes: 0 additions & 13 deletions Integrations/ESPHome/manifest.json

This file was deleted.

5 changes: 2 additions & 3 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ Fixes:
Breaks:



Checks:
- [ ] Documentation Updated
- [ ] Build Number Incremented In MSR-1.yaml
- [ ] Build Number Incremented In manifest.json
- [ ] firmware-factory.bin Updated
- [ ] Build Number Incremented In AIR-1.yaml
2 changes: 1 addition & 1 deletion index.html → static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<h1>Apollo MSR-2 Installer</h1>

<p class="button-row" align="center">
<esp-web-install-button manifest="./Integrations/ESPHome/manifest.json">
<esp-web-install-button manifest="./artifact/manifest.json">
</esp-web-install-button>
</p>

Expand Down

0 comments on commit 99d7b19

Please sign in to comment.