semantic-release-flutter-plugin
semantic-release-flutter-plugin
fork from PalmDevs/semantic-release-flutter-plugin with old semantic-release version support without ESM import
semantic-release plugin to bump pubspec.yaml version with version code support.
Warning: Your
array configuration order for semantic-release actually matters. More explanation here.
branches
Step | Description |
---|---|
| Verify if the file in configuration exists. |
| Verify if the contents of file pubspec.yaml file is valid and updates the file's version field. |
Install
$ npm install semantic-release-flutter-plugin -D
Options
Options | Description | Default |
---|---|---|
| The path of the pubspec.yaml file |
Where is given by semantic-release or if undefined, . |
| The weight of a major version | (100 million) |
| The weight of a minor version | (100 thousand) |
| The weight of a patch version |
|
| The weight of a release channel |
|
| The weight of a prerelease number |
|
Deciding weights
The highest version code Play Store allows is
(2 billion, 100 million). Which means you'll need to configure the weights carefully. This is also very close to the 32-bit integer limit.
If you don't want to publish your app to Play Store or support 32-bit devices, the limit can be safely ignored.
The default configuration allows for:
- 21 major versions
- 1000 minor versions (in a single major version)
- 100 patch versions (in a single minor version)
- 10 release channels
- 100 prerelease builds (in a single version)
The limits are calculated by doing
, eg. if you want to calculate a minor version limit, you can do
upperNonZeroWeight / currentWeight.
majorWeight / minorWeightIf
is
upperNonZeroWeight, look for the upper weight of the
0, eg. if you set
upperWeightto
channelWeight, the formula for prerelease number limit is
0(because
patchWeight / preReleaseWeightis
patchWeight's upper limit).
channelWeight
How version codes are calculated
The weight properties in the configuration is responsible for all the computing. The plugin gets each version number and multiplies it by the weight given in configuration. There are exceptions, such as the prerelease build number which gets
removed from the number before multiplying (because the first prerelease number always is
and not
). Here are examples for the default configuration.
v1.2.3
(major)1 * 100000000
(minor)2 * 100000
(patch)3 * 1000
(sum)100000000 + 200000 + 3000 = 100203000
v1.2.4-alpha.2 (with branches configuration below)
- 1 * 100000000
- 2 * 100000
- 4 * 1000
(channel)2 * 100
(prerelease)(2 - 1) * 1
Examples
Warning: The order in the
property matters! The plugin will generate a higher version code depending on where you place your branch configuration in the
branchesarray.
branchesWhen the plugin notices a prerelease version (eg.
), it will get the index of where the prerelease branch configuration is (in this case,
v1.1.0-alpha.1, index
alpha), then it multiplies that number by the supplied the
2option (
channelWeight) and adds it to the version code number.
2 * channelWeightThis would mean that users from the
release channel wouldn't be able to downgrade to
alpha(index
beta) or the
1(index
main) channel, as the index for those is lower than the
0release channel's index.
alphaIf you want to disable this feature, set
to
channelWeight. This will also increase room for more version codes.
0
You must have 2 configuration files. One for bumping which will be run before building and one for making releases and uploading assets. You'll also need to run semantic-release twice.
(before building)
{ "branches": [ "main", { "name": "beta", "prerelease": true }, { "name": "alpha", "prerelease": true } ], "plugins": [ "@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator", [ "semantic-release-flutter-plugin", { "pubspecPath": "pubspec.yaml" } ], [ "@semantic-release/git", { "assets": [ "pubspec.yaml" ] } ] ]}