Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate bump2version with auto #96

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .autorc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@
"baseBranch": "master",
"author": "auto <auto@nil>",
"noVersionPrefix": true,
"plugins": ["git-tag"]
"plugins": [
"git-tag",
[
"exec",
{
"afterChangelog": "bump2version \"$(printf '%s\n' \"$ARG_0\" | jq -r .bump)\""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the benefit of bringing in bump2version over some simple echo "__version__ = \"$ARG_0\"" >| datalad_crawler/version.py if ARG_0 is the one containing version here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ARG_0 doesn't contain the new version; it contains the name of the version level that is being incremented ("major", "minor", or "patch"), which is perfect for bump2version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and auto itself has no functionality to bump or report back the version? I thought it is the one which "mints" a new version to be, since otherwise I do not see e.g. how in dandi-cli version is decided upon -- we rely on versioneer, and I thought that one just uses the git tag, but then something mints the git tag (so the version). could you please digest the workflow here for me a bit more?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto can and does determine a new version, but (last time I checked) its $ARG_0 payload does not include that information; it only contains the changed version level. auto determines the version level based on the tags on the PRs since the last release, increments the version of the last release appropriately, generates & commits a changelog, runs the afterChangelog hook here to increment __version__ in the source code and commit the change, and then it tags the latest commit with the new version, pushes the tag, and creates a GitHub release.

Even if auto did report the actual version, the afterChangelog command would still need to include a git commit command after updating version.py, whereas bump2version can do all of that at once.

Copy link
Member

@yarikoptic yarikoptic Apr 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THANK YOU. Now it feels less magical. I would still prefer to avoid bump2version: even if both auto and bump2version use the similar logic for bumping a version, that is two different logics and might result in different results. Also still feels too heavy for such a tiny job.
If I read https://github.com/intuit/auto/blob/main/packages/core/src/auto.ts#L1880 code correctly, ARG_4 might be the currentVersion which if I get it right - is the new version auto decided upon. I think it is Ok to do a commit manually BUT ideally it should even be done along with the commit to the changelog: and looking at https://github.com/intuit/auto/blob/main/packages/core/src/auto.ts#L1896 it seems that beforeCommitChangelog should be the hook to use to produce desired version.py (edit: and probably need to stage it with git add). So could we 'tap' into that hook?

Even more ideally -- name of the package should be figured out automagically and it is possible!:

$> python setup.py --name 2>/dev/null
datalad_crawler

This would allow for the release workflow to be easily reused across multiple packages.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, as I said, the env dumps were generated when releasing version 0.3.2.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also: this comment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, that comment did not appear whenever I made my comment. gotcha.
it is a bit odd then that auto does not provide updated version - what is the point of having currentVersion and lastRelease to match?
Is there may be some auto command which would print an updated version?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worse comes to worse, it could as well be

awk 'NR==1{print $2}' CHANGELOG.md

to pick up the version, in beforeCommitChangelog.env right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be with some care/test with grep that obtained value is a semver in syntax

}
]
]
}
7 changes: 7 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[bumpversion]
current_version = 0.8.4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh and if we need to duplicate current version here it would ruin all point of auto . Makes me even more convinced that we should not use it

commit = True
message = [skip ci] Bump version: {current_version} → {new_version}
tag = False

[bumpversion:file:datalad_crawler/version.py]
8 changes: 8 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.6

- name: Install bump2version
run: python -m pip install bump2version

- name: Create release
run: ~/auto shipit
env:
Expand Down
2 changes: 1 addition & 1 deletion datalad_crawler/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.8.2'
__version__ = '0.8.4'