release.yml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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('manifest.json'))['version'])")
  19. echo "version=$VERSION" >> "$GITHUB_OUTPUT"
  20. - name: Build HACS release ZIP
  21. run: |
  22. STAGE=release_stage
  23. mkdir -p "$STAGE/custom_components/solar_of_things/translations"
  24. # Integration source files
  25. for f in __init__.py api.py config_flow.py const.py \
  26. sensor.py number.py select.py switch.py \
  27. manifest.json strings.json; do
  28. cp "$f" "$STAGE/custom_components/solar_of_things/$f"
  29. done
  30. cp translations/en.json "$STAGE/custom_components/solar_of_things/translations/en.json"
  31. # Root-level metadata / docs
  32. for f in hacs.json README.md LICENSE CHANGELOG.md \
  33. INSTALLATION.md QUICKSTART.md \
  34. CONTROL_FEATURES.md EXAMPLES.md; do
  35. cp "$f" "$STAGE/$f"
  36. done
  37. cd "$STAGE"
  38. zip -r "../solar-of-things-ha.zip" . > /dev/null
  39. cd ..
  40. echo "zip built:"
  41. ls -lh solar-of-things-ha.zip
  42. - name: Extract changelog section for this tag
  43. id: changelog
  44. run: |
  45. TAG="${GITHUB_REF_NAME}"
  46. # Grab text between the current version header and the next one
  47. NOTES=$(awk "/^## \[${TAG#v}\]/{flag=1; next} /^## \[/{flag=0} flag" CHANGELOG.md)
  48. # Fallback: use first 50 lines
  49. if [ -z "$NOTES" ]; then
  50. NOTES=$(head -50 CHANGELOG.md)
  51. fi
  52. # Write to file (handles multi-line output)
  53. printf '%s' "$NOTES" > release_notes.txt
  54. echo "notes_file=release_notes.txt" >> "$GITHUB_OUTPUT"
  55. - name: Create GitHub Release & upload asset
  56. uses: softprops/action-gh-release@v2
  57. with:
  58. tag_name: ${{ github.ref_name }}
  59. name: "${{ github.ref_name }} — Solar of Things (Siseli) HA Integration"
  60. body_path: release_notes.txt
  61. draft: true
  62. files: solar-of-things-ha.zip