-1

I think that it's good idea to build artifact and then deploy it across all environment, test, preprod, prod. But according to Gitflow we use "release" branches for tests and we merge it to main, develop and delete release branch. So we have "release" artifact and we test it, but as I understand we deploy to prod artifact from tagged main branch. And for me it's strange. What could be the objective reasons of this?

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
suppix
  • 1

1 Answers1

0

main <=> prod

The reason for this is simple, however, the usual name of the main branch is master. One needs to have an easy way to refer back to whatever prod contains, because, in the case of hotfixes, you want to branch out from prod, because the issue is reproducible there. It is another matter that there is usually a branch for hotfixes as well.

release branches

Basically, you may have many different things that are being developed at the same time. You probably want to create well-separated partitions of problem-spaces to define your tasks, each such partition would represent a release. So, if you are optimizing some business logic on the one hand and you are polishing the UI on the other hand, then you not necessarily know which one will be released first, so you will have some named branches for those. Having "release" branches is a convention for this. Now, when you are deploying a release to prod, you can merge master into your release branch and perform automatic and/or manual tests. When this is successful, your release branch is merged into your master branch.

Deleting a release branch

Once the work represented by a release branch is successfully completed, it makes sense to remove it after it was merged to avoid wasting storage space on things that are unlikely to change (because they were accepted). Note that if a problem arises with a release later on, you can always checkout the commit hash of the tagged commit that represents the release merge in order to see whether the problem you have seen was already manifesting when the release branch was released.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
  • Thank you for the answer. The question was about artifacts, according to Gitflow as I understand we test artifacts from "release" branch, and deploy artifacts from "main/master/prod" branch, and this is strange for me because I think it's better no to build artifact again and use the same across all envs. BTW Github and Gitlab uses main branch as a default. – suppix Jul 02 '22 at 09:38