-
Notifications
You must be signed in to change notification settings - Fork 1
128 lines (111 loc) · 4.62 KB
/
sync-latest-version.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Sync latest Teslamate version
on:
schedule:
# run every day at midnight
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
compare-versions:
runs-on: ubuntu-latest
outputs:
latest-version: ${{ steps.parse-latest-version.outputs.release }}
latest-version-string: v${{ steps.parse-latest-version.outputs.release }}
current-version: ${{ steps.get-current-version.outputs.result }}
version-comparison: ${{ steps.compare-versions.outputs.comparison-result }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get latest Teslamate version
id: fetch-latest-version
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { data } = await github.rest.repos.getLatestRelease({
owner: 'teslamate-org',
repo: 'teslamate',
})
// remove the 'v' prefix since the image tag expects it without
return data.tag_name.replace("v", "")
- name: Parse latest Teslamate version
uses: madhead/semver-utils@latest
id: parse-latest-version
with:
version: ${{steps.fetch-latest-version.outputs.result}}
# fail on non-semantic versions
lenient: false
- name: Get current Teslamate version
id: get-current-version
uses: mikefarah/yq@master
with:
cmd: yq '.appVersion' charts/teslamate/Chart.yaml
- name: Compare versions
uses: madhead/semver-utils@latest
id: compare-versions
with:
version: ${{steps.parse-latest-version.outputs.release}}
compare-to: ${{steps.get-current-version.outputs.result}}
# fail on non-semantic versions
lenient: false
current-chart-version:
runs-on: ubuntu-latest
outputs:
# increment the patch version of the Chart
next-chart-version: ${{ steps.parse-chart-version.outputs.inc-patch }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get current chart version
uses: mikefarah/yq@master
id: get-chart-version
with:
cmd: yq '.version' charts/teslamate/Chart.yaml
- name: Parse current chart version
uses: madhead/semver-utils@latest
id: parse-chart-version
with:
version: ${{steps.get-chart-version.outputs.result}}
# fail on non-semantic versions
lenient: false
trigger-update:
if: ${{ needs.compare-versions.outputs.version-comparison == '>' }}
needs:
- compare-versions
- current-chart-version
permissions:
pull-requests: write
contents: write
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
# yq reformats the files, use sed instead. See https://github.com/mikefarah/yq/issues/465
- name: Update Chart.yaml with a new Chart version
run: |
sed -i 's/^version: .*/version: ${{needs.current-chart-version.outputs.next-chart-version}}/' 'charts/teslamate/Chart.yaml'
- name: Update Chart.yaml with latest Testlamate version
run: |
sed -i 's/^appVersion: .*/appVersion: ${{needs.compare-versions.outputs.latest-version-string}}/' 'charts/teslamate/Chart.yaml'
- name: Update values.yaml with latest Testlamate version
run: |
sed -i 's/^ tag: .*/ tag: ${{needs.compare-versions.outputs.latest-version}}/' 'charts/teslamate/values.yaml'
- name: Create pull request
uses: peter-evans/create-pull-request@v5
with:
commit-message: "feat: bump Teslamate to ${{needs.compare-versions.outputs.latest-version-string}}"
title: "feat: bump Teslamate to ${{needs.compare-versions.outputs.latest-version-string}}"
body: |
Latest version: https://github.com/teslamate-org/teslamate/releases/tag/${{needs.compare-versions.outputs.latest-version-string}}
Comparing [${{needs.compare-versions.outputs.current-version}}...${{needs.compare-versions.outputs.latest-version-string}}](https://github.com/teslamate-org/teslamate/compare/${{needs.compare-versions.outputs.current-version}}...${{needs.compare-versions.outputs.latest-version-string}})
branch: bump-teslamate-to-${{needs.compare-versions.outputs.latest-version-string}}
delete-branch: true