-
Notifications
You must be signed in to change notification settings - Fork 0
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
Use version from PR title when edited by end user #26
Use version from PR title when edited by end user #26
Conversation
The feature works, at least for the base strategy. Before merging I will add some unit tests to be sure all strategies have the same behaviour. |
Just thought about something simplifying the feature, instead of using a label we can check the current version from the release-please manifest from the release branch (before updating it of course): if it does not match the PR title, then the PR title has been edited. Edit: PR description updated to match this logic |
Ok, I think that's way better. I need to test and write tests tomorrow. |
How does this work if the PR title has not been edited and another commit is pushed that would further increase the version number? e.g.
Separately, is there any handling for the case where a commit is pushed after the user has edited the title? I think it could be quite nice to have a comment that the bot automatically updates that says something along the lines of:
|
This wouldn't be an issue, at the time we compare the version from the PR title to the version in the manifest the version bump didn't occur yet. You can see it here:
Your example here seems to match the situation when another commit is pushed after an edit. That's something I thought about yesterday evening. The best solution I found is to add a label Regarding the bot comment, that's a great idea, we can have release-please write a comment to the PR in addition to setting the label |
I added PR comments for warnings and issues, and to communicate to the user how to the end user how they can change back to generated versions. The different states can be seen on this PR: |
src/strategies/base.ts
Outdated
|
||
:rotating_light: This Pull Request has the \`${DEFAULT_CUSTOM_VERSION_LABEL}\` label but the version number cannot be found in the title. Instead the generated version \`${newVersion}\` will be used. | ||
|
||
If you want to use a custom version be sure to use the semver format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
semver
isn't something most people know what it means. Either explain or link to description?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. I actually started with a link to the semver spec but they aren't really user friendly. Would a link to something like this cheat sheet be more helpful? https://devhints.io/semver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option would be wikipedia? Not as user friendly: https://en.wikipedia.org/wiki/Software_versioning#Semantic_versioning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cheat sheet link is good enough. Once it's clear what it means, users can investigate further, but the cheat sheet covers 99% (that's a very accurate madeup statistic)
Ok, now we have a test for this feature covering all the release type we are using: When changing things related to the base strategy or from |
…dited' That makes it possible for an end user to control the version number number without having to rely on a commit with the footnote RELEASE-AS. The label can be easily added by a GitHub Action like this one: ```yaml name: Handle release PR edits on: pull_request: types: - edited jobs: update_pr_content: name: Update pull request content if: | github.event.pull_request.state == 'open' && github.event.changes.title.from != github.event.pull_request.title && github.event.sender.login != 'stainless-bot' # this is important to avoid infinite loops runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/github-script@v6 with: script: | github.rest.issues.addLabels({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, labels: ['autorelease: user edited'] # add the label }) - name: Then here run release-please - run: ... ```
…ecific strategies
eced66d
to
6d150d2
Compare
To determine if the user edited the version from the PR title
release-please
does the following:autorelease: custom version
, use the version from the title and stop hereautorelease: custom version
to the PRautorelease: custom version
"For my tests I am using a github action like this one:
You can find an example of a release with a custom label here, and the release pull request here.