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

[HOLD for payment 2023-11-30] Manually manage tags in bumpVersion action #1612

Merged
merged 7 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
24 changes: 20 additions & 4 deletions .github/actions/bumpVersion/bumpVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@ const exec = promisify(require('child_process').exec);
const fs = require('fs');
const core = require('@actions/core');
const github = require('@actions/github');
const {generateAndroidVersionCode, updateAndroidVersion, updateiOSVersion} = require('../../libs/nativeVersionUpdater');
const {
BUILD_GRADLE_PATH,
PLIST_PATH,
PLIST_PATH_TEST,
generateAndroidVersionCode,
updateAndroidVersion,
updateiOSVersion,
} = require('../../libs/nativeVersionUpdater');

const PACKAGE_JSON_PATH = './package.json';
const PACKAGE_LOCK_PATH = './package-lock.json';

/**
* Update the native app versions.
Expand Down Expand Up @@ -54,7 +64,7 @@ do {

if (errCount < MAX_RETRIES) {
// Determine current patch version
const {version} = JSON.parse(fs.readFileSync('./package.json'));
const {version} = JSON.parse(fs.readFileSync(PACKAGE_JSON_PATH));
const currentPatchVersion = version.split('-')[0];
console.log('Current patch version:', currentPatchVersion);

Expand Down Expand Up @@ -84,11 +94,17 @@ do {
newVersion = `${currentPatchVersion}-${highestBuildNumber + 1}`;
updateNativeVersions(newVersion);
console.log(`Setting npm version for this PR to ${newVersion}`);
return exec(`npm version ${newVersion} --force -m "Update version to ${newVersion}"`);
return exec(`npm --no-git-tag-version version ${newVersion} -m "Update version to ${newVersion}"`);
})
.then(({stdout}) => {
// NPM and native versions successfully updated - don't retry.
// NPM and native versions successfully updated, create a tag
console.log(stdout);
const addCommand = `git add ${
[PACKAGE_JSON_PATH, PACKAGE_LOCK_PATH, BUILD_GRADLE_PATH, PLIST_PATH, PLIST_PATH_TEST].join(' ')
}`;
const commitCommand = `git commit -m "Update version to ${newVersion}`;
const tagCommand = `git tag ${newVersion} && git push --tags`;
return exec(`${[addCommand, commitCommand, tagCommand].join(' && ')}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I have an opinion either way, but is there a reason for doing this in JS as opposed to in the action?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only reason would be to use the new version in the commit message and tag. However, one of the things on our project roadmap is having this action output the new version, so we could just output the new version from JS then do the git stuff in the workflow.

Copy link
Contributor

Choose a reason for hiding this comment

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

Discussed offline and I think we both agreed that moving this out of JS will make our lives and code easier in the long run

})
// eslint-disable-next-line no-loop-func
.catch(({stdout, stderr}) => {
Expand Down
28 changes: 24 additions & 4 deletions .github/actions/bumpVersion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ const exec = promisify(__nccwpck_require__(3129).exec);
const fs = __nccwpck_require__(5747);
const core = __nccwpck_require__(2186);
const github = __nccwpck_require__(5438);
const {generateAndroidVersionCode, updateAndroidVersion, updateiOSVersion} = __nccwpck_require__(322);
const {
BUILD_GRADLE_PATH,
PLIST_PATH,
PLIST_PATH_TEST,
generateAndroidVersionCode,
updateAndroidVersion,
updateiOSVersion,
} = __nccwpck_require__(322);

const PACKAGE_JSON_PATH = './package.json';
const PACKAGE_LOCK_PATH = './package-lock.json';

/**
* Update the native app versions.
Expand Down Expand Up @@ -64,7 +74,7 @@ do {

if (errCount < MAX_RETRIES) {
// Determine current patch version
const {version} = JSON.parse(fs.readFileSync('./package.json'));
const {version} = JSON.parse(fs.readFileSync(PACKAGE_JSON_PATH));
const currentPatchVersion = version.split('-')[0];
console.log('Current patch version:', currentPatchVersion);

Expand Down Expand Up @@ -94,11 +104,17 @@ do {
newVersion = `${currentPatchVersion}-${highestBuildNumber + 1}`;
updateNativeVersions(newVersion);
console.log(`Setting npm version for this PR to ${newVersion}`);
return exec(`npm version ${newVersion} --force -m "Update version to ${newVersion}"`);
return exec(`npm --no-git-tag-version version ${newVersion} -m "Update version to ${newVersion}"`);
})
.then(({stdout}) => {
// NPM and native versions successfully updated - don't retry.
// NPM and native versions successfully updated, create a tag
console.log(stdout);
const addCommand = `git add ${
[PACKAGE_JSON_PATH, PACKAGE_LOCK_PATH, BUILD_GRADLE_PATH, PLIST_PATH, PLIST_PATH_TEST].join(' ')
}`;
const commitCommand = `git commit -m "Update version to ${newVersion}`;
const tagCommand = `git tag ${newVersion} && git push --tags`;
return exec(`${[addCommand, commitCommand, tagCommand].join(' && ')}`);
})
// eslint-disable-next-line no-loop-func
.catch(({stdout, stderr}) => {
Expand Down Expand Up @@ -135,6 +151,10 @@ const BUILD_GRADLE_PATH = process.env.NODE_ENV === 'test'
const PLIST_PATH = './ios/ExpensifyCash/Info.plist';
const PLIST_PATH_TEST = './ios/ExpensifyCashTests/Info.plist';

exports.BUILD_GRADLE_PATH = BUILD_GRADLE_PATH;
exports.PLIST_PATH = PLIST_PATH;
exports.PLIST_PATH_TEST = PLIST_PATH_TEST;

/**
* Pad a number to be three digits (with leading zeros if necessary).
*
Expand Down
4 changes: 4 additions & 0 deletions .github/libs/nativeVersionUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const BUILD_GRADLE_PATH = process.env.NODE_ENV === 'test'
const PLIST_PATH = './ios/ExpensifyCash/Info.plist';
const PLIST_PATH_TEST = './ios/ExpensifyCashTests/Info.plist';

exports.BUILD_GRADLE_PATH = BUILD_GRADLE_PATH;
exports.PLIST_PATH = PLIST_PATH;
exports.PLIST_PATH_TEST = PLIST_PATH_TEST;

/**
* Pad a number to be three digits (with leading zeros if necessary).
*
Expand Down