-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
312 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
name: Build | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
files: | ||
description: Newline separated list of files to build | ||
required: true | ||
type: string | ||
esphome-version: | ||
description: Version of ESPHome to build with | ||
required: false | ||
type: string | ||
default: latest | ||
release-summary: | ||
description: Summary of the release | ||
required: false | ||
type: string | ||
default: "" | ||
release-url: | ||
description: URL to the release notes | ||
required: false | ||
type: string | ||
default: "" | ||
release-version: | ||
description: Version of the release | ||
required: false | ||
type: string | ||
default: "" | ||
combined-name: | ||
description: Combine all files into a single manifest under this name | ||
required: false | ||
type: string | ||
default: "" | ||
|
||
outputs: | ||
version: | ||
description: Version of the firmware generated | ||
value: ${{ jobs.prepare.outputs.version }} | ||
|
||
jobs: | ||
prepare: | ||
name: Prepare | ||
runs-on: ubuntu-latest | ||
outputs: | ||
files: ${{ steps.files-array.outputs.files }} | ||
version: ${{ steps.version.outputs.version }} | ||
artifact-prefix: ${{ steps.artifact-name.outputs.artifact-prefix }} | ||
steps: | ||
- name: Split files input into JSON array | ||
id: files-array | ||
run: | | ||
files=$(echo "${{ inputs.files }}" | jq -RcSn '[inputs | select(length>0)]') | ||
echo files=$files >> $GITHUB_OUTPUT | ||
- name: Generate version | ||
id: version | ||
run: | | ||
if [ -n "${{ inputs.release-version }}" ]; then | ||
version=${{ inputs.release-version }} | ||
else | ||
version=dev-$(date +'%Y%m%d-%H%M') | ||
fi | ||
echo version=$version >> $GITHUB_OUTPUT | ||
- name: Generated random artifact prefix | ||
id: artifact-name | ||
run: | | ||
artifact_prefix=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 16; echo) | ||
echo artifact-prefix=$artifact_prefix >> $GITHUB_OUTPUT | ||
build: | ||
name: ${{ matrix.file }} | ||
needs: [prepare] | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
max-parallel: 3 | ||
matrix: | ||
file: ${{ fromJson(needs.prepare.outputs.files) }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
- name: Replace project version | ||
run: | | ||
sed -i "s/version: dev/version: ${{ needs.prepare.outputs.version }}/g" ${{ matrix.file }} | ||
- name: Build Firmware | ||
uses: esphome/[email protected] | ||
id: esphome-build | ||
with: | ||
yaml-file: ${{ matrix.file }} | ||
version: ${{ inputs.esphome-version }} | ||
complete-manifest: true | ||
release-summary: ${{ inputs.release-summary }} | ||
release-url: ${{ inputs.release-url }} | ||
- name: Move files for versioning | ||
run: | | ||
mkdir -p output/${{ needs.prepare.outputs.version }} | ||
mv ${{ steps.esphome-build.outputs.name }}/* output/${{ needs.prepare.outputs.version }}/ | ||
- name: Upload artifact | ||
uses: actions/[email protected] | ||
with: | ||
name: ${{ inputs.combined-name != '' && format('{0}-{1}', needs.prepare.outputs.artifact-prefix, steps.esphome-build.outputs.name) || steps.esphome-build.outputs.original-name }} | ||
path: output | ||
|
||
combine: | ||
name: Combine manifests | ||
needs: | ||
- prepare | ||
- build | ||
runs-on: ubuntu-latest | ||
if: inputs.combined-name != '' | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/[email protected] | ||
with: | ||
path: files | ||
pattern: ${{ needs.prepare.outputs.artifact-prefix }}-* | ||
|
||
- name: Get artifact names | ||
id: artifacts | ||
run: | | ||
artifacts=$(ls --format=single-column files) | ||
echo "artifacts<<EOF" >> $GITHUB_OUTPUT | ||
echo "$artifacts" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
- name: Delete prefixed artifacts | ||
uses: geekyeggo/[email protected] | ||
with: | ||
name: ${{ steps.artifacts.outputs.artifacts }} | ||
|
||
- name: Combine all parts into a single manifest | ||
run: | | ||
version="${{ needs.prepare.outputs.version }}" | ||
mkdir -p "output/$version" | ||
pushd files | ||
for device in *; do | ||
pushd $device | ||
pushd $version | ||
cp * "../../../output/$version/" | ||
cp manifest.json ../../../output/$version/manifest-`ls *.elf |cut -d. -f1`.json | ||
popd | ||
popd | ||
done | ||
popd | ||
jq -s '(.[0] | del(.builds)) + {"builds": (reduce .[].builds as $b ([]; . + $b))}' files/*/$version/manifest.json > output/$version/manifest.json | ||
- name: Upload artifact | ||
uses: actions/[email protected] | ||
with: | ||
name: ${{ inputs.combined-name }} | ||
path: output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Publish Firmware | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'The version of the firmware to build' | ||
required: true | ||
release: | ||
types: [published] | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
build-firmware: | ||
name: Build Firmware | ||
uses: ./.github/workflows/build.yaml | ||
with: | ||
#### Modify below here to match your project #### | ||
files: | | ||
tagtuner-D1-custom1.factory.yaml | ||
tagtuner-atom-grove-ble.factory.yaml | ||
tagtuner-for-tagreader.factory.yaml | ||
esphome-version: stable | ||
combined-name: tagtuner-firmware | ||
#### Modify above here to match your project #### | ||
|
||
release-summary: ${{ github.event.release.body }} | ||
release-url: ${{ github.event.release.html_url }} | ||
release-version: ${{ (github.event_name == 'release' && github.event.release.tag_name) || (github.event_name == 'workflow_dispatch' && inputs.version) || '' }} | ||
|
||
upload-to-release: | ||
name: Upload to Release | ||
uses: ./.github/workflows/upload-to-gh-release.yml | ||
needs: | ||
- build-firmware | ||
with: | ||
version: ${{ (github.event_name == 'release' && github.event.release.tag_name) || (github.event_name == 'workflow_dispatch' && inputs.version) || '' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Publish Pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'static/**' | ||
- '.github/workflows/publish-pages.yml' | ||
workflow_run: | ||
workflows: | ||
- Publish Firmware | ||
types: | ||
- completed | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout source code | ||
uses: actions/[email protected] | ||
|
||
- run: mkdir -p output/firmware | ||
|
||
- name: Build | ||
uses: actions/[email protected] | ||
with: | ||
source: ./static | ||
destination: ./output | ||
|
||
- name: Fetch firmware files | ||
uses: robinraju/[email protected] | ||
with: | ||
latest: true | ||
fileName: '*' | ||
out-file-path: output/firmware | ||
|
||
- name: Upload artifact | ||
uses: actions/[email protected] | ||
with: | ||
path: output | ||
retention-days: 1 | ||
|
||
publish: | ||
if: github.event_name != 'pull_request' | ||
name: Publish | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
permissions: | ||
pages: write | ||
id-token: write | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
steps: | ||
- name: Setup Pages | ||
uses: actions/[email protected] | ||
|
||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Upload firmware to GitHub Release | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
version: | ||
description: Version of the release | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
upload: | ||
name: Upload | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Download Artifact | ||
uses: actions/[email protected] | ||
with: | ||
path: files | ||
|
||
- name: Copy files to output | ||
run: |- | ||
shopt -s nullglob | ||
mkdir output | ||
version="${{ inputs.version }}" | ||
pushd files | ||
for device in *; do | ||
pushd $device | ||
pushd $version | ||
cp manifest*.json ../../../output/ | ||
for bin in *.{bin,elf}; do | ||
md5sum $bin | head -c 32 > ../../../output/$bin.md5 | ||
cp $bin ../../../output/ | ||
done | ||
popd | ||
popd | ||
done | ||
popd | ||
- name: Upload files to release | ||
uses: softprops/[email protected] | ||
with: | ||
files: output/* | ||
tag_name: ${{ inputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters