UNPKG

7.71 kBMarkdownView Raw
1# Publishing maintenance releases
2
3This recipe will walk you through a simple example that uses Git branches and distribution channels to publish fixes and features for old versions of a package.
4
5This example uses the **semantic-release** default configuration:
6- [branches](../usage/configuration.md#branches): `['+([0-9])?(.{+([0-9]),x}).x', 'master', 'next', 'next-major', {name: 'beta', prerelease: true}, {name: 'alpha', prerelease: true}]`
7- [plugins](../usage/configuration.md#plugins): `['@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator', '@semantic-release/npm', '@semantic-release/github']`
8
9## Initial release
10
11We'll start by making the first commit of the project, with the code for the initial release and the message `feat: initial commit`. When pushing that commit, on `master` **semantic-release** will release the version `1.0.0` and make it available on the default distribution channel which is the dist-tag `@latest` for npm.
12
13The Git history of the repository is:
14
15```
16* feat: initial commit # => v1.0.0 on @latest
17```
18
19## Releasing a breaking change
20
21We now decide to drop Node.js 6 support for our package, and require Node.js 8 or higher, which is a breaking change.
22
23We commit that change with the message `feat: drop Node.js 6 support \n\n BREAKING CHANGE: Node.js >= 8 required` to `master`. When pushing that commit, **semantic-release** will release the version `2.0.0` on the dist-tag `@latest`.
24
25The Git history of the repository is now:
26
27```
28* feat: initial commit # => v1.0.0 on @latest
29* feat: drop Node.js 6 support \n\n BREAKING CHANGE: Node.js >= 8 required # => v2.0.0 on @latest
30```
31
32## Releasing a feature for version 1.x users
33
34One of our users request a new feature, however they cannot migrate to Node.js 8 or higher due to corporate policies.
35
36If we were to push that feature on `master` and release it, the new version would require Node.js 8 or higher as the release would also contains the commit `feat: drop Node.js 6 support \n\n BREAKING CHANGE: Node.js >= 8 required`.
37
38Instead, we create the branch `1.x` from the tag `v1.0.0` with the command `git checkout -b 1.x v1.0.0` and we commit that feature with the message `feat: a feature` to the branch `1.x`. When pushing that commit, **semantic-release** will release the version `1.1.0` on the dist-tag `@release-1.x` so users who can't migrate to Node.js 8 or higher can benefit from it.
39
40The Git history of the repository is now:
41
42```
43* feat: initial commit # => v1.0.0 on @latest
44| \
45* | feat: drop Node.js 6 support \n\n BREAKING CHANGE: Node.js >= 8 required # => v2.0.0 on @latest
46| * feat: a feature # => v1.1.0 on @1.x
47```
48
49## Releasing a bug fix for version 1.0.x users
50
51Another user currently using version `1.0.0` reports a bug. They cannot migrate to Node.js 8 or higher and they also cannot migrate to `1.1.0` as they do not use the feature developed in `feat: a feature` and their corporate policies require to go through a costly quality insurance process for each `minor` upgrades.
52
53In order to deliver the bug fix in a `patch` release, we create the branch `1.0.x` from the tag `v1.0.0` with the command `git checkout -b 1.0.x v1.0.0` and we commit that fix with the message `fix: a fix` to the branch `1.0.x`. When pushing that commit, **semantic-release** will release the version `1.0.1` on the dist-tag `@release-1.0.x` so users who can't migrate to `1.1.x` or `2.x` can benefit from it.
54
55The Git history of the repository is now:
56
57```
58* feat: initial commit # => v1.0.0 on @latest
59| \
60* | feat: drop Node.js 6 support \n\n BREAKING CHANGE: Node.js >= 8 required # => v2.0.0 on @latest
61| | \
62| * | feat: a feature # => v1.1.0 on @1.x
63| | * fix: a fix # => v1.0.1 on @1.0.x
64```
65
66## Porting a bug fix from 1.0.x to 1.x
67
68Now that we have released a fix in version `1.0.1` we want to make it available to `1.1.x` users as well.
69
70To do so we need to merge the changes made on `1.0.x` (the commit `fix: a fix`) into the `1.x` branch. As `1.0.x` and `1.x` branches have diverged, this merge might require to resolve conflicts.
71
72Once the conflicts are resolved and the merge commit is pushed to the branch `1.x`, **semantic-release** will release the version `1.1.1` on the dist-tag `@release-1.x` which contains both our feature and bug fix.
73
74The Git history of the repository is now:
75
76```
77* feat: initial commit # => v1.0.0 on @latest
78| \
79* | feat: drop Node.js 6 support \n\n BREAKING CHANGE: Node.js >= 8 required # => v2.0.0 on @latest
80| | \
81| * | feat: a feature # => v1.1.0 on @1.x
82| | * fix: a fix # => v1.0.1 on @1.0.x
83| | /|
84| * | Merge branch 1.0.x into 1.x # => v1.1.1 on @1.x
85```
86
87## Porting bug fixes and features to master
88
89Finally we want to make both our feature and bug fix available to users using the `@latest` dist-tag.
90
91To do so we need to merge the changes made on `1.x` (the commits `feat: a feature` and `fix: a fix`) into `master`. As `1.x` and `master` branches have diverged, this merge might require to resolve conflicts.
92
93Once the conflicts are resolved and the merge commit is pushed to `master`, **semantic-release** will release the version `2.1.0` on the dist-tag `@latest` which now contains the breaking change feature, the feature and the bug fix.
94
95The Git history of the repository is now:
96
97```
98* feat: initial commit # => v1.0.0 on @latest
99| \
100* | feat: drop Node.js 6 support \n\n BREAKING CHANGE: Node.js >= 8 required # => v2.0.0 on @latest
101| | \
102| * | feat: a feature # => v1.1.0 on @1.x
103| | * fix: a fix # => v1.0.1 on @1.0.x
104| | /|
105| * | Merge branch 1.0.x into 1.x # => v1.1.1 on @1.x
106| /| |
107* | | Merge branch 1.x into master # => v2.1.0 on @latest
108```
109
110## Releasing a bug fix for version 2.1.0 users
111
112One of our users using the version `2.1.0` version reports a bug.
113
114We can simply commit the bug fix with the message `fix: another fix` to `master`. When pushing that commit, **semantic-release** will release the version `2.1.1` on the dist-tag `@latest`.
115
116The Git history of the repository is now:
117
118```
119* feat: initial commit # => v1.0.0 on @latest
120| \
121* | feat: drop Node.js 6 support \n\n BREAKING CHANGE: Node.js >= 8 required # => v2.0.0 on @latest
122| | \
123| * | feat: a feature # => v1.1.0 on @1.x
124| | * fix: a fix # => v1.0.1 on @1.0.x
125| | /|
126| * | Merge branch 1.0.x into 1.x # => v1.1.1 on @1.x
127| /| |
128* | | Merge branch 1.x into master # => v2.1.0 on @latest
129* | | fix: another fix # => v2.1.1 on @latest
130```
131
132## Porting a bug fix from master to 1.x
133
134The bug fix `fix: another fix` also affects version `1.1.1` users, so we want to port it to the `1.x` branch.
135
136To do so we need to cherry pick our fix commit made on `master` (`fix: another fix`) into `1.x` with `git checkout 1.x && git cherry-pick <sha of fix: another fix>`. As `master` and `1.x` branches have diverged, the cherry picking might require to resolve conflicts.
137
138Once the conflicts are resolved and the commit is pushed to `1.x`, **semantic-release** will release the version `1.1.2` on the dist-tag `@release-1.x` which contains `feat: a feature`, `fix: a fix` and `fix: another fix` but not `feat: drop Node.js 6 support \n\n BREAKING CHANGE: Node.js >= 8 required`.
139
140The Git history of the repository is now:
141
142```
143* feat: initial commit # => v1.0.0 on @latest
144| \
145* | feat: drop Node.js 6 support \n\n BREAKING CHANGE: Node.js >= 8 required # => v2.0.0 on @latest
146| | \
147| * | feat: a feature # => v1.1.0 on @1.x
148| | * fix: a fix # => v1.0.1 on @1.0.x
149| | /|
150| * | Merge branch 1.0.x into 1.x # => v1.1.1 on @1.x
151| /| |
152* | | Merge branch 1.x into master # => v2.1.0 on @latest
153* | | fix: another fix # => v2.1.1 on @latest
154| | |
155| * | fix: another fix # => v1.1.2 on @1.x
156```