Manual Patch Release #14
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: Manual Patch Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (e.g., 0.2.1, leave empty to auto-bump patch)' | |
| required: false | |
| type: string | |
| release_notes: | |
| description: 'Custom release notes (optional)' | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| id-token: write # Required for PyPI trusted publishing | |
| jobs: | |
| patch-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v3 | |
| - name: Get last release tag | |
| id: last_tag | |
| run: | | |
| last_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
| echo "last_tag=$last_tag" >> $GITHUB_OUTPUT | |
| echo "Last tag: $last_tag" | |
| - name: Bump version | |
| id: version | |
| run: | | |
| if [ -n "${{ inputs.version }}" ]; then | |
| uv version ${{ inputs.version }} | |
| new_version="${{ inputs.version }}" | |
| echo "Using specified version: $new_version" | |
| else | |
| uv version --bump patch | |
| new_version=$(uv version --short) | |
| echo "Auto-bumped patch version to: $new_version" | |
| fi | |
| echo "new_version=$new_version" >> $GITHUB_OUTPUT | |
| echo "Version: $new_version" | |
| - name: Configure git | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| - name: Commit version bump | |
| run: | | |
| git add pyproject.toml uv.lock | |
| git commit -m "chore: bump version to ${{ steps.version.outputs.new_version }}" | |
| git push origin HEAD:main 2>/dev/null || git push origin HEAD:master | |
| - name: Create and push tag | |
| run: | | |
| git tag -a "v${{ steps.version.outputs.new_version }}" -m "Release v${{ steps.version.outputs.new_version }}" | |
| git push origin --tags | |
| - name: Generate changelog | |
| id: changelog | |
| run: | | |
| last_tag="${{ steps.last_tag.outputs.last_tag }}" | |
| if [ -z "$last_tag" ]; then | |
| changelog=$(git log --pretty=format:"- %s (%h)" --no-merges | head -20) | |
| else | |
| changelog=$(git log $last_tag..HEAD --pretty=format:"- %s (%h)" --no-merges) | |
| fi | |
| echo "changelog<<EOF" >> $GITHUB_OUTPUT | |
| echo "$changelog" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| echo "release_date=$(date -u +"%Y-%m-%d")" >> $GITHUB_OUTPUT | |
| - name: Build package | |
| run: uv build | |
| - name: Create GitHub Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.new_version }} | |
| name: v${{ steps.version.outputs.new_version }} | |
| body: | | |
| ## 🔧 Patch Release v${{ steps.version.outputs.new_version }} | |
| Released on: ${{ steps.changelog.outputs.release_date }}. | |
| ### Installation | |
| ```bash | |
| uv add fastapi-cachex==${{ steps.version.outputs.new_version }} | |
| ``` | |
| ${{ inputs.release_notes != '' && format('**Release Notes:**\n{0}\n\n', inputs.release_notes) || '' }} | |
| **📝 Changelog:** | |
| ${{ steps.changelog.outputs.changelog }} | |
| --- | |
| **Full Changelog**: https://github.com/allen0099/FastAPI-CacheX/compare/${{ steps.last_tag.outputs.last_tag }}...v${{ steps.version.outputs.new_version }} | |
| draft: false | |
| prerelease: false | |
| make_latest: true | |
| files: | | |
| dist/*.whl | |
| dist/*.tar.gz | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| - name: Summary | |
| run: | | |
| echo "### Manual Patch Release Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ Version bumped to: ${{ steps.version.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "📦 Previous version: ${{ steps.last_tag.outputs.last_tag || 'None' }}" >> $GITHUB_STEP_SUMMARY | |
| echo "🏷️ Release created: v${{ steps.version.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "🚀 Published to PyPI" >> $GITHUB_STEP_SUMMARY |