Release #10
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: Release | |
| on: | |
| workflow_run: | |
| workflows: ["CI"] | |
| types: [completed] | |
| branches: ["main"] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' }} | |
| permissions: | |
| contents: write | |
| outputs: | |
| skipped: ${{ steps.changelog.outputs.skipped }} | |
| tag: ${{ steps.changelog.outputs.tag }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Conventional Changelog Action | |
| id: changelog | |
| uses: TriPSs/conventional-changelog-action@v6 | |
| with: | |
| github-token: ${{ secrets.github_token }} | |
| skip-commit: true | |
| skip-tag: true | |
| version-file: "pyproject.toml" | |
| version-path: "project.version" | |
| preset: "conventionalcommits" | |
| release-count: 0 | |
| tag-prefix: "v" | |
| output-file: "false" | |
| - name: Set version as environment variable | |
| run: echo "VERSION=${{ steps.changelog.outputs.version }}" >> $GITHUB_ENV | |
| - name: Update version in pyproject.toml | |
| run: sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml | |
| - name: Update version in Python file | |
| run: sed -i "s/__version__ = [\"'].*[\"']/__version__ = '$VERSION'/" fastapi_ronin/__init__.py | |
| - name: Commit all changes together | |
| if: ${{ steps.changelog.outputs.skipped == 'false' }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add pyproject.toml fastapi_ronin/__init__.py | |
| git diff --cached --quiet || git commit -m "chore(release): v$VERSION [skip ci]" | |
| git tag -f "v$VERSION" | |
| git push | |
| git push --force origin "v$VERSION" | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| if: ${{ steps.changelog.outputs.skipped == 'false' }} | |
| with: | |
| tag_name: ${{ steps.changelog.outputs.tag }} | |
| name: ${{ steps.changelog.outputs.tag }} | |
| body: ${{ steps.changelog.outputs.clean_changelog }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| build-and-publish: | |
| name: Build & Publish | |
| runs-on: ubuntu-latest | |
| needs: release | |
| if: ${{ needs.release.outputs.skipped == 'false' }} | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout exact release tag | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ needs.release.outputs.tag }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| enable-cache: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: "pyproject.toml" | |
| - name: Install packages | |
| run: uv sync --no-dev | |
| - name: Build package | |
| run: uv build | |
| - name: Publish to PyPI | |
| run: | | |
| if [ -n "${{ secrets.PYPI_API_TOKEN }}" ]; then | |
| uv publish --token "${{ secrets.PYPI_API_TOKEN }}" | |
| else | |
| echo "No PyPI token provided, skipping publish." | |
| fi |