Skip to content

Commit

Permalink
Automate release process
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulSD committed Feb 17, 2025
1 parent 83f799f commit d7dbbb8
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 17 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/build.yml → .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Build"
name: Build

on:
push:
Expand All @@ -9,12 +9,20 @@ on:
- master

jobs:
build:
test_build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build
run: |
npm install
npm run build
- name: Archive distribution bundle
uses: actions/upload-artifact@v4
with:
path: dist/config-template-card.js
name: config-template-card-latest-build.js
overwrite: true
13 changes: 7 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
name: Release

on:
release:
types: [published]
push:
tags:
- '*'

jobs:
release:
name: Prepare release
name: Prepare Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build
run: |
cd /home/runner/work/config-template-card/config-template-card
npm install
npm run build
- name: Upload as release
- name: Upload as Release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: /home/runner/work/config-template-card/config-template-card/dist/config-template-card.js
file: dist/config-template-card.js
asset_name: config-template-card.js
tag: ${{ github.ref }}
prerelease: ${{ contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc') }}
overwrite: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/node_modules/
/yarn.lock
/.version.json
/.tsbuildinfo
/dist/
32 changes: 30 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "config-template-card",
"version": "1.3.1",
"description": "Lovelace config-template-card",
"keywords": [
"home-assistant",
Expand All @@ -20,6 +19,7 @@
},
"devDependencies": {
"rollup": "^4.24.3",
"rollup-plugin-version-injector": "1.3.3",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-eslint": "^9.0.5",
"typescript-eslint": "^8.24.0",
Expand All @@ -34,8 +34,10 @@
}
},
"scripts": {
"devl": "rollup --config --watch",
"build": "rollup --config",
"lint": "eslint"
"version": "echo \"{ \\\"version\\\": \\\"$(git describe --exact-match --tags 2>/dev/null || git rev-parse --short HEAD)\\\" }\" > .version.json",
"devl": "npm run version && rollup --config --watch",
"lint": "eslint",
"build": "npm run version && rollup --config",
"release": "rel() { git tag \"$1\" && git push origin tag \"$1\" ; } ; rel"
}
}
14 changes: 14 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import versionInjector from 'rollup-plugin-version-injector';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import eslint from '@rollup/plugin-eslint';
import typescript from '@rollup/plugin-typescript';
Expand All @@ -12,6 +13,19 @@ export default {
sourcemap: true,
},
plugins: [
versionInjector({
packageJson: './.version.json',
injectInComments: {
fileRegexp: /\.js$/,
tag: 'Version: {version} - {date}',
dateFormat: 'yyyy-mm-dd HH:MM:ss',
},
injectInTags: {
fileRegexp: /\.js$/,
tagId: 'VI',
},
logLevel: 'warn',
}),
nodeResolve(),
eslint({
throwOnError: false,
Expand Down
4 changes: 2 additions & 2 deletions src/config-template-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { customElement, property, state } from 'lit/decorators.js';
import { computeCardSize, HomeAssistant, LovelaceCard } from 'custom-card-helpers';

import { ConfigTemplateConfig, ConfigTemplateVars } from './types';
import { CARD_VERSION } from './const';
import { VERSION } from './version';
import { isString } from './util';

console.info(
`%c CONFIG-TEMPLATE-CARD \n%c Version ${CARD_VERSION} `,
`%c CONFIG-TEMPLATE-CARD \n%c Version ${VERSION} `,
'color: orange; font-weight: bold; background: black',
'color: white; font-weight: bold; background: dimgray',
);
Expand Down
1 change: 0 additions & 1 deletion src/const.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const VERSION = '[VI]{version}[/VI]';

0 comments on commit d7dbbb8

Please sign in to comment.