From 0afa2b90b0b208becb9de7dd52c7296337dfc555 Mon Sep 17 00:00:00 2001 From: Timo Reimann Date: Fri, 27 Mar 2026 14:34:14 +0100 Subject: [PATCH] chore: create reusable CHANGELOG workflow and re-use it for nightlies (#28599) --- .github/workflows/hassio-changelog.yml | 46 +++++++++++++------ .github/workflows/nightly.yml | 10 ++++ .../workflows/release-hassio-changelog.yml | 14 ++++++ 3 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/release-hassio-changelog.yml diff --git a/.github/workflows/hassio-changelog.yml b/.github/workflows/hassio-changelog.yml index d0bca0f1c..8886ed181 100644 --- a/.github/workflows/hassio-changelog.yml +++ b/.github/workflows/hassio-changelog.yml @@ -1,19 +1,24 @@ -name: Hassio Addon Changelog - -permissions: - contents: read +name: Hassio Addon Changelog Update (Reusable) on: - release: - types: [edited, released] - + workflow_call: + inputs: + addon_path: + description: "Path inside hassio-addon repo (evcc or evcc-nightly)" + required: true + type: string + include_unreleased: + description: "Prepend commits on master after the latest release" + required: false + type: boolean + default: false jobs: update-changelog: name: Update Hassio Changelog runs-on: depot-ubuntu-24.04-arm permissions: - contents: read # push to hassio-addon is authenticated via HASSIO_DEPLOY_TOKEN PAT + contents: read # gh api calls to evcc repo; push to hassio-addon uses HASSIO_DEPLOY_TOKEN PAT steps: - name: Checkout hassio-addon @@ -33,12 +38,27 @@ jobs: | sort_by(.published_at) | reverse | .[] - | "## [\(.tag_name)] - \(.published_at | split("T")[0])\n\n\((.body // "No release notes.") + | "## [\(.tag_name)] - \(.published_at | split("T")[0])\n\n\((.body // "No release notes.") | gsub("(?m)^\\* [0-9a-f]{40} "; "* "))\n" ' -r > /tmp/changelog_entries.md - printf '%s\n\n' 'Full release details: https://github.com/evcc-io/evcc/releases' > ./hassio/evcc/CHANGELOG.md - cat /tmp/changelog_entries.md >> ./hassio/evcc/CHANGELOG.md + printf '%s\n\n' 'Full release details: https://github.com/evcc-io/evcc/releases' > ./hassio/${{ inputs.addon_path }}/CHANGELOG.md + + if [ "${{ inputs.include_unreleased }}" = "true" ]; then + DEFAULT_BRANCH=$(gh repo view evcc-io/evcc --json defaultBranchRef --jq .defaultBranchRef.name) + LATEST_TAG=$(gh api repos/evcc-io/evcc/releases/latest --jq .tag_name) + COMMITS=$(gh api repos/evcc-io/evcc/compare/${LATEST_TAG}...${DEFAULT_BRANCH} \ + --jq '.commits | reverse[] | .commit.message | split("\n")[0]') + if [ -n "$COMMITS" ]; then + printf '## [unreleased]\n\n' + echo "$COMMITS" | while IFS= read -r line; do + printf '* %s\n' "$line" + done + printf '\n' + fi >> ./hassio/${{ inputs.addon_path }}/CHANGELOG.md + fi + + cat /tmp/changelog_entries.md >> ./hassio/${{ inputs.addon_path }}/CHANGELOG.md - name: Push if changed run: | @@ -49,7 +69,7 @@ jobs: fi git config user.name github-actions git config user.email github-actions@github.com - git add evcc/CHANGELOG.md - git commit -m "Update evcc changelog" + git add ${{ inputs.addon_path }}/CHANGELOG.md + git commit -m "Update ${{ inputs.addon_path }} changelog" git pull --rebase git push diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index b844173bd..7f406a200 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -133,6 +133,16 @@ jobs: git commit -am "Mirror evcc nightly release" git push + hassio-changelog: + name: Update Hassio Nightly Changelog + needs: + - hassio + uses: ./.github/workflows/hassio-changelog.yml + with: + addon_path: evcc-nightly + include_unreleased: true + secrets: inherit + apt: name: Publish APT nightly needs: diff --git a/.github/workflows/release-hassio-changelog.yml b/.github/workflows/release-hassio-changelog.yml new file mode 100644 index 000000000..da19ab563 --- /dev/null +++ b/.github/workflows/release-hassio-changelog.yml @@ -0,0 +1,14 @@ +name: Release - Create Hassio Addon Changelog + +on: + release: + types: [edited, released] + +jobs: + update-changelog: + name: Update Hassio Changelog + uses: ./.github/workflows/hassio-changelog.yml + with: + addon_path: evcc + include_unreleased: false + secrets: inherit