1+ name : Publish oracle-vecdb Python SDK
2+
3+ permissions :
4+ contents : write
5+ actions : read
6+ id-token : write
7+
8+ # Publish job triggered manually via GitHub UI or API
9+ on :
10+ workflow_dispatch :
11+
12+ jobs :
13+ publish :
14+ environment : oracle-vecdb-release
15+ runs-on : ubuntu-latest
16+ steps :
17+ # Checkout the repository to access changelog
18+ - name : Checkout repository
19+ uses : actions/checkout@v4
20+
21+ # Download artifacts from latest run of Build oracle-vecdb Python SDK workflow
22+ - name : Download artifacts
23+ env :
24+ GH_TOKEN : ${{ github.token }}
25+ # Use gh to find and download the artifact
26+ run : |
27+ mkdir -p dist
28+ gh run download --name vecdb-python-sdk-artifacts --dir dist --repo ${{ github.repository }}
29+
30+ # Publish to PyPI via Trusted Publisher (OIDC)
31+ - name : Publish to PyPI
32+ uses : pypa/gh-action-pypi-publish@release/v1
33+ with :
34+ skip-existing : true
35+
36+ # Extract release notes from CHANGELOG.rst
37+ - name : Extract release notes
38+ id : release_notes
39+ shell : python
40+ run : |
41+ import re
42+ import sys
43+ import os
44+ from pathlib import Path
45+
46+ # 1. Prepare version string
47+ tag = "${{ github.ref_name }}"
48+ version = tag.lstrip("v")
49+
50+ # 2. Load file
51+ changelog_path = Path("CHANGELOG.rst")
52+ if not changelog_path.exists():
53+ print(f"::error::CHANGELOG.rst not found")
54+ sys.exit(1)
55+
56+ content = changelog_path.read_text()
57+
58+ # 3. Regex Breakdown:
59+ # ^ matches start of line (due to MULTILINE)
60+ # {version} \s+ - \s+ \d{{4}}... matches "1.0.0 - 2026-03-17"
61+ # \n-+ matches the underline of dashes/equals
62+ # (.*?) captures the body until the next version header or end of file (\Z)
63+ pattern = re.compile(
64+ rf"^{re.escape(version)}\s+-\s+\d{{4}}-\d{{2}}-\d{{2}}\n-+\n(.*?)(?=\n\d+\.\d+\.\d+\s+-\s+\d{{4}}-\d{{2}}-\d{{2}}\n-+|\Z)",
65+ re.DOTALL | re.MULTILINE
66+ )
67+
68+ match = pattern.search(content)
69+
70+ if match:
71+ notes = match.group(1).strip()
72+ else:
73+ print(f"::warning::No section found for version {version}")
74+ notes = "No release notes found in CHANGELOG.rst"
75+
76+ # 4. The "Heredoc" method for multi-line GitHub outputs
77+ # This writes to the unique file path provided by the runner environment
78+ output_file = os.environ['GITHUB_OUTPUT']
79+ with open(output_file, 'a') as f:
80+ f.write(f"RELEASE_NOTES<<EOF\n{notes}\nEOF\n")
81+
82+ # Create GitHub Release
83+ - name : Create GitHub Release
84+ env :
85+ GH_TOKEN : ${{ github.token }}
86+ run : |
87+ gh release create ${{ github.ref_name }} \
88+ --title "${{ github.ref_name }}" \
89+ --notes "${{ steps.release_notes.outputs.RELEASE_NOTES }}"
0 commit comments