chore(ci): Add Devcontainer and github action for auto-release management (#537)

* Add devcontainer

* Add github-actions and semantic-release
This commit is contained in:
Jérôme W
2021-01-17 17:07:56 +01:00
committed by GitHub
parent ae43d93755
commit bbde47b381
14 changed files with 11289 additions and 13 deletions

View File

@@ -0,0 +1,9 @@
lovelace:
mode: yaml
resources:
- url: http://127.0.0.1:5000/mini-graph-card-bundle.js
type: module
default_config:
demo:

View File

@@ -0,0 +1,35 @@
{
"name": "Mini Graph Card Development",
"image": "ghcr.io/ludeeus/devcontainer/generic:latest",
"context": "..",
// "remoteUser": "vscode",
"appPort": [
"8123:8123",
"5000:5000",
],
"postCreateCommand": "npm install && container install",
"extensions": [
"github.vscode-pull-request-github",
"eamodio.gitlens",
"dbaeumer.vscode-eslint",
"redhat.vscode-yaml",
"yzhang.markdown-all-in-one",
],
"settings": {
"files.eol": "\n",
"editor.tabSize": 2,
"terminal.integrated.shell.linux": "/bin/bash",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true,
"markdown.extension.toc.githubCompatibility": true,
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/**": true,
"**/.hg/store/**": true,
"**/.rpt2_cache/**": true
}
}
}

View File

@@ -0,0 +1,6 @@
views:
- title: Main
cards:
- type: custom:mini-graph-card
entities:
- sensor.outside_humidity

11
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 0
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

60
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,60 @@
name: CI
on:
pull_request:
branches:
- "*"
push:
branches:
- "*"
jobs:
lint:
runs-on: ubuntu-latest
# push or fork
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v2.1.4
with:
node-version: 12.x
- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.OS }}-node-12.x-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-12.x
${{ runner.OS }}-
- name: Install dependencies
run: npm ci
- name: Lint the code
run: npm run lint --if-present
build:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
node-version: [10.x, 12.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2.1.4
with:
node-version: ${{ matrix.node-version }}
- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.OS }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-${{ matrix.node-version }}
${{ runner.OS }}-
- name: Install dependencies
run: npm ci
- name: Build the project
run: npm run build --if-present

34
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,34 @@
name: Release
on: workflow_dispatch
jobs:
release-bundle:
runs-on: ubuntu-latest
outputs:
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v2.1.4
with:
node-version: 12.x
- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.OS }}-node-12.x-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-12.x
${{ runner.OS }}-
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2
.gitignore vendored
View File

@@ -1,5 +1,3 @@
/node_modules/
/dist/
package-lock.json
.vscode/
.DS_Store

1
.nvmrc
View File

@@ -1 +0,0 @@
v8.12.0

View File

@@ -1,8 +0,0 @@
language: node_js
node_js:
- "10.15.0"
- "8.12.0"
script:
- npm run lint
- npm run rollup
- npm run babel

16
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8123",
"webRoot": "${workspaceFolder}/dist",
"sourceMaps": true
}
]
}

11082
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -38,8 +38,9 @@
"eslint": "^5.3.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.17.2",
"rollup": "^0.66.6",
"rollup-plugin-node-resolve": "^3.4.0"
"rollup": "^2.33.1",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-serve": "^1.1.0"
},
"scripts": {
"build": "npm run lint && npm run rollup && npm run babel",

19
release.config.js Normal file
View File

@@ -0,0 +1,19 @@
module.exports = {
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
["@semantic-release/npm", {
"npmPublish": false,
}],
["@semantic-release/github", {
"assets": "dist/*.js"
}],
"@semantic-release/git"
],
"preset": "angular",
"branches": [
"master",
{ "name": "dev", "prerelease": true },
]
}

View File

@@ -1,5 +1,17 @@
import resolve from 'rollup-plugin-node-resolve';
import json from '@rollup/plugin-json';
import serve from 'rollup-plugin-serve';
const dev = process.env.ROLLUP_WATCH;
const serveopts = {
contentBase: ['./dist'],
host: '0.0.0.0',
port: 5000,
allowCrossOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
};
export default {
input: 'src/main.js',
@@ -7,6 +19,7 @@ export default {
file: 'dist/mini-graph-card-bundle.js',
format: 'umd',
name: 'MiniGraphCard',
sourcemap: dev ? true : false,
},
plugins: [
json({
@@ -14,5 +27,6 @@ export default {
preferConst: true,
}),
resolve(),
dev && serve(serveopts),
],
};