Skip to content

feat(aft): Version bump command #2068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b775e2b
chore(aft): Make base commands sync
Nov 16, 2022
de1ab7b
feat(aft): Changelog/version commands
Aug 26, 2022
e44b881
fix(aws_common): Logger initialization
Aug 26, 2022
7da0a50
fix(aft): Versioning algorithm and performance
Aug 27, 2022
47b97f8
chore(aft): Clean up
Aug 27, 2022
4c1b36d
chore(aft): Update README
Aug 30, 2022
a4eb22b
chore(aft): Update tests
Aug 30, 2022
005559f
chore(aft): Update dependencies
Sep 13, 2022
4f364f2
chore(aft): Bump dependencies
Sep 15, 2022
a6a3579
chore(aft): Enforce changelog update includes commits
Sep 15, 2022
1f011c5
chore(aft): Add `promptYesNo` helper
Sep 15, 2022
a2c7470
chore(aft): Refine `isExample`
Sep 15, 2022
0dbd9f8
chore(aft): Change `aft version` to `aft version-bump`
Sep 15, 2022
8196961
chore(aft): Remove from mono_repo
Sep 16, 2022
1f6981a
fix(aft): Publish constraints
Sep 21, 2022
340e335
chore(aft): Publish command checks
Nov 16, 2022
57b4b03
chore(aft): Add components and define version bump types
Nov 16, 2022
9417e00
chore(aft): Clean up `deps` command
Nov 16, 2022
759f60f
chore(aft): Add placeholders for version bump commit
Nov 16, 2022
2257dda
chore(aft): Update logging settings
Nov 29, 2022
e32a2dc
test(aft): Update e2e tests
Nov 29, 2022
6fd0b4d
More updates
Dec 9, 2022
a82dd1a
Merge remote-tracking branch 'aws/next' into feat/aft/changlog
Dec 9, 2022
ef26f28
chore(aft): More cleanup
Dec 14, 2022
364b7ff
chore(aft): Add propagation option
Dec 15, 2022
db77a1a
chore(aft): Remove `changelog` command
Dec 15, 2022
7f71862
chore(aft): Clean up
Dec 15, 2022
1961050
Merge remote-tracking branch 'aws/next' into feat/aft/changlog
Dec 15, 2022
b2fe888
chore(aft): Update wording in `aft.yaml`
Dec 15, 2022
a48bab8
chore(aft): Link packages before version bump
dnys1 Dec 18, 2022
80cd383
chore(aft): Follow Dart SemVer strategy
dnys1 Dec 18, 2022
ae1ff5c
chore(aft): Fix analysis errors
dnys1 Dec 18, 2022
9c053cd
fix(aft): Submodule `libgit2dart`
dnys1 Dec 18, 2022
8d6234d
fix(authenticator): ARB syntax
dnys1 Dec 18, 2022
1415fb7
chore(aft): Remove setup step
dnys1 Dec 18, 2022
297f7c3
chore(aft): Copy libgit2 from
dnys1 Dec 18, 2022
018acaa
chore(aft): Reset after patch
dnys1 Dec 18, 2022
bed7229
chore(aft): Copy lib to /usr
dnys1 Dec 19, 2022
0d5a35f
fix(aft): `dev_dependency` conflicts
Jan 9, 2023
b42af79
Merge remote-tracking branch 'aws/next' into feat/aft/changlog
Jan 10, 2023
f5c7f6b
chore(aft): Change workflow path for libgit2
Jan 10, 2023
c1de801
chore(aft): Fix tests in CI
Jan 10, 2023
65b1f71
Merge remote-tracking branch 'aws/next' into feat/aft/changlog
Jan 10, 2023
2cc6576
chore(aft): Bump dependency
Jan 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ commands:
- run:
name: Install and set up aft
command: |
git submodule update --init
flutter pub global activate -spath packages/aft
aft bootstrap
activate_pana:
Expand Down
49 changes: 33 additions & 16 deletions .github/workflows/aft.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
# Generated with aft. To update, run: `aft generate workflows`
name: aft
on:
push:
branches:
- main
- stable
- next
paths:
- 'packages/aft/**/*.dart'
pull_request:
paths:
- 'packages/aft/**/*.dart'
- 'packages/aft/**/*.yaml'
- 'packages/aft/lib/**/*'
- 'packages/aft/test/**/*'
- '.github/workflows/dart_vm.yaml'
- '.github/workflows/dart_native.yaml'
- '.github/workflows/aft.yaml'
schedule:
- cron: "0 0 * * 0" # Every Sunday at 00:00
defaults:
Expand All @@ -24,12 +19,34 @@ permissions: read-all

