Update README.md #2
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: Auto Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'ttsfm/**' | |
| - 'pyproject.toml' | |
| - 'README.md' | |
| workflow_dispatch: | |
| inputs: | |
| bump_type: | |
| description: 'Version bump type' | |
| required: true | |
| default: 'patch' | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| jobs: | |
| check-changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_release: ${{ steps.check.outputs.should_release }} | |
| new_version: ${{ steps.version.outputs.new_version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check if release needed | |
| id: check | |
| run: | | |
| # Check if there are changes since last tag | |
| LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | |
| CHANGES=$(git log ${LAST_TAG}..HEAD --oneline --grep="feat\|fix\|BREAKING" | wc -l) | |
| if [ "$CHANGES" -gt 0 ] || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Calculate new version | |
| id: version | |
| if: steps.check.outputs.should_release == 'true' | |
| run: | | |
| # Get current version from pyproject.toml | |
| CURRENT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') | |
| echo "Current version: $CURRENT_VERSION" | |
| # Determine bump type | |
| BUMP_TYPE="${{ github.event.inputs.bump_type || 'patch' }}" | |
| # Calculate new version (simple implementation) | |
| IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" | |
| MAJOR=${VERSION_PARTS[0]} | |
| MINOR=${VERSION_PARTS[1]} | |
| PATCH=${VERSION_PARTS[2]} | |
| case $BUMP_TYPE in | |
| major) | |
| MAJOR=$((MAJOR + 1)) | |
| MINOR=0 | |
| PATCH=0 | |
| ;; | |
| minor) | |
| MINOR=$((MINOR + 1)) | |
| PATCH=0 | |
| ;; | |
| patch) | |
| PATCH=$((PATCH + 1)) | |
| ;; | |
| esac | |
| NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
| echo "New version: $NEW_VERSION" | |
| echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| release: | |
| needs: check-changes | |
| if: needs.check-changes.outputs.should_release == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Update version in pyproject.toml | |
| run: | | |
| NEW_VERSION="${{ needs.check-changes.outputs.new_version }}" | |
| sed -i "s/^version = .*/version = \"$NEW_VERSION\"/" pyproject.toml | |
| # Also update __init__.py if it exists | |
| if [ -f "ttsfm/__init__.py" ]; then | |
| sed -i "s/__version__ = .*/__version__ = \"$NEW_VERSION\"/" ttsfm/__init__.py | |
| fi | |
| - name: Commit version bump | |
| run: | | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "GitHub Action" | |
| git add pyproject.toml ttsfm/__init__.py | |
| git commit -m "bump: version ${{ needs.check-changes.outputs.new_version }}" || exit 0 | |
| git push | |
| - name: Create and push tag | |
| run: | | |
| NEW_VERSION="${{ needs.check-changes.outputs.new_version }}" | |
| git tag "v$NEW_VERSION" | |
| git push origin "v$NEW_VERSION" | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Build package | |
| run: | | |
| python -m build | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ needs.check-changes.outputs.new_version }} | |
| name: TTSFM v${{ needs.check-changes.outputs.new_version }} | |
| body: | | |
| ## TTSFM v${{ needs.check-changes.outputs.new_version }} | |
| Automated release with latest changes. | |
| ### Installation | |
| ```bash | |
| pip install ttsfm==${{ needs.check-changes.outputs.new_version }} | |
| ``` | |
| ### What's Changed | |
| See commit history for detailed changes. | |
| draft: false | |
| prerelease: false |