Releasing on protected branch
See original GitHub issueHello, thanks for a great tool.
We have a protected master branch becase we want to enforce pull requests reviewes before merging as well as prevent accidental merging to master directly.
Expected Behavior
I would like to be able publish packages no matter if primary branch is protected
Current Behavior
Currently, if user is not administrator, and error is thrown.
Possible Solution
No idea if there is any way around this, but I would appreciate suggestions on how to go around this and keep the primary branch protected.
lerna.json
{
"packages": [
"packages/*"
],
"version": "independent",
"npmClient": "yarn"
}
lerna-debug.log
Are you sure you want to publish these packages? Yes
lerna info git Pushing tags...
lerna ERR! Error: Command failed: git push --follow-tags --no-verify origin master
lerna ERR! remote: error: GH006: Protected branch update failed for refs/heads/master.
lerna ERR! remote: error: At least 1 approving review is required by reviewers with write access.
lerna ERR! To https://github.com/company/repo.git
lerna ERR! * [new tag] @company/repo-package@0.3.6 -> @company/repo-package@0.3.6
lerna ERR! ! [remote rejected] master -> master (protected branch hook declined)
lerna ERR! error: failed to push some refs to ‘https://github.com/company/repo.git’
lerna ERR!
lerna ERR! at makeError (/Users/{censored}/node_modules/execa/index.js:174:9)
lerna ERR! at Promise.all.then.arr (/Users/{censored}/node_modules/execa/index.js:278:16)
lerna ERR! Error: Command failed: git push --follow-tags --no-verify origin master
lerna ERR! remote: error: GH006: Protected branch update failed for refs/heads/master.
lerna ERR! remote: error: At least 1 approving review is required by reviewers with write access.
lerna ERR! To https://github.com/company/repo.git
lerna ERR! * [new tag] @company/repo-package@0.3.6 -> @company/repo-package@0.3.6
lerna ERR! ! [remote rejected] master -> master (protected branch hook declined)
lerna ERR! error: failed to push some refs to ‘https://github.com/company/repo.git’
lerna ERR!
lerna ERR! at makeError (/Users/{censored}/node_modules/execa/index.js:174:9)
lerna ERR! at Promise.all.then.arr (/Users/{censored}/node_modules/execa/index.js:278:16)
lerna ERR! lerna Command failed: git push --follow-tags --no-verify origin master
lerna ERR! lerna remote: error: GH006: Protected branch update failed for refs/heads/master.
lerna ERR! lerna remote: error: At least 1 approving review is required by reviewers with write access.
lerna ERR! lerna To https://github.com/company/repo.git
lerna ERR! lerna * [new tag] @company/repo-package@0.3.6 -> @company/repo-package@0.3.6
lerna ERR! lerna ! [remote rejected] master -> master (protected branch hook declined)
lerna ERR! lerna error: failed to push some refs to ‘https://github.com/company/repo.git’
lerna ERR! lerna
error Command failed with exit code 1.
Context
I would like to be able publish packages no matter if primary branch is protected or even if user is not an Administrator of the org or repo.
Your Environment
Executable | Version |
---|---|
lerna --version |
3.10.7 |
npm --version |
6.4.1 |
yarn --version |
1.13.0 |
node --version |
v10.15.1 |
OS | Version |
---|---|
macOS | 10.14.3 |
Thank you very much for any suggestions.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:41
- Comments:20 (1 by maintainers)
Top Results From Across the Web
About protected branches - GitHub Docs
You can protect important branches by setting branch protection rules, which define whether collaborators can delete or force push to the branch and...
Read more >Protected branches - GitLab Docs
Require everyone to submit merge requests for a protected branch · On the top bar, select Main menu > Projects and find your...
Read more >How to set up Git branch protection rules - Spectral
Step 1: Navigate to your repository homepage at Github. · Step 2: Click on the Add Rule option as shown below. · Step...
Read more >How to push to GitHub protected branch via sbt-release plugin?
The flow works as follows: once a PR is reviewed and merged to main (the protected branch), more tests are executed in GitHub...
Read more >Set Up Branch and Merge Restrictions | JetBrains Space ...
To set up a branch protection rule: · Open the Repository Settings page. · Go to the Protected Branches tab. · Existing rules...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would question the necessity of locking
master
first, frankly. It’s not going to magically protect you from all mistakes.In any event, as long as you’re willing to sacrifice the specificity that Lerna achieves through git tags, you can run
lerna version --no-git-tag-version
to prepare a PR (which will bump everything, as you’ve mangled the previous tags through merging), merge that PR into master, and then runlerna publish from-package --yes
(maybe in CI? up to you), which does not make a commit or tag and publishes any local packages whose version does not exist in the configured registry.But again, I would recommend reconsidering what you’re really gaining by locking
master
, given the tradeoff of losing all relevant git tags and partially-applied publishes.Hi @evocateur, thank you for your input and suggestions. And of course thanks for lerna!
I do get your point. The main reason for locking
master
is to add rules such as :And
The problem is, in our repo, various member of team are contributing to it, including junior staff members that are more likely to make a mistake and e.g. merge PR without a review etc. Although this would be managable, and we could always revert… at scale this might get difficult to keep track of.
I do understand that this is not really problem of lerna but more rules and politics in our team, I was just wondering if there is a way how to keep branch protected and publish packages which I get is not possible at the moment. Now the question is, if someone would take this challenge on, is it possible to achieve this at all?
So I do think being able to lock master does make sense and is common practice, and being to publish via lerna would be a really good feature and would help other people that have been having the same issue.
Thank you