Release in GitLab fails due to can't push to master from detached state
See original GitHub issueProjen version: 0.56.13 CDK Version: 2.24.1 Typescript version: 4.6.4
I’ve recently upgraded to the newest version of projen from 0.19.x. I use it to define CDK constructs in a GitLab monorepo where the root project and .gitlab-ci.yml are manually created (not via projen). I used to use the bump task to update version, then manually tag and commit changes back to the repo, but am trying to switch to using projen release command. I’m running into an issue when the release task tries to commit back to the repo where it throws the error
👾 release » publish:git | git push --follow-tags origin master
error: src refspec master does not match any
error: failed to push some refs to 'https://gitlab.com/####/devops/cdkconstructs'
It does look like the commit is being created, so it’s not that there’s no commit, but it’s in a detached state.
[detached HEAD dc08d87] chore(release): 0.1.1
1 file changed, 2 insertions(+)
It is my understanding that due to being in a detached state, you can’t just push to master with git push --follow-tags origin master
which is what the default gitPushCommand is, but rather need git push --follow-tags origin HEAD:master
. I have seen that you can override the publisher.gitPushCommand, but have not figured out how to do this with the AwsCdkConstructLibrary class.
I can’t edit the task with project.release.publish.publishToGit(gitPushCommand:
git push --follow-tags origin HEAD:master})
. It tries to create a new task, but one with that name already exists. If I try to first remove the publish:git task, it fails because the release task is dependent on it.
So 1, why does the gitPushCommand try to push directly to the main|master branch if it’s in a detached state? Won’t that always error? And 2, how do configure the override for the gitPushCommand? I can’t find any docs to help.
Thanks
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
One other thing, if you’re able to answer here. I haven’t run into this yet, but since I have a monorepo where CI release steps are run in each constructs directory. I suspect that if I have releases triggered for multiple constructs at once I could hit a race condition where the first construct to push changes back wins and subsequent ones fail. Previously, when I did all these steps manually didJust realized I could prepend this to push command. There’s also the option to set it to ‘’ and then run additional steps manually/ use gitlab CI variables.pull --rebase
right before the push to make sure I had the latest. It is a bit weird, but is there anyway to insert this task via projenrc.js in the release steps?Is it possible to customize the git push command by specifying the release trigger like this perhaps?
I’m not too familiar with this component. If changing
master
toHEAD:master
wouldn’t break any existing users, then I’d be okay accepting a pull request that updates the default command directly in projen’s source code.cc @gradybarrett