-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52283 from Expensify/andrew-android-bump
[No QA]Update to deploy HybridApp production iOS and Android using slow rollouts
- Loading branch information
Showing
23 changed files
with
774,561 additions
and
36,556 deletions.
There are no files selected for viewing
5,684 changes: 2,842 additions & 2,842 deletions
5,684
.github/actions/javascript/authorChecklist/index.js
Large diffs are not rendered by default.
Oops, something went wrong.
5,114 changes: 2,557 additions & 2,557 deletions
5,114
.github/actions/javascript/awaitStagingDeploys/index.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: 'Check Android Status' | ||
description: 'Checks the status of the Android track and calculates the rollout percentage.' | ||
inputs: | ||
GITHUB_TOKEN: | ||
description: Auth token for New Expensify Github | ||
required: true | ||
GOOGLE_KEY_FILE: | ||
description: Authentication file for Google Cloud API | ||
required: true | ||
PACKAGE_NAME: | ||
description: Package name to check the status of | ||
required: true | ||
outputs: | ||
HALTED: | ||
description: True if the app is halted, false otherwise | ||
ROLLOUT_PERCENTAGE: | ||
description: The calculated rollout percentage | ||
runs: | ||
using: 'node20' | ||
main: './index.js' |
99 changes: 99 additions & 0 deletions
99
.github/actions/javascript/checkAndroidStatus/checkAndroidStatus.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import * as core from '@actions/core'; | ||
import {google} from 'googleapis'; | ||
import CONST from '@github/libs/CONST'; | ||
import GithubUtils from '@github/libs/GithubUtils'; | ||
|
||
const PACKAGE_NAME = core.getInput('PACKAGE_NAME', {required: true}); | ||
const GOOGLE_KEY_FILE = core.getInput('GOOGLE_KEY_FILE', {required: true}); | ||
const HALTED_STATUS = 'halted'; | ||
|
||
async function checkAndroidStatus() { | ||
const auth = new google.auth.GoogleAuth({ | ||
keyFile: GOOGLE_KEY_FILE, | ||
scopes: ['https://www.googleapis.com/auth/androidpublisher'], | ||
}); | ||
|
||
const androidApi = google.androidpublisher({ | ||
version: 'v3', | ||
auth, | ||
}); | ||
|
||
try { | ||
// The Google Play API requires an edit ID to make changes to the app | ||
const editResponse = await androidApi.edits.insert({ | ||
packageName: PACKAGE_NAME, | ||
}); | ||
const editId = editResponse.data.id ?? 'undefined'; | ||
|
||
// Get the production track status | ||
const trackResponse = await androidApi.edits.tracks.get({ | ||
packageName: PACKAGE_NAME, | ||
editId, | ||
track: 'production', | ||
}); | ||
|
||
const status = trackResponse.data.releases?.[0]?.status ?? 'undefined'; | ||
console.log('Track status:', status); | ||
|
||
// Check if the status is halted | ||
const HALTED = status === HALTED_STATUS; | ||
core.setOutput('HALTED', HALTED); | ||
} catch (error) { | ||
console.error('Error checking track status:', error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
async function getLatestReleaseDate() { | ||
const {data} = await GithubUtils.octokit.repos.getLatestRelease({ | ||
owner: CONST.GITHUB_OWNER, | ||
repo: CONST.APP_REPO, | ||
}); | ||
|
||
const releaseDate = data.published_at?.split('T')[0]; | ||
if (!releaseDate) { | ||
throw new Error('Unable to retrieve the latest release date from GitHub'); | ||
} | ||
|
||
console.log('Latest release date:', releaseDate); | ||
return releaseDate; | ||
} | ||
|
||
function calculateRolloutPercentage(releaseDate: string): number { | ||
const release = new Date(releaseDate); | ||
const current = new Date(); | ||
const daysSinceRelease = Math.floor((current.getTime() - release.getTime()) / (1000 * 60 * 60 * 24)); | ||
console.log('Days since release:', daysSinceRelease); | ||
|
||
if (daysSinceRelease === 1) { | ||
return 0.01; | ||
} | ||
if (daysSinceRelease === 2) { | ||
return 0.02; | ||
} | ||
if (daysSinceRelease === 3) { | ||
return 0.05; | ||
} | ||
if (daysSinceRelease === 4) { | ||
return 0.1; | ||
} | ||
if (daysSinceRelease === 5) { | ||
return 0.2; | ||
} | ||
if (daysSinceRelease === 6) { | ||
return 0.5; | ||
} | ||
if (daysSinceRelease === 7) { | ||
return 1; | ||
} | ||
// If we did not get a valid number of days since release (1-7), return -1 | ||
return -1; | ||
} | ||
|
||
checkAndroidStatus() | ||
.then(getLatestReleaseDate) | ||
.then((releaseDate) => { | ||
const rolloutPercentage = calculateRolloutPercentage(releaseDate); | ||
console.log('Rollout percentage:', rolloutPercentage); | ||
core.setOutput('ROLLOUT_PERCENTAGE', rolloutPercentage); | ||
}); |
Oops, something went wrong.