Skip to content

Version files left unstaged for commit in 2 stage PSR execution #1211

Closed

Description

@codejedi365

Bug Report

Separated into its own issue from #1125, comments from @JonZeolla

Description

In order to resolve #1125, I implemented your two step workflow documented in #1125 (comment). And unfortunately it seems with v9.20.0, the 2 step workflow does not commit the version_variables and version_toml changes unless I intentionally stage them myself.

Expected behavior

The version_variables and version_toml configured files are committed with the release commit while also allowing me to keep uv.lock updated in between the steps.

Actual behavior

The version files were not committed in the release commit while the uv.lock was. The version files remained in the working directory

Environment

  • Operating System (w/ version):
  • Python version:
  • Semantic-release version: v9.20.0

Configuration

Semantic Release Configuration
[tool.semantic_release]
major_on_zero = false
version_toml = [
    "pyproject.toml:project.version",
]
version_variables = [
    "src/example/__init__.py:__version__",
]
changelog_file = "CHANGELOG.md"
commit_parser = "angular"
commit_author = "Example <[email protected]>"
commit_message = "chore(release): example {version}"
tag_format = "example=={version}"

[tool.semantic_release.branches.release]
match = "main"

[tool.semantic_release.publish]
dist_glob_patterns = ["path_relative_to_root/example/dist/*"]
upload_to_vcs_release = true

[tool.semantic_release.remote]
name = "origin"
type = "github"
ignore_token_for_push = false
insecure = false

Execution Log

semantic-release -vv version

Additional context

My guess is that it's this and this. Since we stage the changes before running the --commit, the new_content is the same as self.content (in the working tree), so it returns None.

Then, that doesn't add the file path to paths here, which means it is not added to files_with_new_version_written here:

files_with_new_version_written = apply_version_to_source_files(
repo_dir=runtime.repo_dir,
version_declarations=runtime.version_declarations,
version=new_version,
noop=opts.noop,
)
all_paths_to_add.extend(files_with_new_version_written)

And then finally, it isn't staged and commit here:

if commit_changes:
project.git_add(paths=all_paths_to_add, noop=opts.noop)
# NOTE: If we haven't modified any source code then we skip trying to make a commit
# and any tag that we apply will be to the HEAD commit (made outside of
# running PSR
try:
project.git_commit(
message=commit_message.format(version=new_version),
date=int(commit_date.timestamp()),
no_verify=no_verify,
noop=opts.noop,
)
except GitCommitEmptyIndexError:
log.info("No local changes to add to any commit, skipping")

Activity

  1. added
    bugSomething isn't working properly
    confirmedPrevent from becoming stale
    on Mar 12, 2025
  2. self-assigned this
    on Mar 12, 2025
  3. codejedi365 commented on Mar 12, 2025

    @codejedi365
    ContributorAuthor

    Plan to modify the version --no-commit command option to still stage the intended files for commit even though no commit is executed. This will resolve your workflow as the second execution of PSR will commit all the files that are in the index which will include:

    • uv.lock
    • pyproject.toml
    • src/example/__init__.py
  4. JonZeolla commented on Mar 12, 2025

    @JonZeolla
    Contributor

    Thanks @codejedi365 that approach works for me and makes sense. I'll keep an eye out (or I can submit a PR doing what you outlined above, if you'd like)

  5. codejedi365 commented on Mar 12, 2025

    @codejedi365
    ContributorAuthor

    @JonZeolla, if you want to give a PR a shot, that would definitely help me out.

  6. JonZeolla commented on Mar 13, 2025

    @JonZeolla
    Contributor

    @codejedi365 sounds good, I just opened #1214, can you please approve the workflow runs on that PR so I can make sure CI passes?

  7. github-actions commented on May 13, 2025

    @github-actions

    It has been 60 days since the last update on this confirmed issue. @python-semantic-release/team can you provide an update on the status of this issue?

  8. added 4 commits that reference this issue on Jun 7, 2025
    9dc37c8
    aa09a91
    d28ca80
    365525a
  9. codejedi365 commented on Jun 8, 2025

    @codejedi365
    ContributorAuthor

    resolution pending

  10. added and removed
    confirmedPrevent from becoming stale
    on Jun 12, 2025
  11. added a commit that references this issue on Jun 12, 2025
    de62334
  12. codejedi365 commented on Jun 12, 2025

    @codejedi365
    ContributorAuthor

    🎉 This issue has been resolved in v10.1.0 🎉

    You can find more information about this release on the GitHub Releases page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working properlyreleased

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions