Skip to content

Commit c0893b8

Browse files
committed
feat: use GitHub actions to set version number on release
1 parent df87a7a commit c0893b8

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

.github/workflows/release.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
release_zip_file:
9+
name: Prepare release asset
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out repository
13+
uses: actions/checkout@v1
14+
15+
- name: Get Version
16+
id: get_version
17+
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
18+
19+
- name: "Set version number"
20+
run: |
21+
sed -i '/VERSION = /c\VERSION = "${{ steps.get_version.outputs.VERSION }}"' ${{ github.workspace }}/custom_components/crunch_o_meter/const.py
22+
sed -i '/version/c\ \"version\": \"${{ steps.get_version.outputs.VERSION }}\"' ${{ github.workspace }}/custom_components/crunch_o_meter/manifest.json
23+
24+
- name: Zip
25+
run: |
26+
cd ${{ github.workspace }}/custom_components/crunch_o_meter
27+
zip crunch_o_meter.zip -r ./
28+
29+
- name: Upload Zip to release
30+
uses: svenstaro/upload-release-action@v1-release
31+
with:
32+
repo_token: ${{ secrets.GITHUB_TOKEN }}
33+
file: ${{ github.workspace }}/custom_components/crunch_o_meter/crunch_o_meter.zip
34+
asset_name: crunch_o_meter.zip
35+
tag: ${{ github.ref }}
36+
overwrite: true

custom_components/crunch_o_meter/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
DOMAIN = "crunch_o_meter"
2-
VERSION = "1.0.3"
2+
VERSION = "0.0.0-dev" # Now updated by release workflow
33
ISSUE_URL = "https://github.com/GuyLewin/home-assistant-crunch-o-meter"
44
PLATFORM = "sensor"
55

custom_components/crunch_o_meter/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"@guylewin"
1010
],
1111
"requirements": [],
12-
"version": "1.0.3"
12+
"version": "0.0.0-dev"
1313
}

hacs.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
"name": "Crunch-O-Meter",
33
"domains": ["sensor"],
44
"iot_class": "Cloud Polling",
5-
"render_readme": true
5+
"render_readme": true,
6+
"zip_release": true,
7+
"filename": "crunch_o_meter.zip"
68
}

0 commit comments

Comments
 (0)