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

[No QA] Move version-bump and automerge code to its own workflow #2329

Merged
merged 27 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6f7b7a1
CreateNewVersion workflow draft
roryabraham Apr 9, 2021
19e2865
Add comment with new PR URL
roryabraham Apr 9, 2021
5c1aeb7
Merge branch 'main' into Rory-MoveVersionToItsOwnWorkflow
roryabraham Apr 16, 2021
54ad9d4
Update master to main
roryabraham Apr 16, 2021
ce6dc5d
Use createNewVersion with triggerAndWait from other workflows
roryabraham Apr 16, 2021
bee0e99
Make automerge its own subroutine
roryabraham Apr 16, 2021
61a7cf0
Update bumpVersion to use local version instead of using tags
roryabraham Apr 16, 2021
f0ca0bb
Only deploy staging once staging branch is updated
roryabraham Apr 16, 2021
ff1798f
Get rid of automerge label
roryabraham Apr 16, 2021
9c4287b
Rebuild GH actions
roryabraham Apr 16, 2021
2c3e041
Merge branch 'main' into Rory-MoveVersionToItsOwnWorkflow
roryabraham May 11, 2021
6d6014e
Fix JSON inputs formatting
roryabraham May 11, 2021
3ea9446
Merge branch 'main' into Rory-MoveVersionToItsOwnWorkflow
roryabraham May 11, 2021
424180a
Switch to home-made triggerWorkflowAndWait JS action
roryabraham May 11, 2021
1df800e
Get rid of unnecessary second job in createNewVersion
roryabraham May 11, 2021
5507989
Point auto-approve-action and automerge-action at forks
roryabraham May 11, 2021
500e983
Rebuild GH Actions
roryabraham May 11, 2021
23b8cea
Get rid of TODO and replace with note
roryabraham May 11, 2021
835e38d
Remove unused output from automerge job
roryabraham May 11, 2021
158c82d
Add automerge call to finishReleaseCycle
roryabraham May 11, 2021
477e985
Point back at original automerge-action repo
roryabraham May 11, 2021
a3b404d
Create separate workflows to update staging and production branches
roryabraham May 11, 2021
59b1edb
Replace automerge + updateStaging + updateProduction with updateProte…
roryabraham May 11, 2021
c111446
Wrap if in brackets
roryabraham May 12, 2021
71a029c
Update README
roryabraham May 12, 2021
8dfd03c
Add changedFiles validation back in
roryabraham May 12, 2021
e532838
fix outdated references to steps.bumpVersion.outputs.NEW_VERSION
roryabraham May 12, 2021
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
32 changes: 8 additions & 24 deletions .github/actions/bumpVersion/bumpVersion.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
const {promisify} = require('util');
const fs = require('fs');
const exec = promisify(require('child_process').exec);
const _ = require('underscore');
const core = require('@actions/core');
const github = require('@actions/github');
const versionUpdater = require('../../libs/versionUpdater');
const {updateAndroidVersion, updateiOSVersion, generateAndroidVersionCode} = require('../../libs/nativeVersionUpdater');

let newVersion;

/**
* Update the native app versions.
*
Expand Down Expand Up @@ -42,37 +40,23 @@ function updateNativeVersions(version) {
}
}

const octokit = github.getOctokit(core.getInput('GITHUB_TOKEN', {required: true}));
let semanticVersionLevel = core.getInput('SEMVER_LEVEL', {require: true});

if (!semanticVersionLevel || !_.find(versionUpdater.SEMANTIC_VERSION_LEVELS, v => v === semanticVersionLevel)) {
if (!semanticVersionLevel || !_.contains(versionUpdater.SEMANTIC_VERSION_LEVELS, semanticVersionLevel)) {
console.log(
`Invalid input for 'SEMVER_LEVEL': ${semanticVersionLevel}`,
`Defaulting to: ${versionUpdater.SEMANTIC_VERSION_LEVELS.BUILD}`,
);
semanticVersionLevel = versionUpdater.SEMANTIC_VERSION_LEVELS.BUILD;
}
console.log('Fetching tags from github...');
octokit.repos.listTags({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
})
.catch(githubError => core.setFailed(githubError))
.then((githubResponse) => {
// Find the highest version git tag
const tags = githubResponse.data.map(tag => tag.name);

// tags come from latest to oldest
const highestVersion = tags[0];
const {version: previousVersion} = JSON.parse(fs.readFileSync('./package.json'));
const newVersion = versionUpdater.incrementVersion(previousVersion, semanticVersionLevel);
console.log(`Previous version: ${previousVersion}`, `New version: ${newVersion}`);

console.log(`Highest version found: ${highestVersion}.`);
updateNativeVersions(newVersion);

newVersion = versionUpdater.incrementVersion(highestVersion, semanticVersionLevel);

updateNativeVersions(newVersion);
console.log(`Setting npm version for this PR to ${newVersion}`);
return exec(`npm --no-git-tag-version version ${newVersion} -m "Update version to ${newVersion}"`);
})
console.log(`Setting npm version to ${newVersion}`);
exec(`npm --no-git-tag-version version ${newVersion} -m "Update version to ${newVersion}"`)
Copy link
Contributor

Choose a reason for hiding this comment

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

You can just do "Update version to %s" here. (ref)

.then(({stdout}) => {
// NPM and native versions successfully updated, output new version
console.log(stdout);
Expand Down
Loading