@@ -6,59 +6,49 @@ def main():
66 script_dir = os .path .dirname (os .path .abspath (__file__ ))
77 project_root = os .path .dirname (os .path .dirname (script_dir ))
88
9- # 1. Parse app/build.gradle.kts
10- gradle_path = os .path .join (project_root , 'app' , 'build.gradle.kts' )
11- with open (gradle_path , 'r' , encoding = 'utf-8' ) as f :
12- gradle_content = f .read ()
9+ # 1. Try to get version from tag name (if running in GitHub Actions)
10+ ref_name = os .environ .get ('GITHUB_REF_NAME' )
11+ version_name = None
12+ if ref_name and ref_name .startswith ('v' ):
13+ version_name = ref_name [1 :]
14+ print (f"Detected version name from GITHUB_REF_NAME: { version_name } " )
1315
14- version_name_match = re .search (r'versionName\s*=\s*"([^"]+)"' , gradle_content )
15- version_code_match = re .search (r'versionCode\s*=\s*(\d+)' , gradle_content )
16-
17- if not version_name_match or not version_code_match :
18- print ("Error: Could not parse versionName or versionCode from build.gradle.kts" )
19- return
20-
21- version_name = version_name_match .group (1 )
22- version_code = version_code_match .group (1 )
23-
24- # 2. Read changelog
25- changelog_path = os .path .join (project_root , 'fastlane' , 'metadata' , 'android' , 'en-US' , 'changelogs' , f'{ version_code } .txt' )
26- if not os .path .exists (changelog_path ):
27- print (f"Error: Changelog file { changelog_path } not found" )
16+ # 2. Fall back to build.gradle.kts if not running in action or tag not matching
17+ if not version_name :
18+ gradle_path = os .path .join (project_root , 'app' , 'build.gradle.kts' )
19+ if os .path .exists (gradle_path ):
20+ with open (gradle_path , 'r' , encoding = 'utf-8' ) as f :
21+ gradle_content = f .read ()
22+ version_name_match = re .search (r'versionName\s*=\s*"([^"]+)"' , gradle_content )
23+ if version_name_match :
24+ version_name = version_name_match .group (1 )
25+ print (f"Parsed version name from build.gradle.kts: { version_name } " )
26+
27+ if not version_name :
28+ print ("Error: Could not determine version name" )
2829 return
29-
30- with open (changelog_path , 'r' , encoding = 'utf-8' ) as f :
31- changelog = f .read ().strip ()
32-
33- # 3. Create formatted release notes content
34- release_notes_content = f"""### 💖 Support Our Work
35- * We are committed to making our apps as powerful and polished as possible. As an entirely community-funded project, we rely on your support to keep going, please consider becoming a [sponsor](https://github.com/sponsors/LeanBitLab). A huge thank you to all our current supporters!
3630
37- ## 🚀 What's New
38- { changelog }
31+ # 3. Locate the existing release notes file
32+ releasenote_dir = os .path .join (project_root , 'docs' , 'releasenote' )
33+ source_path = os .path .join (releasenote_dir , f'release_notes_v{ version_name } .md' )
34+ temp_path = os .path .join (releasenote_dir , 'release_notes_temp.md' )
3935
40- ## 📦 Downloads (Choose Your Flavor)
36+ if not os .path .exists (source_path ):
37+ print (f"Error: Release note file { source_path } not found" )
38+ # Write a fallback file so the build/release step doesn't fail
39+ with open (temp_path , 'w' , encoding = 'utf-8' ) as f :
40+ f .write (f"Release notes for version { version_name } " )
41+ return
4142
42- | File | Description | Permissions |
43- | :--- | :--- | :--- |
44- | **`1-LeanType_{ version_name } -standardfull-release.apk`** | **Recommended**. Cloud AI | Internet |
45- | **`2-LeanType_{ version_name } -standard-release.apk`** | **Fdroid Build**. Standard + No Handwrite | Internet |
46- | **`3-LeanType_{ version_name } -offline-release.apk`** | **Privacy Focused**. No Internet. Offline AI Only. | No Internet |
47- | **`4-LeanType_{ version_name } -offlinelite-release.apk`** | **Minimalist**. Pure FOSS. No AI code. | No Internet |
48- """
43+ # 4. Copy to release_notes_temp.md
44+ with open (source_path , 'r' , encoding = 'utf-8' ) as sf :
45+ content = sf .read ()
4946
50- # 4. Write to docs/releasenote/release_notes_v{version_name}.md
51- out_dir = os .path .join (project_root , 'docs' , 'releasenote' )
52- os .makedirs (out_dir , exist_ok = True )
53- out_path = os .path .join (out_dir , f'release_notes_v{ version_name } .md' )
54- with open (out_path , 'w' , encoding = 'utf-8' ) as f :
55- f .write (release_notes_content )
56- temp_path = os .path .join (out_dir , 'release_notes_temp.md' )
57- with open (temp_path , 'w' , encoding = 'utf-8' ) as f :
58- f .write (release_notes_content )
59-
60- print (f"Successfully generated { out_path } and { temp_path } " )
47+ with open (temp_path , 'w' , encoding = 'utf-8' ) as df :
48+ df .write (content )
49+
50+ print (f"Successfully copied { source_path } to { temp_path } " )
6151
6252if __name__ == '__main__' :
63- # ponytail: minimal release notes generator using standard library
53+ # ponytail: copy pre-generated release notes file to temp.md
6454 main ()
0 commit comments