This repository has been archived by the owner on Apr 3, 2024. It is now read-only.
3.1.0 #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This GitHub action workflow is meant to be copyable to any repo that have the same structure. | |
# - Your integration exist 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: | |
release: | |
types: [published] | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
deployments: write | |
steps: | |
- name: 📥 Checkout the repository | |
uses: actions/checkout@v4 | |
- name: 🔢 Get release version | |
id: version | |
uses: home-assistant/actions/helpers/version@master | |
- name: ℹ️ Get integration information | |
id: information | |
run: | | |
name=$(find custom_components/ -type d -maxdepth 1 | tail -n 1 | cut -d "/" -f2) | |
echo "::set-output name=name::$name" | |
min_ha_version=$(jq -r '.homeassistant' ${{ github.workspace }}/hacs.json) | |
echo "::set-output name=min_ha_version::$min_ha_version" | |
- 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: 🖊️ Set min required HA version | |
run: | | |
sed -i '/MIN_REQUIRED_HA_VERSION = /c\MIN_REQUIRED_HA_VERSION = "${{ steps.information.outputs.min_ha_version }}"' \ | |
"${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/const.py" | |
- name: 👀 Validate data | |
run: | | |
echo "Version found :${{ steps.version.outputs.version }}"; | |
if [[ '${{ steps.version.outputs.version }}' == '""' ]]; then | |
echo "Did not correctly identify version" | |
exit 1 | |
fi | |
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" | |
echo "$manifestversion" | |
exit 1 | |
fi | |
if ! grep -q 'MIN_REQUIRED_HA_VERSION = "${{ steps.information.outputs.min_ha_version }}"' ${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/const.py; then | |
echo "The MIN_REQUIRED_HA_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 MIN_REQUIRED_HA_VERSION | |
exit 1 | |
fi | |
- name: 📦 Create zip file for the integration | |
run: | | |
cd "${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}" | |
zip ${{ steps.information.outputs.name }}.zip -r ./ | |
- name: 📤 Upload the zip file as a release asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: "${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/${{ steps.information.outputs.name }}.zip" | |
asset_name: ${{ steps.information.outputs.name }}.zip | |
asset_content_type: application/zip |