Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorSchirmer authored Sep 23, 2024
0 parents commit b5ca997
Show file tree
Hide file tree
Showing 11 changed files with 607 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/autoassign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Auto Assign
on:
issues:
types: [opened]
pull_request:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: 'Auto-assign issue'
uses: pozil/auto-assign-issue@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
assignees: TrevorSchirmer
numOfAssignee: 1
143 changes: 143 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: Build
env:
DEVICE_NAME: plt-1 # TODO: Rename
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/[email protected]
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/Core.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/[email protected]
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 manifest.json 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/[email protected]
with:
path: output
- run: cp -R static/* output/
- uses: actions/[email protected]
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/[email protected]
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI

on:
pull_request:

jobs:
ci:
name: Building ${{ matrix.file }}
runs-on: ubuntu-latest
strategy:
matrix:
file: # TODO: Rename
- Integrations/ESPHome/PLT-1.yaml
- Integrations/ESPHome/PLT-1_BLE.yaml
steps:
- name: Checkout source code
uses: actions/[email protected]
- name: Build ESPHome firmware to verify configuration
uses: esphome/[email protected]
with:
yaml_file: ${{ matrix.file }}
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
Integrations/ESPHome/.DS_Store
Integrations/.DS_Store
.DS_Store
5 changes: 5 additions & 0 deletions Integrations/ESPHome/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Gitignore settings for ESPHome
# This is an example and may include too much for your use-case.
# You can modify this file to suit your needs.
/.esphome/
/secrets.yaml
53 changes: 53 additions & 0 deletions Integrations/ESPHome/AIR-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
esphome:
name: "${name}"
friendly_name: Apollo AIR-1 # TODO: Rename
comment: Apollo AIR-1 # TODO: Rename
name_add_mac_suffix: true
platformio_options:
board_build.flash_mode: dio

project:
name: "ApolloAutomation.AIR-1" # TODO: Rename
version: "${version}"

min_version: 2023.11.1

dashboard_import:
package_import_url: github://ApolloAutomation/AIR-1/Integrations/ESPHome/AIR-1.yaml
import_full_config: false # TODO: Rename

improv_serial:

esp32_improv:
authorizer: none

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

http_request:
verify_ssl: true

safe_mode:

update:
- platform: http_request
id: firmware_update
name: Firmware Update
source: https://apolloautomation.github.io/PLT-1/artifact/manifest.json # TODO: Rename

wifi:
on_connect:
- delay: 5s
- ble.disable:
on_disconnect:
- ble.enable:
ap:
ssid: "Apollo PLT1 Hotspot" # TODO: Rename

logger:

packages:
core: !include Core.yaml
26 changes: 26 additions & 0 deletions Integrations/ESPHome/Core.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
substitutions:
name: apollo-plt-1 # TODO: Rename
version: "24.8.7.2"
device_description: ${name} made by Apollo Automation - version ${version}.

esp32:
board: esp32-c3-devkitm-1
framework:
type: esp-idf

api:

globals:
- id: cycleCounter
type: int
restore_value: no
initial_value: '0'
- id: button_press_timestamp
restore_value: no
type: uint32_t
initial_value: '0'

captive_portal:

web_server:
port: 80
Loading

0 comments on commit b5ca997

Please sign in to comment.