UNPKG

10.2 kBMarkdownView Raw
1# Publishing pre-releases
2
3This recipe will walk you through a simple example that uses pre-releases to publish beta versions while working on a future major release and then make only one release on the default distribution.
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## Working on a future release
20
21We now decide to work on a future major release, which will be composed of multiple features, some of them being breaking changes. We want to publish our package for each new feature developed for test purpose, however we do not want to increment our package version or make it available to our users until all the features are developed and tested.
22
23To implement that workflow we can create the branch `beta` and commit our first feature there. When pushing that commit, **semantic-release** will publish the pre-release version `2.0.0-beta.1` on the dist-tag `@beta`. That allow us to run integration tests by installing our module with `npm install example-module@beta`. Other users installing with `npm install example-module` will still receive the version `1.0.0`.
24
25The Git history of the repository is now:
26
27```
28* feat: initial commit # => v1.0.0 on @latest
29| \
30| * feat: first feature \n\n BREAKING CHANGE: it breaks something # => v2.0.0-beta.1 on @beta
31```
32
33We can continue to work on our future release by committing and pushing other features or bug fixes on the `beta` branch. With each push, **semantic-release** will publish a new pre-release on the dist-tag `@beta`, which allow us to run our integration tests.
34
35With another feature, the Git history of the repository is now:
36
37```
38* feat: initial commit # => v1.0.0 on @latest
39| \
40| * feat: first feature \n\n BREAKING CHANGE: it breaks something # => v2.0.0-beta.1 on @beta
41| * feat: second feature # => v2.0.0-beta.2 on @beta
42```
43
44## Releasing a bug fix on the default distribution channel
45
46In the meantime we can also continue to commit changes and release updates to our users.
47
48For example, we can commit a bug fix with the message `fix: a fix` to `master`. When pushing that commit, **semantic-release** will release the version `1.0.1` on the dist-tag `@latest`.
49
50The Git history of the repository is now:
51
52```
53* feat: initial commit # => v1.0.0 on @latest
54| \
55| * feat: first feature \n\n BREAKING CHANGE: it breaks something # => v2.0.0-beta.1 on @beta
56| * feat: second feature # => v2.0.0-beta.2 on @beta
57* | fix: a fix # => v1.0.1 on @latest
58```
59
60## Working on another future release
61
62We now decide to work on another future major release, in parallel of the beta one, which will also be composed of multiple features, some of them being breaking changes.
63
64To implement that workflow we can create the branch `alpha` from the branch `beta` and commit our first feature there. When pushing that commit, **semantic-release** will publish the pre-release version `3.0.0-alpha.1` on the dist-tag `@alpha`. That allow us to run integration tests by installing our module with `npm install example-module@alpha`. Other users installing with `npm install example-module` will still receive the version `1.0.0`.
65
66The Git history of the repository is now:
67
68```
69* feat: initial commit # => v1.0.0 on @latest
70| \
71| * feat: first feature \n\n BREAKING CHANGE: it breaks something # => v2.0.0-beta.1 on @beta
72| * feat: second feature # => v2.0.0-beta.2 on @beta
73* | fix: a fix # => v1.0.1 on @latest
74| | \
75| | * feat: first feature of other release \n\n BREAKING CHANGE: it breaks something # => v3.0.0-alpha.1 on @alpha
76```
77
78We can continue to work on our future release by committing and pushing other features or bug fixes on the `alpha` branch. With each push, **semantic-release** will publish a new pre-release on the dist-tag `@alpha`, which allow us to run our integration tests.
79
80With another feature, the Git history of the repository is now:
81
82```
83* feat: initial commit # => v1.0.0 on @latest
84| \
85| * feat: first feature \n\n BREAKING CHANGE: it breaks something # => v2.0.0-beta.1 on @beta
86| * feat: second feature # => v2.0.0-beta.2 on @beta
87* | fix: a fix # => v1.0.1 on @latest
88| | \
89| | * feat: first feature of other release \n\n BREAKING CHANGE: it breaks something # => v3.0.0-alpha.1 on @alpha
90| | * feat: second feature of other release # => v3.0.0-alpha.2 on @alpha
91```
92
93## Publishing the 2.0.0 beta release to the default distribution channel
94
95Once we've developed and pushed all the feature we want to include in the future version `2.0.0` in the `beta` branch and all our tests are successful we can release it to our users.
96
97To do so we need to merge our changes made on `beta` into `master`. As `beta` and `master` branches have diverged, this merge might require to resolve conflicts.
98
99Once the conflicts are resolved and the merge commit is pushed to `master`, **semantic-release** will release the version `2.0.0` on the dist-tag `@latest`.
100
101The Git history of the repository is now:
102
103```
104* feat: initial commit # => v1.0.0 on @latest
105| \
106| * feat: first feature \n\n BREAKING CHANGE: it breaks something # => v2.0.0-beta.1 on @beta
107| * feat: second feature # => v2.0.0-beta.2 on @beta
108* | fix: a fix # => v1.0.1 on @latest
109| | \
110| | * feat: first feature of other release \n\n BREAKING CHANGE: it breaks something # => v3.0.0-alpha.1 on @alpha
111| | * feat: second feature of other release # => v3.0.0-alpha.2 on @alpha
112| /| |
113* | | Merge branch beta into master # => v2.0.0 on @latest
114```
115
116## Publishing the 3.0.0 alpha release to the beta distribution channel
117
118Now that we published our the version `2.0.0` that was previously in beta, we decide to promote the version `3.0.0` in alpha to beta.
119
120To do so we need to merge our changes made on `alpha` into `beta`. There should be no conflict as `alpha` is strictly ahead of `master`.
121
122Once the merge commit is pushed to `beta`, **semantic-release** will publish the pre-release version `3.0.0-beta.1` on the dist-tag `@beta`, which allow us to run our integration tests.
123
124The Git history of the repository is now:
125
126```
127* feat: initial commit # => v1.0.0 on @latest
128| \
129| * feat: first feature \n\n BREAKING CHANGE: it breaks something # => v2.0.0-beta.1 on @beta
130| * feat: second feature # => v2.0.0-beta.2 on @beta
131* | fix: a fix # => v1.0.1 on @latest
132| | \
133| | * feat: first feature of other release \n\n BREAKING CHANGE: it breaks something # => v3.0.0-alpha.1 on @alpha
134| | * feat: second feature of other release # => v3.0.0-alpha.2 on @alpha
135| /| |
136* | | Merge branch beta into master # => v2.0.0 on @latest
137| | /|
138| * | Merge branch alpha into beta # => v3.0.0-beta.1 on @beta
139```
140
141## Publishing the 3.0.0 beta release to the default distribution channel
142
143Once we've developed and pushed all the feature we want to include in the future version `3.0.0` in the `beta` branch and all our tests are successful we can release it to our users.
144
145To do so we need to merge our changes made on `beta` into `master`. As `beta` and `master` branches have diverged, this merge might require to resolve conflicts.
146
147Once the conflicts are resolved and the merge commit is pushed to `master`, **semantic-release** will release the version `3.0.0` on the dist-tag `@latest`.
148
149The Git history of the repository is now:
150
151```
152* feat: initial commit # => v1.0.0 on @latest
153| \
154| * feat: first feature \n\n BREAKING CHANGE: it breaks something # => v2.0.0-beta.1 on @beta
155| * feat: second feature # => v2.0.0-beta.2 on @beta
156* | fix: a fix # => v1.0.1 on @latest
157| | \
158| | * feat: first feature of other release \n\n BREAKING CHANGE: it breaks something # => v3.0.0-alpha.1 on @alpha
159| | * feat: second feature of other release # => v3.0.0-alpha.2 on @alpha
160| /| |
161* | | Merge branch beta into master # => v2.0.0 on @latest
162| | /|
163| * | Merge branch alpha into beta # => v3.0.0-beta.1 on @beta
164| /| |
165* | | Merge branch beta into master # => v3.0.0 on @latest
166```
167
168## Working on a third future release
169
170We can now start to work on a new future major release, version `4.0.0`, on the `@beta` distribution channel.
171
172To do so we first need to update the `beta` branch with all the changes from `master` (the commits `fix: a fix`). As `beta` and `master` branches have diverged, this merge might require to resolve conflicts.
173
174We can now commit our new feature on `beta`. When pushing that commit, **semantic-release** will publish the pre-release version `3.1.0-beta.1` on the dist-tag `@beta`. That allow us to run integration tests by installing our module with `npm install example-module@beta`. Other users installing with `npm install example-module` will still receive the version `3.0.0`.
175
176The Git history of the repository is now:
177
178```
179* feat: initial commit # => v1.0.0 on @latest
180| \
181| * feat: first feature \n\n BREAKING CHANGE: it breaks something # => v2.0.0-beta.1 on @beta
182| * feat: second feature # => v2.0.0-beta.2 on @beta
183* | fix: a fix # => v1.0.1 on @latest
184| | \
185| | * feat: first feature of other release \n\n BREAKING CHANGE: it breaks something # => v3.0.0-alpha.1 on @alpha
186| | * feat: second feature of other release # => v3.0.0-alpha.2 on @alpha
187| /| |
188* | | Merge branch beta into master # => v2.0.0 on @latest
189| | /|
190| * | Merge branch alpha into beta # => v3.0.0-beta.1 on @beta
191| /| |
192* | | Merge branch beta into master # => v3.0.0 on @latest
193| \| |
194| * | Merge branch master into beta
195| * | feat: new feature # => v3.1.0-beta.1 on @beta
196```