Skip to content

Commit

Permalink
Cleanup zip file on error (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Dec 8, 2023
1 parent e7607b9 commit e877bba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ jobs:
if [ ! -f "${{ matrix.target.path }}/custom_components/hacs/manifest.json" ]; then
exit 1
fi
if [ -f "${{ matrix.target.path }}/custom_components/hacs.zip" ]; then
exit 1
fi
version:
Expand Down Expand Up @@ -117,4 +120,9 @@ jobs:
run: |
if [ -f "./custom_components/hacs/manifest.json" ]; then
exit 1
fi
- name: 👀 Verify cleanup
run: |
if [ -f "${{ matrix.target.path }}/custom_components/hacs.zip" ]; then
exit 1
fi
7 changes: 6 additions & 1 deletion get
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ if [ -n "$haPath" ]; then
cd "$haPath/custom_components" || error "Could not change path to $haPath/custom_components"

info "Downloading HACS"
rm -f "$haPath/custom_components/hacs.zip"
wget "https://github.com/hacs/integration/releases/latest/download/hacs.zip"

if [ -d "$haPath/custom_components/hacs" ]; then
Expand All @@ -87,6 +88,7 @@ if [ -n "$haPath" ]; then

if [ "${currentYear}" -lt "${targetYear}" ]; then
rm -R "$haPath/custom_components/hacs"
rm -f "$haPath/custom_components/hacs.zip"
error "Version ${currentVersion} is not new enough, needs at least ${targetVersion}"
fi

Expand All @@ -96,11 +98,13 @@ if [ -n "$haPath" ]; then

if [ "${currentYear}.${currentMonth}" == "2023.12" ]; then
rm -R "$haPath/custom_components/hacs"
rm -f "$haPath/custom_components/hacs.zip"
error "HACS will currently not work on ${currentYear}.${currentMonth} versions of Home Assistant, latest known working version is 2023.11.3"
fi

if [ "${currentMonth}" -lt "${targetMonth}" ]; then
rm -R "$haPath/custom_components/hacs"
rm -f "$haPath/custom_components/hacs.zip"
error "Version ${currentVersion} is not new enough, needs at least ${targetVersion}"
fi

Expand All @@ -110,14 +114,15 @@ if [ -n "$haPath" ]; then

if [ "${currentPatch}" -lt "${targetPatch}" ]; then
rm -R "$haPath/custom_components/hacs"
rm -f "$haPath/custom_components/hacs.zip"
error "Version ${currentVersion} is not new enough, needs at least ${targetVersion}"
fi
fi
fi

echo
info "Removing HACS zip file..."
rm "$haPath/custom_components/hacs.zip"
rm -f "$haPath/custom_components/hacs.zip"
info "Installation complete."
echo
info "Remember to restart Home Assistant before you configure it"
Expand Down

0 comments on commit e877bba

Please sign in to comment.