diff --git a/.github/workflows/ha-updater.yaml b/.github/workflows/ha-updater.yaml index 9fb2317..11151a9 100644 --- a/.github/workflows/ha-updater.yaml +++ b/.github/workflows/ha-updater.yaml @@ -18,23 +18,28 @@ jobs: run: | stable_digest=$(curl -s "https://registry.hub.docker.com/v2/repositories/homeassistant/home-assistant/tags/stable" | jq -r .digest) echo "Stable digest: $stable_digest" - echo "::set-output name=stable_digest::$stable_digest" + echo "stable_digest=$stable_digest" >> "$GITHUB_ENV" - name: Get app versions id: get-image-tag run: | tag=$(curl -s "https://registry.hub.docker.com/v2/repositories/homeassistant/home-assistant/tags?page_size=100" | \ - jq -r --arg stable_digest "${{ steps.get-stable-digest.outputs.stable_digest }}" '.results | map(select(.digest == $stable_digest) | .name) | map(select(test("^[0-9]{4}\\.[0-9]{1,2}\\.[0-9]+$"))) | .[]') + jq -r --arg stable_digest "$stable_digest" '.results | map(select(.digest == $stable_digest) | .name) | map(select(test("^[0-9]{4}\\.[0-9]{1,2}\\.[0-9]+$"))) | .[]') echo "App stable tag: $tag" - echo "::set-output name=tag::$tag" + echo "stable_tag=$tag" >> "$GITHUB_ENV" - name: Update Chart.yaml run: | src_file="charts/home-assistant/Chart.yaml" - app_version="$(yq '.appVersion' $src_file)" - image_tag="${{ steps.get-image-tag.outputs.tag }}" - echo "Updating Chart.yaml with appVersion: $image_tag" - diff -B <(yq "$src_file") <(yq eval ".appVersion = \"$image_tag\"" "$src_file") | patch "$src_file" + app_version=$(yq '.appVersion' $src_file) + chart_version=$(yq '.version' "$src_file") + new_version=$(echo $chart | awk -F. '{$NF = $NF + 1;} 1' OFS=.) + + if [ "$app_version" != "$stable_tag" ]; then + echo "Updating Chart.yaml with appVersion: $stable_tag chartVersion: $new_version" + diff -B <(yq "$src_file") <(yq eval ".appVersion = \"$stable_tag\"" "$src_file") | patch "$src_file" + diff -B <(yq "$src_file") <(yq eval ".version = \"$new_version\"" "$src_file") | patch "$src_file" + fi - name: Create Pull Request uses: peter-evans/create-pull-request@v5 @@ -42,5 +47,5 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} title: 'bump(home-assistant): update app version' body: 'Automatically updated Home Assistant app versions' - commit-message: 'bump(home-assistant): appVersion "${{ steps.get-image-tag.outputs.tag }}' + commit-message: 'bump(home-assistant): appVersion $stable_tag' branch-suffix: timestamp