Skip to content
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

Add --rollout-percentage to sz deploy android #1019

Merged
merged 7 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
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