Skip to content

Commit e8d7c3c

Browse files
Build Automation 1
1 parent 38d4ee0 commit e8d7c3c

File tree

5 files changed

+240
-13
lines changed

5 files changed

+240
-13
lines changed

.github/workflows/ESPHome.yml

-13
This file was deleted.

.github/workflows/auto-build.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
#Source: https://github.com/esphome-econet/esphome-econet
3+
name: Auto-Build for CI
4+
5+
on:
6+
pull_request:
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build:
15+
uses: ./.github/workflows/build.yml
16+
with:
17+
force-verbose-logging: true
+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
name: Build and Publish
3+
4+
on:
5+
release:
6+
types: [published]
7+
workflow_dispatch:
8+
inputs:
9+
dry_run:
10+
type: boolean
11+
default: false
12+
required: false
13+
description: "Dry Run: Don't actually deploy to github-pages"
14+
15+
concurrency:
16+
group: ${{ github.workflow }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
build:
21+
uses: ./.github/workflows/build.yml
22+
with:
23+
upload-artifacts: true
24+
25+
consolidate-manifests:
26+
name: Consolidate ${{ matrix.appliance.shorthand }} manifests
27+
runs-on: ubuntu-latest
28+
needs: build
29+
strategy:
30+
matrix:
31+
appliance:
32+
- name: PWR-1
33+
shorthand: pwr_1
34+
fail-fast: false
35+
steps:
36+
- name: Download built firmwares
37+
uses: actions/download-artifact@v4
38+
with:
39+
path: firmwares
40+
- name: Dump Files
41+
run: |-
42+
ls -R firmwares
43+
- name: Copy files
44+
run: |-
45+
mkdir output
46+
- name: Consolidate manifests
47+
run: |-
48+
jq -s '{"name": "esphome-apollo", "new_install_improv_wait_time": 15, "new_install_prompt_erase": false, "version": "${{ github.ref_name }}", "home_assistant_domain": "esphome", "builds":.}' firmwares/*/apollo-${{ matrix.appliance.shorthand }}-*/manifest.json > output/apollo-${{ matrix.appliance.shorthand }}.json
49+
- name: Upload artifact
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: apollo-${{ matrix.appliance.shorthand }}
53+
path: output
54+
retention-days: 7
55+
56+
consolidate:
57+
name: Consolidate firmwares
58+
runs-on: ubuntu-latest
59+
needs: consolidate-manifests
60+
steps:
61+
- name: Checkout source code
62+
uses: actions/checkout@v4
63+
- name: Download built firmwares
64+
uses: actions/download-artifact@v4
65+
with:
66+
path: firmwares
67+
- name: Dump Files
68+
run: |-
69+
ls -R firmwares
70+
- name: Copy files
71+
run: |-
72+
mkdir output
73+
cp -R firmwares/*/* output/
74+
ls -R output/
75+
- name: Upload GitHub Pages artifact
76+
uses: actions/upload-pages-artifact@v3
77+
with:
78+
path: output
79+
80+
deploy:
81+
if: ${{ ! inputs.dry_run }}
82+
name: Deploy to GitHub Pages
83+
runs-on: ubuntu-latest
84+
needs: consolidate
85+
permissions:
86+
pages: write
87+
id-token: write
88+
environment:
89+
name: github-pages
90+
url: ${{ steps.deployment.outputs.page_url }}
91+
steps:
92+
- name: Setup Pages
93+
uses: actions/configure-pages@v4
94+
- name: Deploy to GitHub Pages
95+
id: deployment
96+
uses: actions/deploy-pages@v4

.github/workflows/build.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
name: Build Firmware
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
upload-artifacts:
8+
type: boolean
9+
required: false
10+
default: false
11+
description: "Set to true to have this workflow upload resulting firmware artifacts."
12+
force-verbose-logging:
13+
type: boolean
14+
required: false
15+
default: false
16+
description: "Set to true to have this workflow force verbose logging, useful for catching build failures in logging code."
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
build:
24+
name: Build ${{ matrix.appliance.shorthand }}-${{ matrix.platform }} Firmware
25+
runs-on: ubuntu-latest
26+
strategy:
27+
matrix:
28+
platform: [esp32c3]
29+
appliance:
30+
- name: PWR-1
31+
shorthand: pwr_1
32+
fail-fast: true
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Force Manifest to Build Local Code
36+
uses: mikefarah/yq@v4
37+
with:
38+
cmd: >
39+
Integrations/ESPHome/PWR-1.yaml
40+
- name: Force Verbose Logging
41+
if: ${{ inputs.force-verbose-logging }}
42+
uses: mikefarah/yq@v4
43+
with:
44+
cmd: >
45+
yq -P -i
46+
'
47+
.substitutions.logger_level = "VERY_VERBOSE"
48+
'
49+
Integrations/ESPHome/PWR-1.yaml
50+
- name: Build Firmware
51+
id: esphome-build
52+
uses: esphome/[email protected]
53+
with:
54+
yaml_file: Integrations/ESPHome/PWR-1.yaml
55+
- name: Copy firmware and manifest
56+
if: ${{ inputs.upload-artifacts }}
57+
run: |
58+
mkdir output
59+
mv ${{ steps.esphome-build.outputs.name }} output/
60+
- name: Upload artifact
61+
if: ${{ inputs.upload-artifacts }}
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: apollo-${{ matrix.appliance.shorthand }}-${{ matrix.platform }}
65+
path: output
66+
retention-days: 7
67+
build-status: # Needed to provide an overall status on this job rather than just the various matrix jobs
68+
name: Compile Build Status
69+
needs: build
70+
runs-on: ubuntu-latest
71+
if: ${{ always() }}
72+
steps:
73+
- name: Check build matrix status
74+
if: ${{ needs.build.result != 'success' }}
75+
run: exit 1
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
name: Release Firmware
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
bump:
8+
type: choice
9+
default: "patch"
10+
required: true
11+
description: "The type of semantic version increment to make."
12+
options:
13+
- patch
14+
- minor
15+
- major
16+
17+
jobs:
18+
update-version-strings:
19+
name: Update Version Strings
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Generate Release Version
23+
id: generate_release_version
24+
uses: zwaldowski/semver-release-action@v3
25+
with:
26+
bump: ${{ inputs.bump }}
27+
github_token: ${{ secrets.GITHUB_TOKEN }}
28+
prefix: "v"
29+
dry_run: true
30+
- uses: actions/checkout@v4
31+
with:
32+
token: ${{ secrets.GITHUBACTION }}
33+
- name: Update Project Version String
34+
uses: mikefarah/yq@v4
35+
with:
36+
cmd: >
37+
yq -i
38+
'
39+
.esphome.project.version = "${{ steps.generate_release_version.outputs.version_tag }}"
40+
'
41+
econet_base.yaml
42+
- name: Commit Changes
43+
uses: stefanzweifel/git-auto-commit-action@v5
44+
with:
45+
commit_message: "Automated project versioning update"
46+
push_options: '--force'
47+
- name: Create Release
48+
uses: ncipollo/release-action@v1
49+
with:
50+
generateReleaseNotes: true
51+
tag: ${{ steps.generate_release_version.outputs.version_tag }}
52+
token: ${{ secrets.GITHUBACTION }}

0 commit comments

Comments
 (0)