Skip to content

Commit

Permalink
Merge pull request #79 from esphome/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jesserockz authored Apr 18, 2024
2 parents 9ef76dd + 60e7a92 commit 21f581e
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 125 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
push:
branches:
- main
- dev
pull_request:

jobs:
build:
name: Build ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: Captive Portal
directory: captive-portal
- name: Webserver v2
directory: v2
- name: Webserver v3
directory: v3
steps:
- name: Clone the repo
uses: actions/[email protected]
- name: Set up Node.JS
uses: actions/[email protected]
- name: Install dependencies
run: npm install
- name: Build ${{ matrix.name }}
run: npm run build
working-directory: packages/${{ matrix.directory }}
69 changes: 69 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Release

on:
push:
branches:
- main

jobs:
build:
name: Build ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: Captive Portal
directory: captive-portal
- name: Webserver v2
directory: v2
- name: Webserver v3
directory: v3
steps:
- name: Clone the repo
uses: actions/[email protected]

- name: Set up Node.JS
uses: actions/[email protected]

- name: Install dependencies
run: npm install

- name: Build ${{ matrix.name }}
run: npm run build
working-directory: packages/${{ matrix.directory }}

- uses: actions/[email protected]
with:
name: ${{ matrix.name }}
path: _static/**/*.h

release:
name: Tag and Release
runs-on: ubuntu-latest
needs: build
steps:
# Checkout repo, create new git tag, and git release with artifacts
- name: Checkout the repo
uses: actions/[email protected]

- name: Create a new tag
id: create_tag
run: echo tag=$(date +'%Y%m%d-%H%M%S') >> $GITHUB_OUTPUT

- name: Download Artifacts
uses: actions/[email protected]
with:
path: headers
merge-multiple: true

- name: List files
run: ls -R headers

- name: Create a release
id: create_release
uses: softprops/[email protected]
with:
tag_name: ${{ steps.create_tag.outputs.tag }}
name: Release ${{ steps.create_tag.outputs.tag }}
files: headers/**/*.h
generate_release_notes: true
107 changes: 0 additions & 107 deletions captive-portal/dist/captive_index.h

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "esphome-captive_portal",
"name": "@esphome-webserver/captive-portal",
"version": "2.0.0",
"main": "main.ts",
"license": "MIT",
Expand All @@ -8,7 +8,7 @@
"dev": "vite",
"build": "vite build && npm run deploy",
"serve": "vite preview",
"deploy": "bash -c '../scripts/make_header.sh dist captive_index.h captive_portal'"
"deploy": "bash -c '../../scripts/make_header.sh ../../_static/captive_portal captive_index.h captive_portal'"
},
"dependencies": {
"rollup-plugin-generate-html-template": "^1.7.0",
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "vite";
import gzipPlugin from "rollup-plugin-gzip";
import { viteSingleFile } from 'vite-plugin-singlefile'
import { viteSingleFile } from "vite-plugin-singlefile";

import minifyHTML from "rollup-plugin-minify-html-template-literals";
import { minifyHtml as ViteMinifyHtml } from "vite-plugin-html";
Expand All @@ -13,19 +13,19 @@ export default defineConfig({
ViteMinifyHtml(),
{
...gzipPlugin({ filter: /\.(html)$/ }),
enforce: "post",
apply: "build",
},
enforce: "post",
apply: "build",
},
],
css: {
postcss: {
},
},
postcss: {},
},
build: {
brotliSize: false,
cssCodeSplit: false,
outDir: "../../_static/captive_portal",
assetsInlineLimit: 100000000,
polyfillModulePreload: false
polyfillModulePreload: false,
},
server: {
open: "/", // auto open browser
Expand Down
2 changes: 1 addition & 1 deletion packages/v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"xbuild": "vite build --emptyOutDir",
"build": "vite build --emptyOutDir && npm run deploy",
"serve": "vite preview",
"deploy": "bash -c '../../scripts/make_header.sh ../../_static/v2 server_index.h web_server'"
"deploy": "bash -c '../../scripts/make_header.sh ../../_static/v2 server_index_v2.h web_server 2'"
},
"dependencies": {
"http-proxy-middleware": "^2.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/v3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"xbuild": "vite build --emptyOutDir",
"build": "vite build --emptyOutDir && npm run deploy",
"serve": "vite preview",
"deploy": "bash -c '../../scripts/make_header.sh ../../_static/v3 server_index.h web_server'"
"deploy": "bash -c '../../scripts/make_header.sh ../../_static/v3 server_index_v3.h web_server 3'"
},
"dependencies": {
"chart.js": "^4.4.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/v3/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default defineConfig({
...gzipPlugin({ filter: /\.(js|css|html|svg)$/ }),
enforce: "post",
apply: "build",
}
},
],
build: {
brotliSize: false,
Expand Down
11 changes: 6 additions & 5 deletions scripts/make_header.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#!/bin/bash
cat <<EOT > ./$1/$2
cat <<EOT >./$1/$2
#pragma once
// Generated from https://github.com/esphome/esphome-webserver
$(if [ -n "$4" ]; then echo "#if USE_WEBSERVER_VERSION == $4"; fi)
#include "esphome/core/hal.h"
namespace esphome {
namespace $3 {
EOT
echo "const uint8_t INDEX_GZ[] PROGMEM = {" >> ./$1/$2
xxd -cols 19 -i $1/index.html.gz | sed -e '2,$!d' -e 's/^/ /' -e '$d' | sed -e '$d' | sed -e '$s/$/};/' >> ./$1/$2
cat <<EOT >> ./$1/$2
echo "const uint8_t INDEX_GZ[] PROGMEM = {" >>./$1/$2
xxd -cols 19 -i $1/index.html.gz | sed -e '2,$!d' -e 's/^/ /' -e '$d' | sed -e '$d' | sed -e '$s/$/};/' >>./$1/$2
cat <<EOT >>./$1/$2
} // namespace $3
} // namespace esphome
$(if [ -n "$4" ]; then echo "#endif"; fi)
EOT
ls -l ./$1/$2

0 comments on commit 21f581e

Please sign in to comment.