release.yml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. name: Release
  2. on:
  3. push:
  4. tags:
  5. - "v*.*.*"
  6. permissions:
  7. contents: write
  8. jobs:
  9. release:
  10. name: Build & publish GitHub release
  11. runs-on: ubuntu-latest
  12. steps:
  13. - name: Checkout
  14. uses: actions/checkout@v4
  15. - name: Read version from manifest
  16. id: version
  17. run: |
  18. VERSION=$(python3 -c "import json; print(json.load(open('custom_components/solar_of_things/manifest.json'))['version'])")
  19. echo "version=$VERSION" >> "$GITHUB_OUTPUT"
  20. echo "Building release for version $VERSION"
  21. - name: Build HACS release ZIP
  22. run: |
  23. # ZIP contains the full custom_components tree so HACS / manual users
  24. # can extract directly into their HA config directory.
  25. zip -r solar-of-things-ha.zip custom_components/solar_of_things/ \
  26. -x "*.pyc" -x "__pycache__/*"
  27. echo "ZIP contents:"
  28. unzip -l solar-of-things-ha.zip
  29. - name: Extract changelog section for this tag
  30. id: changelog
  31. run: |
  32. TAG="${GITHUB_REF_NAME}"
  33. VER="${TAG#v}"
  34. # Grab lines between current version header and next version header
  35. NOTES=$(awk "/^## \[${VER}\]/{flag=1; next} /^## \[/{flag=0} flag" CHANGELOG.md)
  36. if [ -z "$NOTES" ]; then
  37. NOTES=$(head -60 CHANGELOG.md)
  38. fi
  39. printf '%s' "$NOTES" > release_notes.txt
  40. echo "notes_file=release_notes.txt" >> "$GITHUB_OUTPUT"
  41. - name: Create GitHub Release & upload asset
  42. uses: softprops/action-gh-release@v2
  43. with:
  44. tag_name: ${{ github.ref_name }}
  45. name: "${{ github.ref_name }} — Solar of Things HA Integration"
  46. body_path: release_notes.txt
  47. draft: false
  48. files: solar-of-things-ha.zip