jobs:
test:
uses: ./.github/workflows/dart_vm.yaml
with:
working-directory: packages/aft
native_test:
if: ${{ github.event_name == 'push' }}
needs: test
uses: ./.github/workflows/dart_native.yaml
with:
working-directory: packages/aft
name: Test
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # 3.1.0
with:
submodules: true

# Needed for `git` but only ever used locally.
- name: Git Config
run: |
git config --global user.email "[email protected]"
git config --global user.name "Amplify Flutter"

- name: Setup Dart
uses: dart-lang/setup-dart@196f54580e9eee2797c57e85e289339f85e6779d # main
with:
sdk: stable

- name: Get Packages
working-directory: packages/aft
run: |
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
( cd external/libgit2dart; git apply ../libgit2dart.patch )
dart pub upgrade
mkdir linux
cp external/libgit2dart/linux/*.so linux

- name: Run Tests
working-directory: packages/aft
run: dart test
6 changes: 5 additions & 1 deletion .github/workflows/dart_dart2js.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ jobs:
sdk: ${{ matrix.sdk }}

- name: Setup aft
run: dart pub global activate -spath packages/aft
run: |
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
( cd packages/aft/external/libgit2dart; git apply ../libgit2dart.patch )
dart pub global activate -spath packages/aft
( cd packages/aft/external/libgit2dart; git reset --hard HEAD )

- name: Setup Firefox
if: ${{ matrix.browser == 'firefox' }}
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/dart_ddc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ jobs:
sdk: ${{ matrix.sdk }}

- name: Setup aft
run: dart pub global activate -spath packages/aft
run: |
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
( cd packages/aft/external/libgit2dart; git apply ../libgit2dart.patch )
dart pub global activate -spath packages/aft
( cd packages/aft/external/libgit2dart; git reset --hard HEAD )

- name: Setup Firefox
if: ${{ matrix.browser == 'firefox' }}
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/dart_native.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ jobs:
sdk: stable

- name: Setup aft
run: dart pub global activate -spath packages/aft
run: |
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
( cd packages/aft/external/libgit2dart; git apply ../libgit2dart.patch )
dart pub global activate -spath packages/aft
( cd packages/aft/external/libgit2dart; git reset --hard HEAD )

- name: Bootstrap
id: bootstrap
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/dart_vm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ jobs:
sdk: ${{ matrix.sdk }}

- name: Setup aft
run: dart pub global activate -spath packages/aft
run: |
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
( cd packages/aft/external/libgit2dart; git apply ../libgit2dart.patch )
dart pub global activate -spath packages/aft
( cd packages/aft/external/libgit2dart; git reset --hard HEAD )

- name: Bootstrap
id: bootstrap
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/flutter_vm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
- name: Git Checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # 3.1.0

- name: Git Submodules
run: git submodule update --init

- name: Setup Flutter
uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d # 2.8.0
with:
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/smoke_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # 3.1.0

- name: Git Submodules
run: git submodule update --init

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

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

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
path = packages/smithy/goldens/smithy
url = https://github.com/awslabs/smithy.git
branch = main
[submodule "packages/aft/external/libgit2dart"]
path = packages/aft/external/libgit2dart
url = https://github.com/SkinnyMind/libgit2dart.git
47 changes: 46 additions & 1 deletion aft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,51 @@ dependencies:
uuid: ">=3.0.6 <=3.0.7"
xml: ">=6.1.0 <=6.2.2"

# Packages to ignore in all repo operations
# Packages to ignore in all repo operations.
ignore:
- synthetic_package
- libgit2dart

# Strongly connected components which should have version bumps happen
# in unison, i.e. a version bump to one package cascades to all.
#
# By default, this happens only for minor version bumps. However, this
# can be modified on a per-component basis using the `propagate` flag.
components:
- name: Amplify Flutter
summary: amplify_flutter
packages:
- amplify_flutter
- amplify_flutter_ios
- amplify_flutter_android
- amplify_core
- amplify_datastore
- amplify_datastore_plugin_interface
- amplify_analytics_pinpoint
- amplify_api
- amplify_api_android
- amplify_api_ios
- amplify_auth_cognito
- amplify_auth_cognito_android
- amplify_auth_cognito_ios
- amplify_storage_s3
- name: Amplify Dart
summary: amplify_core
propagate: none
packages:
- amplify_auth_cognito_dart
- amplify_analytics_pinpoint_dart
- amplify_storage_s3_dart
- name: Amplify UI
packages:
- amplify_authenticator
- name: Smithy
summary: smithy
packages:
- smithy
- smithy_aws
- name: Worker Bee
summary: worker_bee
packages:
- worker_bee
- worker_bee_builder
21 changes: 21 additions & 0 deletions packages/aft/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,24 @@ A CLI tool for managing the Amplify Flutter repository.
- `get`: Runs `dart pub get`/`flutter pub get` for all packages
- `upgrade`: Runs `dart pub upgrade`/`flutter pub upgrade` for all packages
- `publish`: Runs `dart pub publish`/`flutter pub publish` for all packages which need publishing
- `version-bump`: Bumps version using git history
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As changelog and version-bump are separate commands, the release PR will always need to contain 2 commits - one for each?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the changelog command for now - it's all one command


## Setup

To run some commands, `libgit2` is required and can be installed with the following commands:

```sh
$ brew install libgit2
```

```sh
$ sudo apt-get install libgit2-dev
```

To activate `aft`, run:

```sh
$ dart pub global activate -spath packages/aft
```

A full list of available commands and options can be found by running `aft --help`.
1 change: 1 addition & 0 deletions packages/aft/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ analyzer:
public_member_api_docs: ignore
exclude:
- '**/*.g.dart'
- external/
3 changes: 2 additions & 1 deletion packages/aft/bin/aft.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Future<void> main(List<String> args) async {
..addCommand(LinkCommand())
..addCommand(CleanCommand())
..addCommand(PubCommand())
..addCommand(BootstrapCommand());
..addCommand(BootstrapCommand())
..addCommand(VersionBumpCommand());
try {
await runner.run(args);
} on UsageException catch (e) {
Expand Down
36 changes: 36 additions & 0 deletions packages/aft/doc/versioning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Versioning Algorithm

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.

1. Let `packages` be the set of all packages in the repo which are publishable to `pub.dev`.
2. For every package `P` in `packages`:
1. Let `component` be the component of `P`, if any.
2. Let `baseRef` be the commit of the last release of `P`.
3. Let `headRef` be the releaseable commit of `P` (defaults to `HEAD`).
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`.
5. Let `nextVersion = currentVersion`.
6. For each `commit` in `history`:
1. If `commit` is a version bump (i.e. `chore(version)`), ignore it.
2. If `commit` is a merge commit, update dependencies based on the packages changed by the commit.
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.
3. If `commit` is a breaking change (i.e. `feat(auth)!`), set `bumpType = breaking`.
1. else if `commit`'s type is `feat`, set `bumpType = nonBreaking`.
2. else, set `bumpType = patch`.
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`.
5. Let `proposedVersion = currentVersion.bump(bumpType)`
6. Let `nextVersion = max(nextVersion, proposedVersion)`
7. If `nextVersion > currentVersion`:
1. Update `pubspec.yaml`, set `version = nextVersion`
2. If `includeInChangelog`:
1. Update `CHANGELOG.md` with an entry for `commit`.
3. If `bumpType == breaking`:
1. For every package `Q` which directly depends on `P`:
1. Bump the version of `Q` with `bumpType = patch` and `includeInChangelog = false`.
2. Update `Q`'s constraint on `P`.
4. If `bumpType == breaking` or `bumpType == nonBreaking` and `component != null`:
1. For every package `Q` in `component`:
1. Bump the version of `Q` with the same `bumpType` as `P` and `includeInChangelog = false`.
8. If `component` has a summary package:
1. Update `CHANGELOG.md` in the summary package with `commit`.
9. For every package `Q` which was affected by `commit`:
1. Update `Q`'s constraint on `P` using `nextVersion`.
1 change: 1 addition & 0 deletions packages/aft/external/libgit2dart
Submodule libgit2dart added at 34d492
29 changes: 29 additions & 0 deletions packages/aft/external/libgit2dart.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/pubspec.yaml b/pubspec.yaml
index 5acda72..2831e58 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -8,7 +8,6 @@ homepage: https://github.com/SkinnyMind/libgit2dart

environment:
sdk: ">=2.18.0 <3.0.0"
- flutter: ">=3.3.0"

dependencies:
args: ^2.3.0
@@ -23,16 +22,6 @@ dev_dependencies:
lints: ^2.0.0
test: ^1.20.0

-flutter:
- plugin:
- platforms:
- linux:
- pluginClass: Libgit2dartPlugin
- macos:
- pluginClass: Libgit2dartPlugin
- windows:
- pluginClass: Libgit2dartPlugin
-
ffigen:
output: "lib/src/bindings/libgit2_bindings.dart"
headers:
1 change: 1 addition & 0 deletions packages/aft/lib/aft.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export 'src/commands/link_command.dart';
export 'src/commands/list_packages_command.dart';
export 'src/commands/pub_command.dart';
export 'src/commands/publish_command.dart';
export 'src/commands/version_bump_command.dart';
export 'src/models.dart';
export 'src/pub/pub_runner.dart';
export 'src/util.dart';
Loading