test(docs): reorganize survey documentation tests #24
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Create GitHub Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| - "deploy-*" | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version number (e.g. v1.0.0)" | |
| required: true | |
| jobs: | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Determine Version | |
| id: get_version | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV | |
| else | |
| echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
| fi | |
| - name: Get Commits Since Last Tag | |
| id: get_commits | |
| run: | | |
| cat <<'PY_SCRIPT' > get_commits.py | |
| import subprocess, os, secrets | |
| try: | |
| prev = subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0', 'HEAD^'], stderr=subprocess.DEVNULL).decode('utf-8').strip() | |
| commits = subprocess.check_output(['git', 'log', prev + '..HEAD', '--pretty=format:- %s (%h)']).decode('utf-8') | |
| except: | |
| commits = subprocess.check_output(['git', 'log', '--pretty=format:- %s (%h)']).decode('utf-8') | |
| eof = secrets.token_hex(16) | |
| with open(os.environ['GITHUB_ENV'], 'a') as f: | |
| f.write(f'RAW_COMMITS<<{eof}\n{commits}\n{eof}\n') | |
| PY_SCRIPT | |
| python3 get_commits.py | |
| - name: Generate Release Notes with Gemini | |
| id: ai_summary | |
| env: | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| run: | | |
| cat <<'PY_SCRIPT' > generate_notes.py | |
| import os, json, http.client, secrets, sys | |
| api_key = os.environ.get('GEMINI_API_KEY') | |
| commits = os.environ.get('RAW_COMMITS', '') | |
| output_file = os.environ['GITHUB_OUTPUT'] | |
| eof = secrets.token_hex(16) | |
| if not api_key: | |
| with open(output_file, 'a') as f: | |
| f.write(f'release_notes<<{eof}\n{commits}\n{eof}\n') | |
| sys.exit(0) | |
| prompt = f"""You are a technical writer generating release notes. | |
| Below are the raw git commit messages since the last release. | |
| Please generate a well-formatted Markdown release note. | |
| Requirements: | |
| 1. Start with a brief, high-level summary of what is new. | |
| 2. Provide a categorized list of the changes (e.g., 📝 Documentation, 🚀 Features, 🐛 Fixes ) based on the commit messages. Documentation comes first. | |
| 3. Output ONLY the raw markdown content. Do not wrap it in markdown code blocks. | |
| Commits: | |
| {commits}""" | |
| try: | |
| conn = http.client.HTTPSConnection('generativelanguage.googleapis.com') | |
| payload = json.dumps({'contents': [{'parts': [{'text': prompt}]}]}) | |
| headers = {'Content-Type': 'application/json'} | |
| # Log attempt | |
| print(f"Calling Gemini API for model: gemini-3-flash-preview") | |
| conn.request('POST', f'/v1beta/models/gemini-3-flash-preview:generateContent?key={api_key}', payload, headers) | |
| res = conn.getresponse() | |
| data = res.read().decode('utf-8') | |
| result = json.loads(data) | |
| if 'candidates' in result and result['candidates']: | |
| notes = result['candidates'][0]['content']['parts'][0]['text'] | |
| if notes.startswith('```markdown'): | |
| notes = notes[11:] | |
| elif notes.startswith('```'): | |
| notes = notes[3:] | |
| if notes.endswith('```'): | |
| notes = notes[:-3] | |
| notes = notes.strip() | |
| with open(output_file, 'a') as f: | |
| f.write(f'release_notes<<{eof}\n{notes}\n{eof}\n') | |
| else: | |
| print("Full API Response:", json.dumps(result, indent=2)) | |
| raise KeyError("'candidates' key missing or empty in API response") | |
| except Exception as e: | |
| print(f'Error generating release notes: {e}') | |
| with open(output_file, 'a') as f: | |
| f.write(f'release_notes<<{eof}\n{commits}\n{eof}\n') | |
| PY_SCRIPT | |
| python3 generate_notes.py | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ env.VERSION }} | |
| name: Release ${{ env.VERSION }} | |
| body: ${{ steps.ai_summary.outputs.release_notes }} | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |