-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (68 loc) · 2.79 KB
/
ha-updater.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Update Home Assistant appVersion
on:
workflow_dispatch:
schedule:
- cron: '0 8 * * *'
jobs:
update-version:
runs-on: ubuntu-24.04
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- uses: pre-commit/action@v3.0.1
- name: Install semver CLI
run: |
wget -O /usr/local/bin/semver \
https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver
chmod +x /usr/local/bin/semver
semver --version
- name: Get stable digest
id: get-stable-digest
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 "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 "$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 "stable_tag=$tag" >> "$GITHUB_ENV"
- name: Update Chart.yaml
run: |
src_file="charts/home-assistant/Chart.yaml"
app_version=$(yq '.appVersion' "$src_file")
chart_version=$(yq '.version' "$src_file")
if [ "$app_version" == "$stable_tag" ]; then
echo "App version: ${app_version} is already up-to-date. No changes needed."
exit 0
fi
if [[ "$stable_tag" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
if [ $(semver get major "$stable_tag") -ne $(semver get major "$app_version") ]; then
new_version=$(semver bump minor "$chart_version")
else
new_version=$(semver bump patch "$chart_version")
fi
else
new_version=$(semver bump patch "$chart_version")
fi
echo "Updating Chart.yaml with appVersion: ${stable_tag} chartVersion: ${new_version}"
yq eval ".appVersion = \"$stable_tag\" | .version = \"$new_version\"" -i "$src_file"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
if: github.ref == 'refs/heads/main'
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: 'bump(home-assistant): update app version'
body: 'Automatically updated Home Assistant app versions'
commit-message: 'bump(home-assistant): appVersion ${{ env.stable_tag }}'
branch: bump/home-assistant
# branch-suffix: timestamp
sign-commits: true