bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

changelog.py (3324B)


      1 import os
      2 from datetime import datetime, timezone
      3 
      4 sha = os.environ.get('BUILD_SHA', 'unknown')
      5 actor = os.environ.get('BUILD_ACTOR', 'unknown')
      6 ref = os.environ.get('BUILD_REF', 'unknown')
      7 timestamp = os.environ.get('BUILD_TIMESTAMP', '')
      8 
      9 try:
     10     dt = datetime.fromisoformat(timestamp).astimezone(timezone.utc)
     11     build_time = dt.strftime('%B %d, %Y at %H:%M UTC')
     12 except:
     13     build_time = timestamp
     14 
     15 # Parse git log
     16 commits = []
     17 try:
     18     with open('git_log.txt', 'r', encoding='utf-8') as f:
     19         for line in f:
     20             parts = line.strip().split('|')
     21             if len(parts) == 4:
     22                 c_sha, c_msg, c_author, c_time = parts
     23                 try:
     24                     c_dt = datetime.fromisoformat(c_time).astimezone(timezone.utc)
     25                     c_time_fmt = c_dt.strftime('%b %d, %Y %H:%M UTC')
     26                 except:
     27                     c_time_fmt = c_time
     28                 commits.append({
     29                     'sha': c_sha[:7],
     30                     'full_sha': c_sha,
     31                     'msg': c_msg,
     32                     'author': c_author,
     33                     'time': c_time_fmt,
     34                 })
     35 except FileNotFoundError:
     36     pass
     37 
     38 ICON = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:inline; margin-bottom:-2px; margin-right:6px;" class="lucide lucide-history"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l4 2"/></svg>'
     39 
     40 # Build commit history markdown
     41 commit_lines = []
     42 for c in commits:
     43     commit_url = f"https://github.com/notamitgamer/bsc/commit/{c['full_sha']}"
     44     commit_lines.append(f"- [`{c['sha']}`]({commit_url}) {c['msg']} — {c['author']}, {c['time']}")
     45 
     46 commit_section = '\n'.join(commit_lines) if commit_lines else '- No commit history available.'
     47 
     48 # VitePress docs/changelog.md
     49 docs_content = f"""---
     50 title: '{ICON} Changelog'
     51 description: 'Current build information and recent commit history.'
     52 ---
     53 
     54 # Build Info
     55 
     56 ::: tip Important
     57 Compare the Build ID (listed below) against the one in the [GitHub Changelog](https://github.com/notamitgamer/bsc/blob/main/CHANGELOG.md#latest-build) to verify that your browser is displaying the latest version.
     58 ::: 
     59 
     60 - **Build ID** — <span style="word-break: break-all;">`{sha}`</span>
     61 - **Triggered by** — [@{actor}](https://github.com/{actor})
     62 - **Branch** — `{ref}`
     63 - **Build time** — {build_time}
     64 
     65 ## Recent Commits
     66 
     67 {commit_section}
     68 """
     69 
     70 with open('docs/changelog.md', 'w', encoding='utf-8') as f:
     71     f.write(docs_content)
     72 
     73 # Root CHANGELOG.md for GitHub
     74 root_content = f"""# Changelog
     75 
     76 > Last build: {build_time}
     77 
     78 ## Latest Build
     79 
     80 - **Build ID** — `{sha}`
     81 - **Triggered by** — [@{actor}](https://github.com/{actor})
     82 - **Branch** — `{ref}`
     83 - **Build time** — {build_time}
     84 
     85 ## Recent Commits
     86 
     87 {commit_section}
     88 
     89 ---
     90 
     91 *This file is auto-generated on every deployment. For the live site, visit [code.amit.is-a.dev](https://code.amit.is-a.dev).*
     92 *Check [/changelog](https://code.amit.is-a.dev/changelog) on the site to verify your browser is showing the latest build.*
     93 """
     94 
     95 with open('CHANGELOG.md', 'w', encoding='utf-8') as f:
     96     f.write(root_content)
     97 
     98 print(f"Generated changelog with {len(commits)} commits.")
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror