pypa / setuptools-scm

the blessed package to manage your versions by scm tags
https://setuptools-scm.readthedocs.io/en/latest/
MIT License
858 stars 210 forks source link

How to Publish Next Version #693

Closed mikelnick closed 2 years ago

mikelnick commented 2 years ago

I am very green with python packaging.

Is there no way to just publish the value python -m setuptools_scm --strip-dev for production package releases? This is such a great tool and it seems like if I want to create a tag on my repo and have it publish a "clean" version it should work with a config param but I am not seeing how to do this. I know this isn't a support board but it seems like a documentation miss.

This will set version to 3.0.1.dev5

[tool.setuptools_scm]
write_to = "TestPackage/_version.py"
version_scheme = "guess-next-dev"
local_scheme = "no-local-version"

This will set version to 3.0.1.dev5+g449642a.d20220302

[tool.setuptools_scm]
write_to = "TestPackage/_version.py"
version_scheme = "guess-next-dev"

How do you use this tool and have version set to 3.0.1?

RonnyPfannschmidt commented 2 years ago

please take example in the production releases of setuptools-scm - those are done off tags

RonnyPfannschmidt commented 2 years ago

https://github.com/pypa/setuptools_scm/blob/main/.github/workflows/python-tests.yml#L153

mikelnick commented 2 years ago

That was my assumption as well. I am using Gitlab CI, and the default branch name is main. It doesn't seem to be working the way I thought. It might be due to those two factors.

RonnyPfannschmidt commented 2 years ago

@mikelnick releases on gilab should work the same way, do you prohibit running the pipelines on tags by chance (and are tags protected or not)

mikelnick commented 2 years ago

I was just trying to block running on main without dedicated tag and have .dev* releases for non main/tag. Tags are not protected. It felt like I needed to supply some value to the "Release". The other thing I tried was changing the regex, but I was following conventional v1.0.0 semver when creating tags.

Dev:
  script:
    - pip install --upgrade twine build
    - python3 -m build
    - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
  except:
    refs:
      - main
      - tags

Release:
  script:
    - pip install --upgrade twine build
    - python3 -m build
    - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
  only:
    refs:
      - tags
RonnyPfannschmidt commented 2 years ago

Nothing springs to the eye at first, more details needed

mikelnick commented 2 years ago

Thank you so much for taking the time to respond. I tried to reproduce it and now it works with a new repo. I feel like a jerk. Thank you again.

mikelnick commented 2 years ago

https://gitlab.com/mikelnick/py-lib-test/-/packages