From 6f8ab876033976fc6687ddc25a6941acbdc599c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Wed, 18 Dec 2024 17:33:00 +0100 Subject: [PATCH] Add setversion script (#98) --- .github/workflows/release.yaml | 19 ------------------- custom_components/healthchecksio/const.py | 1 - scripts/setversion | 10 ++++++++++ 3 files changed, 10 insertions(+), 20 deletions(-) create mode 100755 scripts/setversion diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a6bbe4f..5451ce5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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: @@ -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" diff --git a/custom_components/healthchecksio/const.py b/custom_components/healthchecksio/const.py index 7f8e2e8..62041c4 100644 --- a/custom_components/healthchecksio/const.py +++ b/custom_components/healthchecksio/const.py @@ -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, diff --git a/scripts/setversion b/scripts/setversion new file mode 100755 index 0000000..506c3fe --- /dev/null +++ b/scripts/setversion @@ -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