Skip to content

Commit 6eb6ed0

Browse files
committed
package release
1 parent b1e0e7a commit 6eb6ed0

File tree

3 files changed

+379
-0
lines changed

3 files changed

+379
-0
lines changed

.github/workflows/auto-release.yml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
name: Auto Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'ttsfm/**'
9+
- 'pyproject.toml'
10+
- 'README.md'
11+
12+
workflow_dispatch:
13+
inputs:
14+
bump_type:
15+
description: 'Version bump type'
16+
required: true
17+
default: 'patch'
18+
type: choice
19+
options:
20+
- patch
21+
- minor
22+
- major
23+
24+
jobs:
25+
check-changes:
26+
runs-on: ubuntu-latest
27+
outputs:
28+
should_release: ${{ steps.check.outputs.should_release }}
29+
new_version: ${{ steps.version.outputs.new_version }}
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Check if release needed
37+
id: check
38+
run: |
39+
# Check if there are changes since last tag
40+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
41+
CHANGES=$(git log ${LAST_TAG}..HEAD --oneline --grep="feat\|fix\|BREAKING" | wc -l)
42+
43+
if [ "$CHANGES" -gt 0 ] || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
44+
echo "should_release=true" >> $GITHUB_OUTPUT
45+
else
46+
echo "should_release=false" >> $GITHUB_OUTPUT
47+
fi
48+
49+
- name: Calculate new version
50+
id: version
51+
if: steps.check.outputs.should_release == 'true'
52+
run: |
53+
# Get current version from pyproject.toml
54+
CURRENT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
55+
echo "Current version: $CURRENT_VERSION"
56+
57+
# Determine bump type
58+
BUMP_TYPE="${{ github.event.inputs.bump_type || 'patch' }}"
59+
60+
# Calculate new version (simple implementation)
61+
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
62+
MAJOR=${VERSION_PARTS[0]}
63+
MINOR=${VERSION_PARTS[1]}
64+
PATCH=${VERSION_PARTS[2]}
65+
66+
case $BUMP_TYPE in
67+
major)
68+
MAJOR=$((MAJOR + 1))
69+
MINOR=0
70+
PATCH=0
71+
;;
72+
minor)
73+
MINOR=$((MINOR + 1))
74+
PATCH=0
75+
;;
76+
patch)
77+
PATCH=$((PATCH + 1))
78+
;;
79+
esac
80+
81+
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
82+
echo "New version: $NEW_VERSION"
83+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
84+
85+
release:
86+
needs: check-changes
87+
if: needs.check-changes.outputs.should_release == 'true'
88+
runs-on: ubuntu-latest
89+
90+
steps:
91+
- uses: actions/checkout@v4
92+
with:
93+
token: ${{ secrets.GITHUB_TOKEN }}
94+
95+
- name: Set up Python
96+
uses: actions/setup-python@v4
97+
with:
98+
python-version: '3.11'
99+
100+
- name: Update version in pyproject.toml
101+
run: |
102+
NEW_VERSION="${{ needs.check-changes.outputs.new_version }}"
103+
sed -i "s/^version = .*/version = \"$NEW_VERSION\"/" pyproject.toml
104+
105+
# Also update __init__.py if it exists
106+
if [ -f "ttsfm/__init__.py" ]; then
107+
sed -i "s/__version__ = .*/__version__ = \"$NEW_VERSION\"/" ttsfm/__init__.py
108+
fi
109+
110+
- name: Commit version bump
111+
run: |
112+
git config --local user.email "[email protected]"
113+
git config --local user.name "GitHub Action"
114+
git add pyproject.toml ttsfm/__init__.py
115+
git commit -m "bump: version ${{ needs.check-changes.outputs.new_version }}" || exit 0
116+
git push
117+
118+
- name: Create and push tag
119+
run: |
120+
NEW_VERSION="${{ needs.check-changes.outputs.new_version }}"
121+
git tag "v$NEW_VERSION"
122+
git push origin "v$NEW_VERSION"
123+
124+
- name: Install build dependencies
125+
run: |
126+
python -m pip install --upgrade pip
127+
pip install build twine
128+
129+
- name: Build package
130+
run: |
131+
python -m build
132+
133+
- name: Publish to PyPI
134+
uses: pypa/gh-action-pypi-publish@release/v1
135+
with:
136+
password: ${{ secrets.PYPI_API_TOKEN }}
137+
138+
- name: Create GitHub Release
139+
uses: softprops/action-gh-release@v1
140+
with:
141+
tag_name: v${{ needs.check-changes.outputs.new_version }}
142+
name: TTSFM v${{ needs.check-changes.outputs.new_version }}
143+
body: |
144+
## TTSFM v${{ needs.check-changes.outputs.new_version }}
145+
146+
Automated release with latest changes.
147+
148+
### Installation
149+
```bash
150+
pip install ttsfm==${{ needs.check-changes.outputs.new_version }}
151+
```
152+
153+
### What's Changed
154+
See commit history for detailed changes.
155+
draft: false
156+
prerelease: false
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Manual Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to release (e.g., 3.0.1)'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: '3.11'
22+
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install -e .
27+
28+
- name: Run basic tests
29+
run: |
30+
python -c "import ttsfm; print(f'TTSFM imported successfully')"
31+
python -c "from ttsfm import TTSClient; print('TTSClient imported successfully')"
32+
33+
build-and-release:
34+
needs: test
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
with:
40+
token: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Set up Python
43+
uses: actions/setup-python@v4
44+
with:
45+
python-version: '3.11'
46+
47+
- name: Update version
48+
run: |
49+
VERSION="${{ github.event.inputs.version }}"
50+
sed -i "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
51+
52+
# Update __init__.py if it exists
53+
if [ -f "ttsfm/__init__.py" ]; then
54+
sed -i "s/__version__ = .*/__version__ = \"$VERSION\"/" ttsfm/__init__.py
55+
fi
56+
57+
- name: Commit version update
58+
run: |
59+
git config --local user.email "[email protected]"
60+
git config --local user.name "GitHub Action"
61+
git add pyproject.toml ttsfm/__init__.py
62+
git commit -m "bump: version ${{ github.event.inputs.version }}" || exit 0
63+
git push
64+
65+
- name: Install build dependencies
66+
run: |
67+
python -m pip install --upgrade pip
68+
pip install build twine
69+
70+
- name: Build package
71+
run: |
72+
python -m build
73+
74+
- name: Check package
75+
run: |
76+
twine check dist/*
77+
ls -la dist/
78+
79+
- name: Publish to PyPI
80+
uses: pypa/gh-action-pypi-publish@release/v1
81+
with:
82+
password: ${{ secrets.PYPI_API_TOKEN }}
83+
84+
- name: Create and push tag
85+
run: |
86+
git tag "v${{ github.event.inputs.version }}"
87+
git push origin "v${{ github.event.inputs.version }}"
88+
89+
- name: Create GitHub Release
90+
uses: softprops/action-gh-release@v1
91+
with:
92+
tag_name: v${{ github.event.inputs.version }}
93+
name: TTSFM v${{ github.event.inputs.version }}
94+
body: |
95+
## TTSFM v${{ github.event.inputs.version }}
96+
97+
Manual release of TTSFM package.
98+
99+
### Installation
100+
```bash
101+
pip install ttsfm==${{ github.event.inputs.version }}
102+
```
103+
104+
### Features
105+
- Text-to-Speech API client with OpenAI compatibility
106+
- Support for multiple voices and audio formats
107+
- Async and sync interfaces
108+
- Web interface for testing
109+
110+
### Documentation
111+
See [GitHub repository](https://github.com/dbccccccc/ttsfm) for full documentation.
112+
draft: false
113+
prerelease: false
114+
115+
- name: Verify installation
116+
run: |
117+
echo "Waiting 30 seconds for PyPI to update..."
118+
sleep 30
119+
120+
pip install ttsfm==${{ github.event.inputs.version }}
121+
python -c "import ttsfm; print(f'✅ PyPI installation successful! Version: {ttsfm.__version__}')"

.github/workflows/release.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Release to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Triggers on version tags like v1.0.0, v3.0.0, etc.
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install -e .
27+
28+
- name: Test package import
29+
run: |
30+
python -c "import ttsfm; print(f'TTSFM imported successfully')"
31+
python -c "from ttsfm import TTSClient; print('TTSClient imported successfully')"
32+
33+
build:
34+
needs: test
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Set up Python
41+
uses: actions/setup-python@v4
42+
with:
43+
python-version: '3.11'
44+
45+
- name: Install build dependencies
46+
run: |
47+
python -m pip install --upgrade pip
48+
pip install build twine
49+
50+
- name: Build package
51+
run: |
52+
python -m build
53+
54+
- name: Check package
55+
run: |
56+
twine check dist/*
57+
ls -la dist/
58+
59+
- name: Upload build artifacts
60+
uses: actions/upload-artifact@v3
61+
with:
62+
name: dist
63+
path: dist/
64+
65+
release:
66+
needs: build
67+
runs-on: ubuntu-latest
68+
69+
steps:
70+
- uses: actions/checkout@v4
71+
72+
- name: Download build artifacts
73+
uses: actions/download-artifact@v3
74+
with:
75+
name: dist
76+
path: dist/
77+
78+
- name: Publish to PyPI
79+
uses: pypa/gh-action-pypi-publish@release/v1
80+
with:
81+
password: ${{ secrets.PYPI_API_TOKEN }}
82+
83+
- name: Create GitHub Release
84+
uses: softprops/action-gh-release@v1
85+
with:
86+
body: |
87+
## TTSFM ${{ github.ref_name }}
88+
89+
Automated release of TTSFM package.
90+
91+
### Installation
92+
```bash
93+
pip install ttsfm
94+
```
95+
96+
### Features
97+
- Text-to-Speech API client with OpenAI compatibility
98+
- Support for multiple voices and audio formats
99+
- Async and sync interfaces
100+
- Web interface for testing
101+
draft: false
102+
prerelease: false

0 commit comments

Comments
 (0)