From c3c8ec45b03e9fbed26ca05ce283af4942d2c79a Mon Sep 17 00:00:00 2001 From: Dimitri Koshkin Date: Mon, 1 Jan 2024 20:08:43 -0800 Subject: [PATCH] ci: sync Teslamate versions --- .../{release-chart.yml => release-chart.yaml} | 0 .github/workflows/sync-latest-version.yaml | 132 ++++++++++++++++++ charts/teslamate/Chart.yaml | 2 +- 3 files changed, 133 insertions(+), 1 deletion(-) rename .github/workflows/{release-chart.yml => release-chart.yaml} (100%) create mode 100644 .github/workflows/sync-latest-version.yaml diff --git a/.github/workflows/release-chart.yml b/.github/workflows/release-chart.yaml similarity index 100% rename from .github/workflows/release-chart.yml rename to .github/workflows/release-chart.yaml diff --git a/.github/workflows/sync-latest-version.yaml b/.github/workflows/sync-latest-version.yaml new file mode 100644 index 0000000..172196f --- /dev/null +++ b/.github/workflows/sync-latest-version.yaml @@ -0,0 +1,132 @@ +name: Sync latest Teslamate version + +on: + push: + branches: + - feat-sync-app + # schedule: + # - cron: "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 current version by 1 patch + 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, see https://github.com/mikefarah/yq/issues/465 + # use sed instead + + - 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-string}}/' '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 + base: feat-sync-app diff --git a/charts/teslamate/Chart.yaml b/charts/teslamate/Chart.yaml index 2dfb0c9..5b4133f 100644 --- a/charts/teslamate/Chart.yaml +++ b/charts/teslamate/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 -appVersion: v1.28.2 +appVersion: v1.28.1 description: A self-hosted data logger for your Tesla 🚘 name: teslamate version: 0.3.0