The aft version-bump
command uses Git history + conventional commit formatting to determine a suitable next version for a package along with the required changes for depending packages.
- Let
packages
be the set of all packages in the repo which are publishable topub.dev
. - For every package
P
inpackages
:- Let
component
be the component ofP
, if any. - Let
baseRef
be the commit of the last release ofP
. - Let
headRef
be the releaseable commit ofP
(defaults toHEAD
). - Let
history
be the list of git commits in the rangebaseRef..headRef
which affectedP
, i.e. those commits which included changes to files inP
. - Let
nextVersion = currentVersion
. - For each
commit
inhistory
:- If
commit
is a version bump (i.e.chore(version)
), ignore it. - If
commit
is a merge commit, update dependencies based on the packages changed by the commit.- The thinking here is that PRs should either be squashed into a single commit or merged as a set of independent commits capped off by a merge commit. The independent commits are isolated changes which are used to update changelogs and bump versions. The merge commit is then used solely for associating previous commits and updating constraints accordingly.
- If
commit
is a breaking change (i.e.feat(auth)!
), setbumpType = breaking
.- else if
commit
's type isfeat
, setbumpType = nonBreaking
. - else, set
bumpType = patch
.
- else if
- If
commit
is a noteworthy change (scope is one offeat
,fix
,bug
,perf
, orrevert
or it's a breaking change), setincludeInChangelog = true
. - Let
proposedVersion = currentVersion.bump(bumpType)
- Let
nextVersion = max(nextVersion, proposedVersion)
- If
nextVersion > currentVersion
:- Update
pubspec.yaml
, setversion = nextVersion
- If
includeInChangelog
:- Update
CHANGELOG.md
with an entry forcommit
.
- Update
- If
bumpType == breaking
:- For every package
Q
which directly depends onP
:- Bump the version of
Q
withbumpType = patch
andincludeInChangelog = false
. - Update
Q
's constraint onP
.
- Bump the version of
- For every package
- If
bumpType == breaking
orbumpType == nonBreaking
andcomponent != null
:- For every package
Q
incomponent
:- Bump the version of
Q
with the samebumpType
asP
andincludeInChangelog = false
.
- Bump the version of
- For every package
- Update
- If
component
has a summary package:- Update
CHANGELOG.md
in the summary package withcommit
.
- Update
- For every package
Q
which was affected bycommit
:- Update
Q
's constraint onP
usingnextVersion
.
- Update
- If
- Let