Skip to content

Commit e2f6eb1

Browse files
author
Daniel Mason
committed
feat: ci
1 parent b6c68fb commit e2f6eb1

File tree

5 files changed

+113
-2
lines changed

5 files changed

+113
-2
lines changed

.github/workflows/master.yaml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release HA component
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v1
13+
- name: Setting up Node
14+
uses: actions/setup-node@v1
15+
with:
16+
node-version: '12.x'
17+
- name: Preparing release
18+
run: |
19+
git config --local user.email "action@github.com"
20+
git config --local user.name "GitHub Action"
21+
git config --global --add safe.directory /github/workspace
22+
npm install
23+
npm run release
24+
echo ::set-env name=PACKAGE_VERSION::$(node -p -e "require('./package.json').version")
25+
env:
26+
CI: true
27+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
28+
29+
- name: Push to master
30+
uses: ad-m/github-push-action@master
31+
with:
32+
github_token: ${{ secrets.GITHUB_TOKEN }}
33+
- name: Merge back to develop
34+
uses: ad-m/github-push-action@master
35+
with:
36+
github_token: ${{ secrets.GITHUB_TOKEN }}
37+
branch: develop
38+
- name: Create Github Release
39+
id: create_release
40+
uses: actions/create-release@v1
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
43+
with:
44+
tag_name: v${{ env.PACKAGE_VERSION }}
45+
release_name: ${{ env.PACKAGE_VERSION }}
46+
draft: false
47+
prerelease: false

custom_components/processor/mqtt_code.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import homeassistant.util.uuid as uuid_util
99
from custom_components.processor.yaml_scheduler import TimeSchedule, Mapping
1010
from homeassistant.components import mqtt
11-
VERSION='3.0.1'
11+
VERSION = '3.0.1'
1212

1313
_LOGGER = logging.getLogger(__name__)
1414

custom_components/processor/yaml_scheduler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from . import DOMAIN
88
_LOGGER = logging.getLogger(__name__)
99
from homeassistant.util import dt
10-
VERSION='3.0.1'
10+
VERSION = '3.0.1'
1111

1212
class Scheduler:
1313

package.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "mqtt-mqtt-payload_processor",
3+
"version": "3.0.1",
4+
"description": "Custom Home Assistant component that converts MQTT message payloads to events and callback functions for consumption in automations. Can be used to assign schedule-based actions to remote controls or button wall panels.",
5+
"main": "index.js",
6+
"directories": {
7+
"test": "tests"
8+
},
9+
"scripts": {
10+
"release": "standard-version -a"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "https://github.com/danobot/mqtt_payload_processor"
15+
},
16+
"author": "Daniel Mason",
17+
"license": "GNU General Public License v3.0",
18+
"devDependencies": {
19+
"replace-in-file": "^3.4.3",
20+
"semantic-release": "^15.13.3",
21+
"standard-version": "^4.4.0",
22+
"update-json-file": "^1.1.1"
23+
},
24+
"standard-version": {
25+
"scripts": {
26+
"precommit": "node postbump.js; git add custom_components/processor/__init__.py; git add custom_components/processor/manifest.json; git add package.json; git add custom_components/processor/mqtt_code.py; git add custom_components/processor/yaml_scheduler.py"
27+
}
28+
}
29+
}

postbump.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
var v = require('./package.json').version
2+
const replace = require('replace-in-file');
3+
const updateJsonFile = require('update-json-file')
4+
5+
const regex = new RegExp('VERSION = .*', 'i');
6+
const options = {
7+
files: 'custom_components/entity_controller/__init__.py',
8+
from: regex,
9+
to: "VERSION = '"+v+"'",
10+
};
11+
12+
var changes = replace.sync(options)
13+
14+
15+
16+
const regex3 = new RegExp('Version: .*', 'i');
17+
18+
const header_version = {
19+
files: 'custom_components/entity_controller/__init__.py',
20+
from: regex3,
21+
to: "Version: v"+v,
22+
};
23+
changes = replace.sync(header_version)
24+
25+
26+
27+
const filePath = 'custom_components/entity_controller/manifest.json'
28+
29+
updateJsonFile(filePath, (data) => {
30+
data.version = v
31+
return data
32+
})
33+
34+
console.log("chore(release): " + v)
35+

0 commit comments

Comments
 (0)