|
69 | 69 | # Clean up the local ZIP so it's not committed to git. |
70 | 70 | rm "Releases/$ZIP" |
71 | 71 |
|
| 72 | + - name: Inject GitHub release notes into appcast |
| 73 | + env: |
| 74 | + GH_TOKEN: ${{ github.token }} |
| 75 | + TAG: ${{ steps.info.outputs.tag }} |
| 76 | + BUILD: ${{ steps.info.outputs.build }} |
| 77 | + run: | |
| 78 | + # Fetch the release description (Markdown) written in the GitHub draft |
| 79 | + gh release view "$TAG" --json body --jq '.body' > /tmp/notes.md |
| 80 | +
|
| 81 | + # Convert Markdown → HTML (pandoc is pre-installed on GitHub macOS runners) |
| 82 | + pandoc -f gfm -t html /tmp/notes.md > /tmp/notes.html |
| 83 | +
|
| 84 | + # Inject the HTML as <description><![CDATA[…]]></description> |
| 85 | + # into the <item> that matches the current build number |
| 86 | + python3 - "$BUILD" 'Releases/VolumeControlCast.xml' /tmp/notes.html << 'PYEOF' |
| 87 | +import sys, re |
| 88 | + |
| 89 | +build, appcast_path, notes_path = sys.argv[1], sys.argv[2], sys.argv[3] |
| 90 | + |
| 91 | +with open(notes_path, encoding='utf-8') as f: |
| 92 | + notes_html = f.read().strip() |
| 93 | + |
| 94 | +with open(appcast_path, encoding='utf-8') as f: |
| 95 | + content = f.read() |
| 96 | + |
| 97 | +desc_tag = '<description><![CDATA[\n' + notes_html + '\n ]]></description>' |
| 98 | + |
| 99 | +item_re = re.compile( |
| 100 | + r'(<item>.*?<sparkle:version>' + re.escape(build) + r'</sparkle:version>.*?)(</item>)', |
| 101 | + re.DOTALL |
| 102 | +) |
| 103 | + |
| 104 | +def inject(m): |
| 105 | + inner = m.group(1) |
| 106 | + if '<description>' in inner: |
| 107 | + inner = re.sub(r'<description>.*?</description>', desc_tag, inner, flags=re.DOTALL) |
| 108 | + else: |
| 109 | + inner += '\n ' + desc_tag + '\n ' |
| 110 | + return inner + m.group(2) |
| 111 | + |
| 112 | +new_content = item_re.sub(inject, content) |
| 113 | + |
| 114 | +if new_content == content: |
| 115 | + print(f'WARNING: no <item> found for build {build}', file=sys.stderr) |
| 116 | + sys.exit(1) |
| 117 | + |
| 118 | +with open(appcast_path, 'w', encoding='utf-8') as f: |
| 119 | + f.write(new_content) |
| 120 | + |
| 121 | +print(f'Release notes injected for build {build}.') |
| 122 | +PYEOF |
| 123 | + |
72 | 124 | - name: Commit and push changes to main |
73 | 125 | env: |
74 | 126 | TAG: ${{ steps.info.outputs.tag }} |
|
0 commit comments