-
Notifications
You must be signed in to change notification settings - Fork 4k
[No QA] Scriptify bump version #61152
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
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
d4a184e
Add run function to bumpVersion.ts
roryabraham 58778a3
Remove redundant type check
roryabraham eb6d513
Use path.resolve for path constants
roryabraham 841bd56
Add filepath constants for Mobile-Expensify subdir
roryabraham 4f4ae97
Update Android versions in submodule
roryabraham 38bcec8
Fix typo in replace
roryabraham 1846351
Update Mobile-Expensify iOS PLists
roryabraham fc03119
Use async for updating android
roryabraham 1038cae
Update iOS and Android in parallel
roryabraham 74d7849
Use async for updating package.json
roryabraham 0fb8445
Use path constant for package.json
roryabraham 00499b4
Update npm version in parallel
roryabraham 6a7c91a
Update Mobile-Expensify config.json
roryabraham c94d01c
Fix Promise.all call
roryabraham e4e6682
Remove top-level await and undo tsconfig.json change
roryabraham 221ce1e
Use eval to side-step ncc, rebuild actions
roryabraham 299c1a2
Add comments and TODOs for tomorrow
roryabraham 6b9de71
Remove bash Mobile-Expensify version bump
roryabraham adfcaed
Validate actor before checkout
roryabraham a3e1efc
Add retry to pushes in createNewVersion
roryabraham 54c6eed
Combine nativeVersionUpdater into bumpVersion
roryabraham 145f51a
Fix AndroidManifest.xml versioning
roryabraham 2493972
Remove unused imports
roryabraham 324d8fd
Rebuild actions after clean install
roryabraham d1dc0d7
Merge branch 'main' into Rory-FixVersionBumpRaceConditions
roryabraham 1857d43
Move bumpVersion to its own script
roryabraham 19bcc4a
Fix import in bumpVersionTest
roryabraham 1d07e90
Fix typescript types
roryabraham 1501787
Make bumpVersion executable
roryabraham 7bbe9a6
Fix json formatting in config.json
roryabraham 0d971c6
Rebuild gh actions
roryabraham 63ff5ce
Merge branch 'main' into Rory-ScriptifyBumpVersion
roryabraham 7b2148e
Remove unused GITHUB_TOKEN input
roryabraham 6cd7fdd
Fix absolute paths in the bundled script
roryabraham 6ac7fbe
Fix lint
roryabraham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,15 +1,12 @@ | ||
| name: 'Bump npm version' | ||
| description: 'Increase the application version (JS and native), based on git tags' | ||
| name: Bump npm version | ||
| description: Increase the application version (JS and native), based on git tags | ||
| inputs: | ||
| GITHUB_TOKEN: | ||
| description: Auth token for New Expensify Github | ||
| required: true | ||
| SEMVER_LEVEL: | ||
| description: Semantic Versioning Level | ||
| required: true | ||
| outputs: | ||
| NEW_VERSION: | ||
| description: The new semver version of the application, updated in the JS and native layers. | ||
| runs: | ||
| using: 'node20' | ||
| main: './index.js' | ||
| using: node20 | ||
| main: ./index.js | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,74 +1,26 @@ | ||
| import * as core from '@actions/core'; | ||
| import {exec as originalExec} from 'child_process'; | ||
| import fs from 'fs'; | ||
| import type {PackageJson} from 'type-fest'; | ||
| import {promisify} from 'util'; | ||
| import {generateAndroidVersionCode, updateAndroidVersion, updateiOSVersion} from '@github/libs/nativeVersionUpdater'; | ||
| import bumpVersion from '@scripts/bumpVersion'; | ||
| import * as versionUpdater from '@github/libs/versionUpdater'; | ||
| import type {SemverLevel} from '@github/libs/versionUpdater'; | ||
|
|
||
| const exec = promisify(originalExec); | ||
|
|
||
| /** | ||
| * Update the native app versions. | ||
| */ | ||
| function updateNativeVersions(version: string) { | ||
| console.log(`Updating native versions to ${version}`); | ||
|
|
||
| // Update Android | ||
| const androidVersionCode = generateAndroidVersionCode(version); | ||
| updateAndroidVersion(version, androidVersionCode) | ||
| .then(() => { | ||
| console.log('Successfully updated Android!'); | ||
| }) | ||
| .catch((err: string | Error) => { | ||
| console.error('Error updating Android'); | ||
| core.setFailed(err); | ||
| }); | ||
|
|
||
| // Update iOS | ||
| async function run() { | ||
| try { | ||
| const cfBundleVersion = updateiOSVersion(version); | ||
| if (typeof cfBundleVersion === 'string' && cfBundleVersion.split('.').length === 4) { | ||
| core.setOutput('NEW_IOS_VERSION', cfBundleVersion); | ||
| console.log('Successfully updated iOS!'); | ||
| } else { | ||
| core.setFailed(`Failed to set NEW_IOS_VERSION. CFBundleVersion: ${cfBundleVersion}`); | ||
| const semverLevel = core.getInput('SEMVER_LEVEL', {required: true}); | ||
| if (!versionUpdater.isValidSemverLevel(semverLevel)) { | ||
| throw new Error(`Invalid SEMVER_LEVEL ${semverLevel}`); | ||
| } | ||
| } catch (err) { | ||
| console.error('Error updating iOS'); | ||
| if (err instanceof Error) { | ||
| core.setFailed(err); | ||
| const newVersion = await bumpVersion(semverLevel); | ||
| core.setOutput('NEW_VERSION', newVersion); | ||
| } catch (e) { | ||
| if (e instanceof Error) { | ||
| core.setFailed(e); | ||
| return; | ||
| } | ||
| core.setFailed('An unknown error occurred.'); | ||
| } | ||
| } | ||
|
|
||
| let semanticVersionLevel = core.getInput('SEMVER_LEVEL', {required: true}); | ||
| if (!semanticVersionLevel || !versionUpdater.isValidSemverLevel(semanticVersionLevel)) { | ||
| semanticVersionLevel = versionUpdater.SEMANTIC_VERSION_LEVELS.BUILD; | ||
| console.log(`Invalid input for 'SEMVER_LEVEL': ${semanticVersionLevel}`, `Defaulting to: ${semanticVersionLevel}`); | ||
| if (require.main === module) { | ||
| run(); | ||
| } | ||
|
|
||
| const {version: previousVersion} = JSON.parse(fs.readFileSync('./package.json').toString()) as PackageJson; | ||
| if (!previousVersion) { | ||
| core.setFailed('Error: Could not read package.json'); | ||
| } | ||
|
|
||
| const newVersion = versionUpdater.incrementVersion(previousVersion ?? '', semanticVersionLevel as SemverLevel); | ||
| console.log(`Previous version: ${previousVersion}`, `New version: ${newVersion}`); | ||
|
|
||
| updateNativeVersions(newVersion); | ||
|
|
||
| console.log(`Setting npm version to ${newVersion}`); | ||
| exec(`npm --no-git-tag-version version ${newVersion} -m "Update version to ${newVersion}"`) | ||
| .then(({stdout}) => { | ||
| // NPM and native versions successfully updated, output new version | ||
| console.log(stdout); | ||
| core.setOutput('NEW_VERSION', newVersion); | ||
| }) | ||
| .catch(({stdout, stderr}) => { | ||
| // Log errors and retry | ||
| console.log(stdout); | ||
| console.error(stderr); | ||
| core.setFailed('An error occurred in the `npm version` command'); | ||
| }); | ||
| export default run; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was unused