Skip to content

Commit

Permalink
Add setversion script (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Dec 18, 2024
1 parent 4c84326 commit 6f8ab87
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# This GitHub action workflow is ment to be copyable to any repo that have the same structure.
# - Your integration exsist under custom_components/{INTEGRATION_NAME}/[integration files]
# - You are using GitHub releases to publish new versions
# - You have a INTEGRATION_VERSION constant in custom_components/{INTEGRATION_NAME}/const.py

name: Release Workflow

on:
Expand All @@ -27,22 +22,8 @@ jobs:
name=$(find custom_components/ -type d -maxdepth 1 | tail -n 1 | cut -d "/" -f2)
echo "::set-output name=name::$name"
- name: 🖊️ Set version number
run: |
sed -i '/INTEGRATION_VERSION = /c\INTEGRATION_VERSION = "${{ steps.version.outputs.version }}"' \
"${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/const.py"
jq '.version = "${{ steps.version.outputs.version }}"' \
"${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/manifest.json" > tmp \
&& mv -f tmp "${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/manifest.json"
- name: 👀 Validate data
run: |
if ! grep -q 'INTEGRATION_VERSION = "${{ steps.version.outputs.version }}"' ${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/const.py; then
echo "The version in custom_components/${{ steps.information.outputs.name }}/const.py was not correct"
cat ${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/const.py | grep INTEGRATION_VERSION
exit 1
fi
manifestversion=$(jq -r '.version' ${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/manifest.json)
if [ "$manifestversion" != "${{ steps.version.outputs.version }}" ]; then
echo "The version in custom_components/${{ steps.information.outputs.name }}/manifest.json was not correct"
Expand Down
1 change: 0 additions & 1 deletion custom_components/healthchecksio/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from homeassistant.const import Platform

DOMAIN = "healthchecksio"
INTEGRATION_VERSION = "main"
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=300)
PLATFORMS = [
Platform.BINARY_SENSOR,
Expand Down
10 changes: 10 additions & 0 deletions scripts/setversion
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

NEW_VERSION=$1

jq --arg version "$NEW_VERSION" '.version = $version' ./custom_components/healthchecksio/manifest.json > _manifest_tmp.json
mv _manifest_tmp.json ./custom_components/healthchecksio/manifest.json

0 comments on commit 6f8ab87

Please sign in to comment.