Feature -> Release
Action | Branches and their versions (before) | CLI commands | Branches and their versions (after) | More details |
Start a feature | develop: 1.0.0-SNAPSHOT.0 master: 1.0.0-SNAPSHOT.0 | git flow feature start xxx git flow feature publish xxx | feature/xxx: 1.0.0-SNAPSHOT.0 develop: 1.0.0-SNAPSHOT.0 master: 1.0.0-SNAPSHOT.0 | Or just branch from develop |
Finish a feature | feature/xxx: 1.0.0-SNAPSHOT.0 develop: 1.0.0-SNAPSHOT.0 master: 1.0.0-SNAPSHOT.0 | git flow feature finish xxx | develop: 1.0.0-SNAPSHOT.0 master: 1.0.0-SNAPSHOT.0 | Or just using pull requests |
Start a release | develop: 1.0.0-SNAPSHOT.0 master: 1.0.0-SNAPSHOT.0 | #create a release branch and switch to this branch git flow release start `./next-release-version.sh` # bump up to a release version. # why “-no-git-tag-version” ? ## you don’t want npm to create a tag for you. ## It’s the job of git flow npm –no-git-tag-version version patch git commit -am “Bump up version to `./current-version.sh`” git flow release publish | develop: 1.0.0-SNAPSHOT.0 release/1.0.0: 1.0.0 master: 1.0.0-SNAPSHOT.0 | See *.sh files later |
Finish a release | develop: 1.0.0-SNAPSHOT.0 release/1.0.0: 1.0.0 master: 1.0.0-SNAPSHOT.0 | #After running it, ## changes will be merged to develop/master ### but local only. ## a tag will be be created locally, not pushed. ## Release branch will be deleted local/remote GIT_MERGE_AUTOEDIT=no git flow release finish -m `./current-version.sh` git checkout master #Bump up the version to SNAPSHOT npm version prerelease –preid=SNAPSHOT git push git checkout develop # copy the bumped version from master to develop git merge master git push | develop: 1.0.1-SNAPSHOT.0 (tag)1.0.0: 1.0.0 master: 1.0.1-SNAPSHOT.0 |
Source code of *.sh
The source of current-version.sh
#!/bin/sh node -e "console.log(require('./package.json').version);"
The source of next-release-version.sh
#!/bin/sh node -e "console.log(require('./package.json').version);" | awk -F - '{print $1}' #Also see https://github.com/npm/rfcs/discussions/302
Hotfix
Action | Branches and their versions (before) | CLI commands | Branches and their versions (after) | More details |
Start a hotfix | develop: 1.0.1-SNAPSHOT.0 master: 1.0.1-SNAPSHOT.0 | git flow hotfix start `./next-release-version.sh` # bump up to a release version. # why “-no-git-tag-version” ? ## you don’t want npm to create a tag for you. ## It’s the job of git flow npm –no-git-tag-version version patch git commit -am “Bump up version to `./current-version.sh`” git push | develop: 1.0.1-SNAPSHOT.0 hotfix/1.0.1: 1.0.1 master: 1.0.1-SNAPSHOT.0 | |
Do code change | develop: 1.0.1-SNAPSHOT.0 hotfix/1.0.1: 1.0.1 master: 1.0.1-SNAPSHOT.0 | N/A | develop: 1.0.1-SNAPSHOT.0 hotfix/1.0.1: 1.0.1 master: 1.0.1-SNAPSHOT.0 | Do it in the hotfix branch |
Finish hotfix | develop: 1.0.1-SNAPSHOT.0 hotfix/1.0.1: 1.0.1 master: 1.0.1-SNAPSHOT.0 | #After running it ## changes will be merged to master and develop( not pushed) ### You may have to resolve conflicts ## A tag will be created locally (not pushed) ## The hotfix branch will be deleted from both local and remote GIT_MERGE_AUTOEDIT=no git flow hotfix finish -m `./current-version.sh` git checkout master #Bump up the version to SNAPSHOT npm version prerelease –preid=SNAPSHOT git push git checkout develop # copy the bumped version from master to develop git merge master git push | develop: 1.0.2-SNAPSHOT.0 (tag)1.0.1: 1.0.1 master: 1.0.2-SNAPSHOT.0 |
A quick summary of versions
- feature and develop branch always uses a pre-release (SNAPSHOT) version, because they are not release candidates
- release/hotfix branch always uses a release version
- master branch always uses a pre-release(SNAPSHOT) version, because
- it’s not a release candidate
- merging master to develop will lead to a pre-release version on develop branch