Merge pull request #73 from robust-python/release/2025.12.1 #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
| # .github/workflows/release-template.yml | |
| # Automated release workflow for the cookiecutter-robust-python template | |
| # Uses Calendar Versioning (CalVer): YYYY.MM.MICRO | |
| name: Release Template | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| micro_version: | |
| description: 'Override micro version (leave empty for auto-increment)' | |
| required: false | |
| type: string | |
| jobs: | |
| bump_and_build: | |
| name: Bump Version & Build | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.VERSION }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".github/workflows/.python-version" | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Bump version and generate changelog | |
| run: | | |
| if [ -n "${{ inputs.micro_version }}" ]; then | |
| uvx nox -s bump-version -- ${{ inputs.micro_version }} | |
| else | |
| uvx nox -s bump-version | |
| fi | |
| - name: Get version | |
| id: version | |
| run: | | |
| VERSION=$(uvx --from commitizen cz version -p) | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Push version bump commit | |
| run: git push origin HEAD | |
| - name: Build packages | |
| run: uvx nox -s build-python | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-${{ steps.version.outputs.VERSION }} | |
| path: dist/ | |
| retention-days: 7 | |
| publish_testpypi: | |
| name: Publish to TestPyPI | |
| runs-on: ubuntu-latest | |
| needs: bump_and_build | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v6 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist-${{ needs.bump_and_build.outputs.version }} | |
| path: dist/ | |
| - name: Publish to TestPyPI | |
| run: uvx nox -s publish-python -- --test-pypi | |
| publish_pypi: | |
| name: Tag & Publish to PyPI | |
| runs-on: ubuntu-latest | |
| needs: [bump_and_build, publish_testpypi] | |
| permissions: | |
| id-token: write | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: main | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".github/workflows/.python-version" | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Pull latest (includes version bump) | |
| run: git pull origin main | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist-${{ needs.bump_and_build.outputs.version }} | |
| path: dist/ | |
| - name: Create and push tag | |
| run: uvx nox -s tag-version -- push | |
| - name: Publish to PyPI | |
| run: uvx nox -s publish-python | |
| - name: Extract release notes | |
| run: uvx nox -s get-release-notes -- release_notes.md | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.bump_and_build.outputs.version }} | |
| name: v${{ needs.bump_and_build.outputs.version }} | |
| body_path: release_notes.md | |
| files: dist/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |