diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index d6aca03..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,143 +0,0 @@ -name: Build -env: - DEVICE_NAME: h-1 - 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/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/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 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/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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..2374f13 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,103 @@ +name: Publish +on: + push: + branches: + - main + workflow_dispatch: + inputs: + version: + description: 'The version of the firmware to build' + required: true + release: + types: [published] + +jobs: + build-firmware: + name: Build And Release + uses: esphome/workflows/.github/workflows/build.yml@main + with: + files: | + Integrations/ESPHome/H-1.yaml + esphome-version: stable + combined-name: firmware + release-summary: ${{ github.event_name == 'release' && github.event.release.body || '' }} + release-url: ${{ github.event_name == 'release' && github.event.release.html_url || '' }} + release-version: ${{ (github.event_name == 'release' && github.event.release.tag_name) || (github.event_name == 'workflow_dispatch' && inputs.version) || '' }} + + build-firmware-d: + name: Build And Release + uses: esphome/workflows/.github/workflows/build.yml@main + with: + files: | + Integrations/ESPHome/H-1D.yaml + esphome-version: stable + combined-name: firmware-d + release-summary: ${{ github.event_name == 'release' && github.event.release.body || '' }} + release-url: ${{ github.event_name == 'release' && github.event.release.html_url || '' }} + release-version: ${{ (github.event_name == 'release' && github.event.release.tag_name) || (github.event_name == 'workflow_dispatch' && inputs.version) || '' }} + + build-site: + name: Build Site + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v4.1.7 + - name: Build + uses: actions/jekyll-build-pages@v1.0.13 + with: + source: ./static + destination: ./output + - name: Upload + uses: actions/upload-artifact@v4.3.6 + with: + name: site + path: output + + publish: + name: Publish to GitHub Pages + runs-on: ubuntu-latest + needs: + - build-firmware + - build-firmware-d + - build-site + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - uses: actions/download-artifact@v4.1.8 + with: + name: firmware + path: firmware + - uses: actions/download-artifact@v4.1.8 + with: + name: firmware-d + path: firmware-d + + - name: Copy firmware and manifest + run: |- + mkdir -p output/firmware + cp -r firmware/${{ needs.build-firmware.outputs.version }}/* output/firmware/ + - name: Copy firmware and manifest + run: |- + mkdir -p output/firmware-d + cp -r firmware-d/${{ needs.build-firmware.outputs.version }}/* output/firmware-d/ + + - uses: actions/download-artifact@v4.1.8 + with: + name: site + path: output + + - uses: actions/upload-pages-artifact@v3.0.1 + with: + path: output + retention-days: 1 + + - name: Setup Pages + uses: actions/configure-pages@v5.0.0 + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4.0.5 diff --git a/Integrations/ESPHome/Core.yaml b/Integrations/ESPHome/Core.yaml index 2217d4f..0a9fe85 100644 --- a/Integrations/ESPHome/Core.yaml +++ b/Integrations/ESPHome/Core.yaml @@ -1,6 +1,6 @@ substitutions: name: apollo-h-1 - version: "24.10.28.1" + version: "24.10.29.1" device_description: ${name} made by Apollo Automation - version ${version}. esp32: diff --git a/static/_config.yml b/static/_config.yml new file mode 100644 index 0000000..c97972f --- /dev/null +++ b/static/_config.yml @@ -0,0 +1,4 @@ +# CHANGEME: Set these variable to your liking +title: Apollo H-1 Installer +description: Powered by ESPHome and ESP Web Tools +theme: jekyll-theme-slate diff --git a/index.html b/static/index.html similarity index 82% rename from index.html rename to static/index.html index 5c97474..0092c1f 100644 --- a/index.html +++ b/static/index.html @@ -81,10 +81,16 @@