Created
September 1, 2025 02:29
-
-
Save 7c00/c305f8824d59beb70ada274edb831e00 to your computer and use it in GitHub Desktop.
release-prepare.yaml & release-publish.yaml
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
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump: | |
| description: bump | |
| required: true | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| default: patch | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| prepare: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check branch | |
| if: ${{ github.ref != 'refs/heads/main' }} | |
| run: echo "This action can only be run on the main branch." && exit 1 | |
| - uses: actions/[email protected] | |
| with: | |
| ref: ${{ github.ref }} | |
| show-progress: false | |
| - name: Setup uv | |
| uses: astral-sh/[email protected] | |
| - name: Bump version | |
| run: | | |
| echo ">>> Current version: $(uv version --short)" | |
| uv version --bump ${{ inputs.bump }} | |
| echo ">>> New version: $(uv version --short)" | |
| - name: Commit change and tag | |
| run: | | |
| git config --global --add safe.directory ${{github.workspace}} | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git config pull.rebase false | |
| echo "Release $(uv version --short)" >/tmp/.msg | |
| echo >>/tmp/.msg | |
| echo "Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >>/tmp/.msg | |
| echo "By: @${{ github.triggering_actor }}" >>/tmp/.msg | |
| git commit -am "$(cat /tmp/.msg)" | |
| git tag "v$(uv version --short)" | |
| GIT_PAGER=cat git log --pretty="format:%s" -3 | |
| git push origin main | |
| git push origin main --tags | |
| - name: Trigger release workflow | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| gh workflow run release-publish.yaml -r "v$(uv version --short)" |
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::Publish | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Check tag | |
| if: ${{ ! startsWith(github.ref, 'refs/tags/v') }} | |
| run: echo "This action can only be run on a tag." && exit 1 | |
| - name: Checkout code | |
| uses: actions/[email protected] | |
| with: | |
| ref: ${{ github.ref }} | |
| show-progress: false | |
| - name: Setup uv | |
| uses: astral-sh/[email protected] | |
| - name: Build | |
| run: | | |
| echo ">>> Current version: $(uv version --short)" | |
| uv build | |
| sha256sum dist/* | |
| - name: Publish release distributions to PyPI | |
| uses: pypa/[email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment