ci: Add initial semantic-release configuration (#1528)
This commit is contained in:
@@ -0,0 +1,54 @@
|
|||||||
|
---
|
||||||
|
name: Semantic Release
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
get-next-version:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: volta-cli/action@v4
|
||||||
|
- run: npx semantic-release --dry-run
|
||||||
|
id: get-next-version
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
outputs:
|
||||||
|
new-release-published: ${{ steps.get-next-version.outputs.new-release-published }}
|
||||||
|
new-release-version: ${{ steps.get-next-version.outputs.new-release-version }}
|
||||||
|
new-release-git-tag: ${{ steps.get-next-version.outputs.new-release-git-tag }}
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: get-next-version
|
||||||
|
if: needs.get-next-version.outputs.new-release-published == 'true'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: volta-cli/action@v4
|
||||||
|
- run: echo "The new release version is ${{ needs.get-next-version.outputs.new-release-version }}"
|
||||||
|
- run: echo "The new release git tag is ${{ needs.get-next-version.outputs.new-release-git-tag }}"
|
||||||
|
- run: yarn install --immutable
|
||||||
|
- run: yarn run build
|
||||||
|
env:
|
||||||
|
RELEASE_VERSION: ${{ needs.get-next-version.outputs.new-release-version }}
|
||||||
|
RELEASE_TAG: ${{ needs.get-next-version.outputs.new-release-git-tag }}
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- uses: thedoctor0/zip-release@0.7.6
|
||||||
|
with:
|
||||||
|
type: zip
|
||||||
|
path: dist
|
||||||
|
filename: frigate-hass-card.zip
|
||||||
|
- run: npx semantic-release --dry-run
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
+27
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "frigate-hass-card",
|
"name": "frigate-hass-card",
|
||||||
"version": "6.0.0-beta.1",
|
"version": "0.0.0-dev",
|
||||||
"description": "Frigate Lovelace Card for Home Assistant",
|
"description": "Frigate Lovelace Card for Home Assistant",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"frigate",
|
"frigate",
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"module": "frigate-hass-card.js",
|
"module": "frigate-hass-card.js",
|
||||||
"repository": "git@github.com:dermotduffy/frigate-hass-card.git",
|
"repository": "github:dermotduffy/frigate-hass-card",
|
||||||
"author": "Dermot Duffy <dermot.duffy@gmail.com>",
|
"author": "Dermot Duffy <dermot.duffy@gmail.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -60,6 +60,7 @@
|
|||||||
"@rollup/plugin-replace": "^5.0.7",
|
"@rollup/plugin-replace": "^5.0.7",
|
||||||
"@rollup/plugin-terser": "^0.4.4",
|
"@rollup/plugin-terser": "^0.4.4",
|
||||||
"@rollup/plugin-typescript": "^11.1.6",
|
"@rollup/plugin-typescript": "^11.1.6",
|
||||||
|
"@semantic-release/github": "^10.3.3",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/masonry-layout": "^4.2.8",
|
"@types/masonry-layout": "^4.2.8",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.13.0",
|
"@typescript-eslint/eslint-plugin": "^7.13.0",
|
||||||
@@ -79,12 +80,36 @@
|
|||||||
"rollup-plugin-styler": "^1.8.0",
|
"rollup-plugin-styler": "^1.8.0",
|
||||||
"rollup-plugin-visualizer": "^5.12.0",
|
"rollup-plugin-visualizer": "^5.12.0",
|
||||||
"sass": "patch:sass@npm%3A1.77.4#~/.yarn/patches/sass-npm-1.77.4-13b6910aea.patch",
|
"sass": "patch:sass@npm%3A1.77.4#~/.yarn/patches/sass-npm-1.77.4-13b6910aea.patch",
|
||||||
|
"semantic-release": "^24.1.1",
|
||||||
|
"semantic-release-export-data": "^1.1.0",
|
||||||
"ts-prune": "^0.10.3",
|
"ts-prune": "^0.10.3",
|
||||||
"type-fest": "^4.20.0",
|
"type-fest": "^4.20.0",
|
||||||
"typescript": "^5.4.5",
|
"typescript": "^5.4.5",
|
||||||
"vitest": "^1.6.0",
|
"vitest": "^1.6.0",
|
||||||
"vitest-mock-extended": "^1.3.1"
|
"vitest-mock-extended": "^1.3.1"
|
||||||
},
|
},
|
||||||
|
"release": {
|
||||||
|
"plugins": [
|
||||||
|
"@semantic-release/commit-analyzer",
|
||||||
|
"@semantic-release/release-notes-generator",
|
||||||
|
"semantic-release-export-data",
|
||||||
|
[
|
||||||
|
"@semantic-release/github",
|
||||||
|
{
|
||||||
|
"assets": [
|
||||||
|
{
|
||||||
|
"path": "dist/*.zip",
|
||||||
|
"label": "Zip distribution"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "dist/*.js",
|
||||||
|
"label": "JS distribution"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "rollup -c --watch",
|
"start": "rollup -c --watch",
|
||||||
"build": "yarn run lint && yarn run rollup",
|
"build": "yarn run lint && yarn run rollup",
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ const plugins = [
|
|||||||
preventAssignment: true,
|
preventAssignment: true,
|
||||||
values: {
|
values: {
|
||||||
'process.env.NODE_ENV': JSON.stringify(dev ? 'development' : 'production'),
|
'process.env.NODE_ENV': JSON.stringify(dev ? 'development' : 'production'),
|
||||||
|
__FRIGATE_CARD_RELEASE_VERSION__: process.env.RELEASE_VERSION ?? 'dev',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
watch && serve(serveopts),
|
watch && serve(serveopts),
|
||||||
|
|||||||
+2
-5
@@ -6,7 +6,6 @@ import { ifDefined } from 'lit/directives/if-defined.js';
|
|||||||
import { Ref, createRef, ref } from 'lit/directives/ref.js';
|
import { Ref, createRef, ref } from 'lit/directives/ref.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
import 'web-dialog';
|
import 'web-dialog';
|
||||||
import pkg from '../package.json';
|
|
||||||
import { actionHandler } from './action-handler-directive.js';
|
import { actionHandler } from './action-handler-directive.js';
|
||||||
import { ConditionsEvaluateRequestEvent } from './card-controller/conditions-manager.js';
|
import { ConditionsEvaluateRequestEvent } from './card-controller/conditions-manager.js';
|
||||||
import { CardController } from './card-controller/controller';
|
import { CardController } from './card-controller/controller';
|
||||||
@@ -34,6 +33,7 @@ import { localize } from './localize/localize.js';
|
|||||||
import cardStyle from './scss/card.scss';
|
import cardStyle from './scss/card.scss';
|
||||||
import { ExtendedHomeAssistant, MediaLoadedInfo, Message } from './types.js';
|
import { ExtendedHomeAssistant, MediaLoadedInfo, Message } from './types.js';
|
||||||
import { frigateCardHasAction } from './utils/action.js';
|
import { frigateCardHasAction } from './utils/action.js';
|
||||||
|
import { getReleaseVersion } from './utils/diagnostics';
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// General Card-Wide Notes
|
// General Card-Wide Notes
|
||||||
@@ -70,10 +70,7 @@ import { frigateCardHasAction } from './utils/action.js';
|
|||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
||||||
console.info(
|
console.info(
|
||||||
`%c FRIGATE-HASS-CARD \n` +
|
`%c FRIGATE-HASS-CARD \n` + `%c ${localize('common.version')} ` + getReleaseVersion(),
|
||||||
`%c ${localize('common.version')} ` +
|
|
||||||
`${pkg.version} ` +
|
|
||||||
`${process.env.NODE_ENV === 'development' ? `(${pkg['buildDate']})` : ''}`,
|
|
||||||
'color: pink; font-weight: bold; background: black',
|
'color: pink; font-weight: bold; background: black',
|
||||||
'color: white; font-weight: bold; background: dimgray',
|
'color: white; font-weight: bold; background: dimgray',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,6 +12,16 @@ interface GitDiagnostics {
|
|||||||
commit_date?: string;
|
commit_date?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getReleaseVersion = (): string => {
|
||||||
|
const releaseVersion = '__FRIGATE_CARD_RELEASE_VERSION__';
|
||||||
|
/* istanbul ignore if: this path cannot be reached during tests as the value
|
||||||
|
is substituted by rollup -- @preserve */
|
||||||
|
if ((releaseVersion as unknown) === 'dev') {
|
||||||
|
return `${releaseVersion}+${pkg['gitAbbrevHash']} (${pkg['buildDate']})`;
|
||||||
|
}
|
||||||
|
return releaseVersion;
|
||||||
|
};
|
||||||
|
|
||||||
export interface Diagnostics {
|
export interface Diagnostics {
|
||||||
card_version: string;
|
card_version: string;
|
||||||
browser: string;
|
browser: string;
|
||||||
@@ -51,7 +61,7 @@ export const getDiagnostics = async (
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
card_version: pkg.version,
|
card_version: getReleaseVersion(),
|
||||||
browser: navigator.userAgent,
|
browser: navigator.userAgent,
|
||||||
date: new Date(),
|
date: new Date(),
|
||||||
...(frigateVersionMap.size && {
|
...(frigateVersionMap.size && {
|
||||||
@@ -60,7 +70,7 @@ export const getDiagnostics = async (
|
|||||||
lang: getLanguage(),
|
lang: getLanguage(),
|
||||||
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||||
git: {
|
git: {
|
||||||
...(pkg['gitVersion'] && { build_version: pkg['gitVersion'] }),
|
...(pkg['gitAbbrevHash'] && { hash: pkg['gitAbbrevHash'] }),
|
||||||
...(pkg['buildDate'] && { build_date: pkg['buildDate'] }),
|
...(pkg['buildDate'] && { build_date: pkg['buildDate'] }),
|
||||||
...(pkg['gitDate'] && { commit_date: pkg['gitDate'] }),
|
...(pkg['gitDate'] && { commit_date: pkg['gitDate'] }),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import { HassConfig } from 'home-assistant-js-websocket';
|
import { HassConfig } from 'home-assistant-js-websocket';
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
import { getLanguage } from '../../src/localize/localize';
|
import { getLanguage } from '../../src/localize/localize';
|
||||||
import { getDiagnostics } from '../../src/utils/diagnostics.js';
|
import { getDiagnostics, getReleaseVersion } from '../../src/utils/diagnostics.js';
|
||||||
import { getAllDevices } from '../../src/utils/ha/device-registry.js';
|
import { getAllDevices } from '../../src/utils/ha/device-registry.js';
|
||||||
import { createHASS } from '../test-utils';
|
import { createHASS } from '../test-utils';
|
||||||
|
|
||||||
vi.mock('../../package.json', () => ({
|
vi.mock('../../package.json', () => ({
|
||||||
default: {
|
default: {
|
||||||
version: '5.2.0',
|
gitAbbrevHash: 'g4cf13b1',
|
||||||
gitVersion: '5.2.0-dev+g4cf13b1',
|
|
||||||
buildDate: 'Tue, 19 Sep 2023 04:59:27 GMT',
|
buildDate: 'Tue, 19 Sep 2023 04:59:27 GMT',
|
||||||
gitDate: 'Wed, 6 Sep 2023 21:27:28 -0700',
|
gitDate: 'Wed, 6 Sep 2023 21:27:28 -0700',
|
||||||
},
|
},
|
||||||
@@ -17,6 +16,12 @@ vi.mock('../../src/utils/ha');
|
|||||||
vi.mock('../../src/localize/localize.js');
|
vi.mock('../../src/localize/localize.js');
|
||||||
vi.mock('../../src/utils/ha/device-registry');
|
vi.mock('../../src/utils/ha/device-registry');
|
||||||
|
|
||||||
|
describe('getReleaseVersion', () => {
|
||||||
|
it('should get release version', () => {
|
||||||
|
expect(getReleaseVersion()).toBe('__FRIGATE_CARD_RELEASE_VERSION__');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// @vitest-environment jsdom
|
// @vitest-environment jsdom
|
||||||
describe('getDiagnostics', () => {
|
describe('getDiagnostics', () => {
|
||||||
const now = new Date('2023-10-01T21:53Z');
|
const now = new Date('2023-10-01T21:53Z');
|
||||||
@@ -54,7 +59,7 @@ describe('getDiagnostics', () => {
|
|||||||
}),
|
}),
|
||||||
).toEqual({
|
).toEqual({
|
||||||
browser: 'FrigateCardTest/1.0',
|
browser: 'FrigateCardTest/1.0',
|
||||||
card_version: '5.2.0',
|
card_version: '__FRIGATE_CARD_RELEASE_VERSION__',
|
||||||
config: {
|
config: {
|
||||||
cameras: [{ camera_entity: 'camera.office' }],
|
cameras: [{ camera_entity: 'camera.office' }],
|
||||||
},
|
},
|
||||||
@@ -64,8 +69,8 @@ describe('getDiagnostics', () => {
|
|||||||
},
|
},
|
||||||
git: {
|
git: {
|
||||||
build_date: 'Tue, 19 Sep 2023 04:59:27 GMT',
|
build_date: 'Tue, 19 Sep 2023 04:59:27 GMT',
|
||||||
build_version: '5.2.0-dev+g4cf13b1',
|
|
||||||
commit_date: 'Wed, 6 Sep 2023 21:27:28 -0700',
|
commit_date: 'Wed, 6 Sep 2023 21:27:28 -0700',
|
||||||
|
hash: 'g4cf13b1',
|
||||||
},
|
},
|
||||||
date: now,
|
date: now,
|
||||||
lang: 'en',
|
lang: 'en',
|
||||||
@@ -77,11 +82,11 @@ describe('getDiagnostics', () => {
|
|||||||
it('should fetch diagnostics without hass or config', async () => {
|
it('should fetch diagnostics without hass or config', async () => {
|
||||||
expect(await getDiagnostics()).toEqual({
|
expect(await getDiagnostics()).toEqual({
|
||||||
browser: 'FrigateCardTest/1.0',
|
browser: 'FrigateCardTest/1.0',
|
||||||
card_version: '5.2.0',
|
card_version: '__FRIGATE_CARD_RELEASE_VERSION__',
|
||||||
git: {
|
git: {
|
||||||
build_date: 'Tue, 19 Sep 2023 04:59:27 GMT',
|
build_date: 'Tue, 19 Sep 2023 04:59:27 GMT',
|
||||||
build_version: '5.2.0-dev+g4cf13b1',
|
|
||||||
commit_date: 'Wed, 6 Sep 2023 21:27:28 -0700',
|
commit_date: 'Wed, 6 Sep 2023 21:27:28 -0700',
|
||||||
|
hash: 'g4cf13b1',
|
||||||
},
|
},
|
||||||
date: now,
|
date: now,
|
||||||
lang: 'en',
|
lang: 'en',
|
||||||
@@ -103,11 +108,11 @@ describe('getDiagnostics', () => {
|
|||||||
|
|
||||||
expect(await getDiagnostics(hass)).toEqual({
|
expect(await getDiagnostics(hass)).toEqual({
|
||||||
browser: 'FrigateCardTest/1.0',
|
browser: 'FrigateCardTest/1.0',
|
||||||
card_version: '5.2.0',
|
card_version: '__FRIGATE_CARD_RELEASE_VERSION__',
|
||||||
git: {
|
git: {
|
||||||
build_date: 'Tue, 19 Sep 2023 04:59:27 GMT',
|
build_date: 'Tue, 19 Sep 2023 04:59:27 GMT',
|
||||||
build_version: '5.2.0-dev+g4cf13b1',
|
|
||||||
commit_date: 'Wed, 6 Sep 2023 21:27:28 -0700',
|
commit_date: 'Wed, 6 Sep 2023 21:27:28 -0700',
|
||||||
|
hash: 'g4cf13b1',
|
||||||
},
|
},
|
||||||
ha_version: '2023.9.0',
|
ha_version: '2023.9.0',
|
||||||
date: now,
|
date: now,
|
||||||
@@ -121,11 +126,11 @@ describe('getDiagnostics', () => {
|
|||||||
|
|
||||||
expect(await getDiagnostics(hass)).toEqual({
|
expect(await getDiagnostics(hass)).toEqual({
|
||||||
browser: 'FrigateCardTest/1.0',
|
browser: 'FrigateCardTest/1.0',
|
||||||
card_version: '5.2.0',
|
card_version: '__FRIGATE_CARD_RELEASE_VERSION__',
|
||||||
git: {
|
git: {
|
||||||
build_date: 'Tue, 19 Sep 2023 04:59:27 GMT',
|
build_date: 'Tue, 19 Sep 2023 04:59:27 GMT',
|
||||||
build_version: '5.2.0-dev+g4cf13b1',
|
|
||||||
commit_date: 'Wed, 6 Sep 2023 21:27:28 -0700',
|
commit_date: 'Wed, 6 Sep 2023 21:27:28 -0700',
|
||||||
|
hash: 'g4cf13b1',
|
||||||
},
|
},
|
||||||
ha_version: '2023.9.0',
|
ha_version: '2023.9.0',
|
||||||
date: now,
|
date: now,
|
||||||
|
|||||||
Reference in New Issue
Block a user