Skip to content
Merged
Show file tree
Hide file tree
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 Apr 8, 2025
58778a3
Remove redundant type check
roryabraham Apr 8, 2025
eb6d513
Use path.resolve for path constants
roryabraham Apr 8, 2025
841bd56
Add filepath constants for Mobile-Expensify subdir
roryabraham Apr 8, 2025
4f4ae97
Update Android versions in submodule
roryabraham Apr 8, 2025
38bcec8
Fix typo in replace
roryabraham Apr 9, 2025
1846351
Update Mobile-Expensify iOS PLists
roryabraham Apr 9, 2025
fc03119
Use async for updating android
roryabraham Apr 9, 2025
1038cae
Update iOS and Android in parallel
roryabraham Apr 9, 2025
74d7849
Use async for updating package.json
roryabraham Apr 9, 2025
0fb8445
Use path constant for package.json
roryabraham Apr 9, 2025
00499b4
Update npm version in parallel
roryabraham Apr 9, 2025
6a7c91a
Update Mobile-Expensify config.json
roryabraham Apr 9, 2025
c94d01c
Fix Promise.all call
roryabraham Apr 9, 2025
e4e6682
Remove top-level await and undo tsconfig.json change
roryabraham Apr 9, 2025
221ce1e
Use eval to side-step ncc, rebuild actions
roryabraham Apr 9, 2025
299c1a2
Add comments and TODOs for tomorrow
roryabraham Apr 9, 2025
6b9de71
Remove bash Mobile-Expensify version bump
roryabraham Apr 9, 2025
adfcaed
Validate actor before checkout
roryabraham Apr 9, 2025
a3e1efc
Add retry to pushes in createNewVersion
roryabraham Apr 9, 2025
54c6eed
Combine nativeVersionUpdater into bumpVersion
roryabraham Apr 9, 2025
145f51a
Fix AndroidManifest.xml versioning
roryabraham Apr 9, 2025
2493972
Remove unused imports
roryabraham Apr 9, 2025
324d8fd
Rebuild actions after clean install
roryabraham Apr 9, 2025
d1dc0d7
Merge branch 'main' into Rory-FixVersionBumpRaceConditions
roryabraham Apr 29, 2025
1857d43
Move bumpVersion to its own script
roryabraham Apr 30, 2025
19bcc4a
Fix import in bumpVersionTest
roryabraham Apr 30, 2025
1d07e90
Fix typescript types
roryabraham Apr 30, 2025
1501787
Make bumpVersion executable
roryabraham Apr 30, 2025
7bbe9a6
Fix json formatting in config.json
roryabraham Apr 30, 2025
0d971c6
Rebuild gh actions
roryabraham Apr 30, 2025
63ff5ce
Merge branch 'main' into Rory-ScriptifyBumpVersion
roryabraham Apr 30, 2025
7b2148e
Remove unused GITHUB_TOKEN input
roryabraham Apr 30, 2025
6cd7fdd
Fix absolute paths in the bundled script
roryabraham Apr 30, 2025
6ac7fbe
Fix lint
roryabraham Apr 30, 2025
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
11 changes: 4 additions & 7 deletions .github/actions/javascript/bumpVersion/action.yml
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:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was unused

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
78 changes: 15 additions & 63 deletions .github/actions/javascript/bumpVersion/bumpVersion.ts
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;
Loading