release.yml 1.6 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@v6
  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 -r solar-of-things-ha.zip custom_components/solar_of_things/ \
  24. -x "*.pyc" -x "__pycache__/*"
  25. echo "ZIP size: $(du -sh solar-of-things-ha.zip | cut -f1)"
  26. echo "ZIP contents:"
  27. unzip -l solar-of-things-ha.zip
  28. - name: Extract changelog section for this tag
  29. id: changelog
  30. run: |
  31. TAG="${GITHUB_REF_NAME}"
  32. VER="${TAG#v}"
  33. NOTES=$(awk "/^## \[${VER}\]/{flag=1; next} /^## \[/{flag=0} flag" CHANGELOG.md)
  34. if [ -z "$NOTES" ]; then
  35. NOTES=$(head -60 CHANGELOG.md)
  36. fi
  37. printf '%s' "$NOTES" > release_notes.txt
  38. - name: Create GitHub Release & upload asset
  39. uses: softprops/action-gh-release@v3
  40. with:
  41. tag_name: ${{ github.ref_name }}
  42. name: "${{ github.ref_name }} — Solar of Things HA Integration"
  43. body_path: release_notes.txt
  44. draft: false
  45. prerelease: false
  46. files: solar-of-things-ha.zip
  47. env:
  48. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}