Skip to content

Commit

Permalink
Add --rollout-percentage to sz deploy android (#1019)
Browse files Browse the repository at this point in the history
This PR adds the `--rollout-percentage` to `sz deploy android`: The
percentage (between 0.0 - 1.0) of the user fraction when uploading to
the rollout track (setting to 1 will complete the rollout).

Additionally, this PR adds the parameters to `stable.yml` (default: 0.2)
and `beta.yml` (default: 1.0).
  • Loading branch information
nilsreichardt authored Sep 19, 2023
1 parent 19de772 commit 2ad1056
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ on:
Android changelog: Used for the Google Play Store release notes. If the
changelog is not provided, the deployment for Android will be skipped.
Use '\n' for line breaks.
android-rollout-percentage:
type: number
description: |
Android rollout percentage: The percentage of users that should receive
the new version.
default: "1.0"

# Set permissions to none.
#
Expand Down Expand Up @@ -205,4 +211,5 @@ jobs:
sz deploy android \
--stage beta \
--whats-new "$CHANGELOG_WITH_NEW_LINES"
--whats-new "$CHANGELOG_WITH_NEW_LINES" \
--rollout-percentage ${{ github.event.inputs.android-rollout-percentage }}
9 changes: 8 additions & 1 deletion .github/workflows/stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ on:
Android changelog: Used for the Google Play Store release notes. If the
changelog is not provided, the deployment for Android will be skipped.
Use '\n' for line breaks.
android-rollout-percentage:
type: number
description: |
Android rollout percentage: The percentage of users that should receive
the new version.
default: "0.2"

# Set permissions to none.
#
Expand Down Expand Up @@ -207,4 +213,5 @@ jobs:
sz deploy android \
--stage stable \
--whats-new "$CHANGELOG_WITH_NEW_LINES"
--whats-new "$CHANGELOG_WITH_NEW_LINES" \
--rollout-percentage ${{ github.event.inputs.android-rollout-percentage }}
1 change: 1 addition & 0 deletions app/android/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ platform :android do
track: ENV['TRACK'],
package_name: 'de.codingbrain.sharezone',
aab: '../build/app/outputs/bundle/prodRelease/app-prod-release.aab',
rollout: ENV["ROLLOUT"]
)
end
end
27 changes: 25 additions & 2 deletions tools/sz_repo_cli/lib/src/commands/src/deploy_android_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,16 @@ class DeployAndroidCommand extends Command {
allowed: _androidFlavors,
help: 'The flavor to build for. Only the "prod" flavor is supported.',
defaultsTo: 'prod',
)
..addOption(
rolloutPercentageOptionName,
help:
'The percentage (between 0.0 - 1.0) of the user fraction when uploading to the rollout track (setting to 1 will complete the rollout).',
defaultsTo: '1.0',
);
}

static const rolloutPercentageOptionName = 'rollout-percentage';
static const releaseStageOptionName = 'stage';
static const flavorOptionName = 'flavor';
static const whatsNewOptionName = 'whats-new';
Expand Down Expand Up @@ -158,13 +165,27 @@ class DeployAndroidCommand extends Command {
try {
await _setChangelog();

final track = _getGooglePlayTrackFromStage();
await _uploadToGooglePlay(track: track);
final rolloutPercentage =
argResults![rolloutPercentageOptionName] as String;
_printRolloutPercentage(rolloutPercentage);

await _uploadToGooglePlay(
track: _getGooglePlayTrackFromStage(),
rollout: rolloutPercentage,
);
} finally {
await _removeChangelogFile();
}
}

void _printRolloutPercentage(String rolloutPercentage) {
final rolloutPercentageDouble = double.parse(rolloutPercentage);
stdout.writeln(
'This release will be rolled out to: ${rolloutPercentageDouble * 100}% of users.}');
stdout.writeln(
'You can later change the rollout percentage in the Play Store Console: Go to "Production" (or Open testing or Closed Testing) -> "Releases"');
}

Future<void> _setChangelog() async {
final whatsNew = argResults![whatsNewOptionName] as String?;
if (whatsNew == null) {
Expand Down Expand Up @@ -198,13 +219,15 @@ class DeployAndroidCommand extends Command {

Future<void> _uploadToGooglePlay({
required String track,
required String rollout,
}) async {
await runProcess(
'fastlane',
['deploy'],
workingDirectory: '${_repo.sharezoneFlutterApp.location.path}/android',
environment: {
'TRACK': track,
'ROLLOUT': rollout,
},
);
}
Expand Down

0 comments on commit 2ad1056

Please sign in to comment.