Skip to content

Commit 4cc54ab

Browse files
authored
Merge pull request Expensify#52283 from Expensify/andrew-android-bump
[No QA]Update to deploy HybridApp production iOS and Android using slow rollouts
2 parents 5e52279 + 88301f9 commit 4cc54ab

File tree

23 files changed

+774561
-36556
lines changed

23 files changed

+774561
-36556
lines changed

.github/actions/javascript/authorChecklist/index.js

+2,842-2,842
Large diffs are not rendered by default.

.github/actions/javascript/awaitStagingDeploys/index.js

+2,557-2,557
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 'Check Android Status'
2+
description: 'Checks the status of the Android track and calculates the rollout percentage.'
3+
inputs:
4+
GITHUB_TOKEN:
5+
description: Auth token for New Expensify Github
6+
required: true
7+
GOOGLE_KEY_FILE:
8+
description: Authentication file for Google Cloud API
9+
required: true
10+
PACKAGE_NAME:
11+
description: Package name to check the status of
12+
required: true
13+
outputs:
14+
HALTED:
15+
description: True if the app is halted, false otherwise
16+
ROLLOUT_PERCENTAGE:
17+
description: The calculated rollout percentage
18+
runs:
19+
using: 'node20'
20+
main: './index.js'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import * as core from '@actions/core';
2+
import {google} from 'googleapis';
3+
import CONST from '@github/libs/CONST';
4+
import GithubUtils from '@github/libs/GithubUtils';
5+
6+
const PACKAGE_NAME = core.getInput('PACKAGE_NAME', {required: true});
7+
const GOOGLE_KEY_FILE = core.getInput('GOOGLE_KEY_FILE', {required: true});
8+
const HALTED_STATUS = 'halted';
9+
10+
async function checkAndroidStatus() {
11+
const auth = new google.auth.GoogleAuth({
12+
keyFile: GOOGLE_KEY_FILE,
13+
scopes: ['https://www.googleapis.com/auth/androidpublisher'],
14+
});
15+
16+
const androidApi = google.androidpublisher({
17+
version: 'v3',
18+
auth,
19+
});
20+
21+
try {
22+
// The Google Play API requires an edit ID to make changes to the app
23+
const editResponse = await androidApi.edits.insert({
24+
packageName: PACKAGE_NAME,
25+
});
26+
const editId = editResponse.data.id ?? 'undefined';
27+
28+
// Get the production track status
29+
const trackResponse = await androidApi.edits.tracks.get({
30+
packageName: PACKAGE_NAME,
31+
editId,
32+
track: 'production',
33+
});
34+
35+
const status = trackResponse.data.releases?.[0]?.status ?? 'undefined';
36+
console.log('Track status:', status);
37+
38+
// Check if the status is halted
39+
const HALTED = status === HALTED_STATUS;
40+
core.setOutput('HALTED', HALTED);
41+
} catch (error) {
42+
console.error('Error checking track status:', error);
43+
process.exit(1);
44+
}
45+
}
46+
47+
async function getLatestReleaseDate() {
48+
const {data} = await GithubUtils.octokit.repos.getLatestRelease({
49+
owner: CONST.GITHUB_OWNER,
50+
repo: CONST.APP_REPO,
51+
});
52+
53+
const releaseDate = data.published_at?.split('T')[0];
54+
if (!releaseDate) {
55+
throw new Error('Unable to retrieve the latest release date from GitHub');
56+
}
57+
58+
console.log('Latest release date:', releaseDate);
59+
return releaseDate;
60+
}
61+
62+
function calculateRolloutPercentage(releaseDate: string): number {
63+
const release = new Date(releaseDate);
64+
const current = new Date();
65+
const daysSinceRelease = Math.floor((current.getTime() - release.getTime()) / (1000 * 60 * 60 * 24));
66+
console.log('Days since release:', daysSinceRelease);
67+
68+
if (daysSinceRelease === 1) {
69+
return 0.01;
70+
}
71+
if (daysSinceRelease === 2) {
72+
return 0.02;
73+
}
74+
if (daysSinceRelease === 3) {
75+
return 0.05;
76+
}
77+
if (daysSinceRelease === 4) {
78+
return 0.1;
79+
}
80+
if (daysSinceRelease === 5) {
81+
return 0.2;
82+
}
83+
if (daysSinceRelease === 6) {
84+
return 0.5;
85+
}
86+
if (daysSinceRelease === 7) {
87+
return 1;
88+
}
89+
// If we did not get a valid number of days since release (1-7), return -1
90+
return -1;
91+
}
92+
93+
checkAndroidStatus()
94+
.then(getLatestReleaseDate)
95+
.then((releaseDate) => {
96+
const rolloutPercentage = calculateRolloutPercentage(releaseDate);
97+
console.log('Rollout percentage:', rolloutPercentage);
98+
core.setOutput('ROLLOUT_PERCENTAGE', rolloutPercentage);
99+
});

0 commit comments

Comments
 (0)