Skip to content

Update CHANGELOG and version to 0.2.0 for image modality support #2

Update CHANGELOG and version to 0.2.0 for image modality support

Update CHANGELOG and version to 0.2.0 for image modality support #2

Workflow file for this run

name: Publish to PyPI
on:
push:
tags:
- 'v*'
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Extract changelog
id: changelog
env:
TAG_NAME: ${{ github.ref_name }}
run: |
python <<'PY'
import os
import pathlib
import re
tag = os.environ["TAG_NAME"]
version = tag[1:] if tag.startswith("v") else tag
changelog_path = pathlib.Path("CHANGELOG.md")
if changelog_path.exists():
changelog = changelog_path.read_text()
pattern = re.compile(rf"^## \[{re.escape(version)}\][^\n]*\n(.*?)(?=\n## \[|\Z)", re.DOTALL | re.MULTILINE)
section = pattern.search(changelog)
body = section.group(1).strip() if section else f"Release {version}"
else:
body = f"Release {version}"
if not body:
body = f"Release {version}"
output = pathlib.Path("release_notes.md")
output.write_text(body + "\n")
print(body)
PY
- name: Create Release
uses: softprops/action-gh-release@v2
with:
body_path: release_notes.md
generate_release_notes: false
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}