Skip to content

Commit

Permalink
🏗️ Add workflows and bundling
Browse files Browse the repository at this point in the history
 * Get ready for HACS
  • Loading branch information
hyperb1iss committed Jul 27, 2024
1 parent d349f42 commit ce2c48e
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 7 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Continuous Integration

on:
push:
branches: [ main, master, develop ]
pull_request:
branches: [ main, master ]

jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run tests
run: npm test
- name: Build project
run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
name: dist
path: dist

analyze:
needs: build_and_test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npx eslint .
continue-on-error: true
- name: Run TypeScript compiler
run: npx tsc --noEmit
continue-on-error: true
55 changes: 55 additions & 0 deletions .github/workflows/release.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release

on:
push:
tags:
- "v*.*.*"

jobs:
build_test_and_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run tests
run: npm test
- name: Build project
run: npm run build:hacs
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body_path: CHANGELOG.md
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/hyper-light-card-bundle.js
asset_name: hyper-light-card-bundle.js
asset_content_type: application/javascript
5 changes: 5 additions & 0 deletions hacs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "hyper-light-card",
"render_readme": true,
"filename": "hyper-light-card-bundle.js"
}
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
"test": "jest",
"test:watch": "jest --watch",
"copy:hass": "node scripts/copy-to-hass.js",
"dev": "npm run build:dev && npm run copy:hass"
"dev": "npm run build:dev && npm run copy:hass",
"build:hacs": "rollup -c --environment BUILD:production && cp dist/hyper-light-card.js dist/hyper-light-card-bundle.js"
},
"keywords": [
"home-assistant",
"lovelace",
"custom-card",
"signalrgb"
],
"author": "Your Name",
"license": "MIT",
"author": "hyperb1iss",
"license": "Apache 2.0",
"devDependencies": {
"@babel/core": "^7.24.9",
"@babel/plugin-transform-typescript": "^7.25.0",
Expand Down Expand Up @@ -87,10 +88,10 @@
},
"repository": {
"type": "git",
"url": "https://github.com/your-username/hyper-light-card.git"
"url": "https://github.com/hyperb1iss/hyper-light-card.git"
},
"bugs": {
"url": "https://github.com/your-username/hyper-light-card/issues"
"url": "https://github.com/hyperb1iss/hyper-light-card/issues"
},
"homepage": "https://github.com/your-username/hyper-light-card#readme"
"homepage": "https://github.com/hyperb1iss/hyper-light-card#readme"
}
2 changes: 1 addition & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const development = process.env.BUILD === 'development';
export default {
input: 'src/hyper-light-card.ts',
output: {
file: 'dist/hyper-light-card.js',
dir: 'dist',
format: 'es',
sourcemap: true, // Always generate source map
},
Expand Down

0 comments on commit ce2c48e

Please sign in to comment.