#đź”’ Python and Semantic-release versioning

23 messages · Page 1 of 1 (latest)

dusky halo
#

Hey folks! I’m stuck with python-semantic-release on a “test” branch where it keeps trying to upload the same artifacts (version 0.1.0-rc.1), resulting in a 422 (Unprocessable Entity) error on GitHub. Here’s the situation:

  • I have a “test” branch for dev/pre-releases.
  • I originally ran python -m build before running semantic-release publish, so it always built artifacts labeled 0.1.0 (or 0.1.0-rc.1).
  • When semantic-release checks for a new version, it never increments beyond 0.1.0-rc.1, reuses the same tag, and tries to re-upload the same .whl/.tar.gz to GitHub → 422 error because those files already exist under that release.

I’ve tried:

  1. Removing the manual python -m build step (letting semantic-release do the build),
  2. Creating commits with feat!: ... BREAKING CHANGE: lines to force major bumps,
  3. Even environment overrides like SEMANTIC_RELEASE_LEVEL=minor.

No matter what, the logs say “found 1 previous tag (0.1.0-rc.1),” reuses that tag, and collides with existing assets. Any idea why it won’t bump to something like 0.1.0-rc.2 or 0.2.0-rc.1? Is it because semantic-release thinks there aren’t actually new recognized commits, or because the prior build is always the same version?

How should I ensure each run actually increments the version and builds unique artifacts so we don’t keep hitting the 422 error? Any tips or config suggestions would be greatly appreciated!

tulip sequoiaBOT
#

@dusky halo

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

dusky halo
#
name: Release to PyPI

on:
  push:
    branches: [ "test" ]

jobs:
  release:
    runs-on: ubuntu-latest

    steps:
      - name: Check out repo
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: "3.11"

      - name: Install Dependencies
        run: |
          pip install --upgrade pip
          pip install build python-semantic-release

      - name: Build the package
        run: python -m build

      - name: Run Semantic Release
        env:
          GH_TOKEN: ${{ secrets.GH_TOKEN }}
          PYPI_USERNAME: "__token__"
          PYPI_PASSWORD: ${{ secrets.PYPI_TOKEN }}
        run: semantic-release -vv publish
[tool.semantic_release]
tag_format = "{version}"
build_command = "python -m build"

[tool.semantic_release.branches."test"]
match = "test"
prerelease = true
prerelease_token = "rc"
repository_url = "https://test.pypi.org/legacy/"
starting_version = "0.1.0"

[tool.semantic_release.branches."main"]
match = "main"
prerelease = false
repository_url = "https://upload.pypi.org/legacy/"
silver ridge
#

where does this thing get its version data from

dusky halo
dusky halo
silver ridge
#

I've been doing semantic releases for a long time w/o this tool

dusky halo
silver ridge
#

I push a git tag and everything else happens automatically

#

sdist/wheel creation, uploading to pypi and publishing a github release w/ the changelog

dusky halo
silver ridge
#

note that I am using trusted publishing which has to be configured separately on the pypi

dusky halo
silver ridge
#

I manually add a new tag, yes

silver ridge
#

yes

dusky halo
#

ohh okkay, Thanks!
I will try to do the same!

#

the only wierd part for me is that your project.toml file deosn't have

tool.semantic_release

silver ridge
#

why is that weird? I told you I'm not using that tool

dusky halo
tulip sequoiaBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.