Skip to content

Commit 29c785d

Browse files
authored
feat(aft): Version bump command (#2068)
* chore(aft): Make base commands sync There isn't any value with these being async since it's okay to block in this context. And sync makes everything easier to work with. commit-id:6743d9d4 * feat(aft): Changelog/version commands commit-id:0c17379d * fix(aws_common): Logger initialization Fixes an issue in logger initialization where the initial plugin is not registered to the root plugin. commit-id:063fbfe0 * fix(aft): Versioning algorithm and performance commit-id:c45852ad * chore(aft): Clean up commit-id:de10a06e * chore(aft): Update README commit-id:8261f867 * chore(aft): Update tests Expand e2e tests to incude changelog/pubspec changes commit-id:e9757240 * chore(aft): Update dependencies commit-id:4509edf2 * chore(aft): Bump dependencies commit-id:14f44d17 * chore(aft): Enforce changelog update includes commits Changelog updates should only be made with a non-empty list of commits. commit-id:4eccafce * chore(aft): Add `promptYesNo` helper commit-id:8544885f * chore(aft): Refine `isExample` Refine the definition of `isExample` to be more precise and not require workarounds. commit-id:51cc0ac0 * chore(aft): Change `aft version` to `aft version-bump` commit-id:0526b477 * chore(aft): Remove from mono_repo The package libgit2dart, while it can be used in Dart-only packages tricks pub into thinking it has a dependency on Flutter. mono_repo cannot handle this discrepancy. commit-id:ec27a8d2 * fix(aft): Publish constraints Fixes constraints around publishing checks and which packages to consider for publishing. commit-id:937ee042 * chore(aft): Publish command checks Improves publish command checks by removing `pubspec_overrides` and not splitting the pre-publish and publish commands for a package. * chore(aft): Add components and define version bump types * chore(aft): Clean up `deps` command Fix logging and merge `pub.dev` logic with `publish` * chore(aft): Add placeholders for version bump commit * chore(aft): Update logging settings * test(aft): Update e2e tests * More updates * chore(aft): More cleanup * chore(aft): Add propagation option * chore(aft): Remove `changelog` command * chore(aft): Clean up * chore(aft): Update wording in `aft.yaml` * chore(aft): Link packages before version bump * chore(aft): Follow Dart SemVer strategy Use build tag (`+`) for patch releases. * chore(aft): Fix analysis errors * fix(aft): Submodule `libgit2dart` Adds workaround for dart-lang/pub#3563 which requires using Flutter's `dart` command if a package lists a Flutter SDK constraint even if the package does not depend on Flutter. * fix(authenticator): ARB syntax Remove unncessary commas * chore(aft): Remove setup step * chore(aft): Copy libgit2 from Instead of trying to install it (since the latest version is not available in apt) * chore(aft): Reset after patch * chore(aft): Copy lib to /usr * fix(aft): `dev_dependency` conflicts When `dev_dependencies` contains versions of the published packages different than those on pub.dev (for example when using path deps or `any`), this causes issues during pre-publish verification. By simply keeping these constraints up-to-date as well, we lose nothing (since they are overridden in local development via linking), but gain stronger confidence in the pre-publish step. * chore(aft): Change workflow path for libgit2 * chore(aft): Fix tests in CI * chore(aft): Bump dependency Co-authored-by: Dillon Nys <[email protected]>
1 parent db69cce commit 29c785d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3343
-303
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ commands:
4242
- run:
4343
name: Install and set up aft
4444
command: |
45+
git submodule update --init
4546
flutter pub global activate -spath packages/aft
4647
aft bootstrap
4748
activate_pana:

.github/workflows/aft.yaml

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
# Generated with aft. To update, run: `aft generate workflows`
21
name: aft
32
on:
43
push:
54
branches:
65
- main
76
- stable
87
- next
8+
paths:
9+
- 'packages/aft/**/*.dart'
910
pull_request:
1011
paths:
1112
- 'packages/aft/**/*.dart'
12-
- 'packages/aft/**/*.yaml'
13-
- 'packages/aft/lib/**/*'
14-
- 'packages/aft/test/**/*'
15-
- '.github/workflows/dart_vm.yaml'
16-
- '.github/workflows/dart_native.yaml'
17-
- '.github/workflows/aft.yaml'
1813
schedule:
1914
- cron: "0 0 * * 0" # Every Sunday at 00:00
2015
defaults:
@@ -24,12 +19,34 @@ permissions: read-all
2419

2520
jobs:
2621
test:
27-
uses: ./.github/workflows/dart_vm.yaml
28-
with:
29-
working-directory: packages/aft
30-
native_test:
31-
if: ${{ github.event_name == 'push' }}
32-
needs: test
33-
uses: ./.github/workflows/dart_native.yaml
34-
with:
35-
working-directory: packages/aft
22+
name: Test
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Git Checkout
26+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # 3.1.0
27+
with:
28+
submodules: true
29+
30+
# Needed for `git` but only ever used locally.
31+
- name: Git Config
32+
run: |
33+
git config --global user.email "[email protected]"
34+
git config --global user.name "Amplify Flutter"
35+
36+
- name: Setup Dart
37+
uses: dart-lang/setup-dart@196f54580e9eee2797c57e85e289339f85e6779d # main
38+
with:
39+
sdk: stable
40+
41+
- name: Get Packages
42+
working-directory: packages/aft
43+
run: |
44+
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
45+
( cd external/libgit2dart; git apply ../libgit2dart.patch )
46+
dart pub upgrade
47+
mkdir linux
48+
cp external/libgit2dart/linux/*.so linux
49+
50+
- name: Run Tests
51+
working-directory: packages/aft
52+
run: dart test

.github/workflows/dart_dart2js.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ jobs:
5050
sdk: ${{ matrix.sdk }}
5151

5252
- name: Setup aft
53-
run: dart pub global activate -spath packages/aft
53+
run: |
54+
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
55+
( cd packages/aft/external/libgit2dart; git apply ../libgit2dart.patch )
56+
dart pub global activate -spath packages/aft
57+
( cd packages/aft/external/libgit2dart; git reset --hard HEAD )
5458
5559
- name: Setup Firefox
5660
if: ${{ matrix.browser == 'firefox' }}

.github/workflows/dart_ddc.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ jobs:
5454
sdk: ${{ matrix.sdk }}
5555

5656
- name: Setup aft
57-
run: dart pub global activate -spath packages/aft
57+
run: |
58+
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
59+
( cd packages/aft/external/libgit2dart; git apply ../libgit2dart.patch )
60+
dart pub global activate -spath packages/aft
61+
( cd packages/aft/external/libgit2dart; git reset --hard HEAD )
5862
5963
- name: Setup Firefox
6064
if: ${{ matrix.browser == 'firefox' }}

.github/workflows/dart_native.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ jobs:
5151
sdk: stable
5252

5353
- name: Setup aft
54-
run: dart pub global activate -spath packages/aft
54+
run: |
55+
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
56+
( cd packages/aft/external/libgit2dart; git apply ../libgit2dart.patch )
57+
dart pub global activate -spath packages/aft
58+
( cd packages/aft/external/libgit2dart; git reset --hard HEAD )
5559
5660
- name: Bootstrap
5761
id: bootstrap

.github/workflows/dart_vm.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ jobs:
4747
sdk: ${{ matrix.sdk }}
4848

4949
- name: Setup aft
50-
run: dart pub global activate -spath packages/aft
50+
run: |
51+
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
52+
( cd packages/aft/external/libgit2dart; git apply ../libgit2dart.patch )
53+
dart pub global activate -spath packages/aft
54+
( cd packages/aft/external/libgit2dart; git reset --hard HEAD )
5155
5256
- name: Bootstrap
5357
id: bootstrap

.github/workflows/flutter_vm.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ jobs:
2323
- name: Git Checkout
2424
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # 3.1.0
2525

26+
- name: Git Submodules
27+
run: git submodule update --init
28+
2629
- name: Setup Flutter
2730
uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d # 2.8.0
2831
with:

.github/workflows/smoke_test.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ jobs:
2525
runs-on: ubuntu-latest
2626
steps:
2727
- name: Git Checkout
28-
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
28+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # 3.1.0
29+
30+
- name: Git Submodules
31+
run: git submodule update --init
2932

3033
- name: Setup Dart
3134
uses: dart-lang/setup-dart@196f54580e9eee2797c57e85e289339f85e6779d # main
@@ -34,6 +37,8 @@ jobs:
3437

3538
- name: Link Packages
3639
run: |
40+
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
41+
( cd packages/aft/external/libgit2dart; git apply ../libgit2dart.patch )
3742
dart pub global activate -spath packages/aft
3843
aft link
3944

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@
1111
path = packages/smithy/goldens/smithy
1212
url = https://github.com/awslabs/smithy.git
1313
branch = main
14+
[submodule "packages/aft/external/libgit2dart"]
15+
path = packages/aft/external/libgit2dart
16+
url = https://github.com/SkinnyMind/libgit2dart.git

aft.yaml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,51 @@ dependencies:
1717
uuid: ">=3.0.6 <=3.0.7"
1818
xml: ">=6.1.0 <=6.2.2"
1919

20-
# Packages to ignore in all repo operations
20+
# Packages to ignore in all repo operations.
2121
ignore:
2222
- synthetic_package
23+
- libgit2dart
24+
25+
# Strongly connected components which should have version bumps happen
26+
# in unison, i.e. a version bump to one package cascades to all.
27+
#
28+
# By default, this happens only for minor version bumps. However, this
29+
# can be modified on a per-component basis using the `propagate` flag.
30+
components:
31+
- name: Amplify Flutter
32+
summary: amplify_flutter
33+
packages:
34+
- amplify_flutter
35+
- amplify_flutter_ios
36+
- amplify_flutter_android
37+
- amplify_core
38+
- amplify_datastore
39+
- amplify_datastore_plugin_interface
40+
- amplify_analytics_pinpoint
41+
- amplify_api
42+
- amplify_api_android
43+
- amplify_api_ios
44+
- amplify_auth_cognito
45+
- amplify_auth_cognito_android
46+
- amplify_auth_cognito_ios
47+
- amplify_storage_s3
48+
- name: Amplify Dart
49+
summary: amplify_core
50+
propagate: none
51+
packages:
52+
- amplify_auth_cognito_dart
53+
- amplify_analytics_pinpoint_dart
54+
- amplify_storage_s3_dart
55+
- name: Amplify UI
56+
packages:
57+
- amplify_authenticator
58+
- name: Smithy
59+
summary: smithy
60+
packages:
61+
- smithy
62+
- smithy_aws
63+
- name: Worker Bee
64+
summary: worker_bee
65+
packages:
66+
- worker_bee
67+
- worker_bee_builder

packages/aft/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,24 @@ A CLI tool for managing the Amplify Flutter repository.
1818
- `get`: Runs `dart pub get`/`flutter pub get` for all packages
1919
- `upgrade`: Runs `dart pub upgrade`/`flutter pub upgrade` for all packages
2020
- `publish`: Runs `dart pub publish`/`flutter pub publish` for all packages which need publishing
21+
- `version-bump`: Bumps version using git history
22+
23+
## Setup
24+
25+
To run some commands, `libgit2` is required and can be installed with the following commands:
26+
27+
```sh
28+
$ brew install libgit2
29+
```
30+
31+
```sh
32+
$ sudo apt-get install libgit2-dev
33+
```
34+
35+
To activate `aft`, run:
36+
37+
```sh
38+
$ dart pub global activate -spath packages/aft
39+
```
40+
41+
A full list of available commands and options can be found by running `aft --help`.

packages/aft/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ analyzer:
55
public_member_api_docs: ignore
66
exclude:
77
- '**/*.g.dart'
8+
- external/

packages/aft/bin/aft.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ Future<void> main(List<String> args) async {
2525
..addCommand(LinkCommand())
2626
..addCommand(CleanCommand())
2727
..addCommand(PubCommand())
28-
..addCommand(BootstrapCommand());
28+
..addCommand(BootstrapCommand())
29+
..addCommand(VersionBumpCommand());
2930
try {
3031
await runner.run(args);
3132
} on UsageException catch (e) {

packages/aft/doc/versioning.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Versioning Algorithm
2+
3+
The `aft version-bump` command uses Git history + [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) formatting to determine a suitable next version for a package along with the required changes for depending packages.
4+
5+
1. Let `packages` be the set of all packages in the repo which are publishable to `pub.dev`.
6+
2. For every package `P` in `packages`:
7+
1. Let `component` be the component of `P`, if any.
8+
2. Let `baseRef` be the commit of the last release of `P`.
9+
3. Let `headRef` be the releaseable commit of `P` (defaults to `HEAD`).
10+
4. Let `history` be the list of git commits in the range `baseRef..headRef` which affected `P`, i.e. those commits which included changes to files in `P`.
11+
5. Let `nextVersion = currentVersion`.
12+
6. For each `commit` in `history`:
13+
1. If `commit` is a version bump (i.e. `chore(version)`), ignore it.
14+
2. If `commit` is a merge commit, update dependencies based on the packages changed by the commit.
15+
1. 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.
16+
3. If `commit` is a breaking change (i.e. `feat(auth)!`), set `bumpType = breaking`.
17+
1. else if `commit`'s type is `feat`, set `bumpType = nonBreaking`.
18+
2. else, set `bumpType = patch`.
19+
4. If `commit` is a noteworthy change (scope is one of `feat`, `fix`, `bug`, `perf`, or `revert` or it's a breaking change), set `includeInChangelog = true`.
20+
5. Let `proposedVersion = currentVersion.bump(bumpType)`
21+
6. Let `nextVersion = max(nextVersion, proposedVersion)`
22+
7. If `nextVersion > currentVersion`:
23+
1. Update `pubspec.yaml`, set `version = nextVersion`
24+
2. If `includeInChangelog`:
25+
1. Update `CHANGELOG.md` with an entry for `commit`.
26+
3. If `bumpType == breaking`:
27+
1. For every package `Q` which directly depends on `P`:
28+
1. Bump the version of `Q` with `bumpType = patch` and `includeInChangelog = false`.
29+
2. Update `Q`'s constraint on `P`.
30+
4. If `bumpType == breaking` or `bumpType == nonBreaking` and `component != null`:
31+
1. For every package `Q` in `component`:
32+
1. Bump the version of `Q` with the same `bumpType` as `P` and `includeInChangelog = false`.
33+
8. If `component` has a summary package:
34+
1. Update `CHANGELOG.md` in the summary package with `commit`.
35+
9. For every package `Q` which was affected by `commit`:
36+
1. Update `Q`'s constraint on `P` using `nextVersion`.

packages/aft/external/libgit2dart

Submodule libgit2dart added at 34d492a
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
diff --git a/pubspec.yaml b/pubspec.yaml
2+
index 5acda72..2831e58 100644
3+
--- a/pubspec.yaml
4+
+++ b/pubspec.yaml
5+
@@ -8,7 +8,6 @@ homepage: https://github.com/SkinnyMind/libgit2dart
6+
7+
environment:
8+
sdk: ">=2.18.0 <3.0.0"
9+
- flutter: ">=3.3.0"
10+
11+
dependencies:
12+
args: ^2.3.0
13+
@@ -23,16 +22,6 @@ dev_dependencies:
14+
lints: ^2.0.0
15+
test: ^1.20.0
16+
17+
-flutter:
18+
- plugin:
19+
- platforms:
20+
- linux:
21+
- pluginClass: Libgit2dartPlugin
22+
- macos:
23+
- pluginClass: Libgit2dartPlugin
24+
- windows:
25+
- pluginClass: Libgit2dartPlugin
26+
-
27+
ffigen:
28+
output: "lib/src/bindings/libgit2_bindings.dart"
29+
headers:

packages/aft/lib/aft.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export 'src/commands/link_command.dart';
1212
export 'src/commands/list_packages_command.dart';
1313
export 'src/commands/pub_command.dart';
1414
export 'src/commands/publish_command.dart';
15+
export 'src/commands/version_bump_command.dart';
1516
export 'src/models.dart';
1617
export 'src/pub/pub_runner.dart';
1718
export 'src/util.dart';

0 commit comments

Comments
 (0)