diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2bdcb26be..e05ea3169 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,7 +67,7 @@ git checkout -b master 5. Before you submit your PR: - Rebase your changes to the latest master: `git pull --rebase upstream master`. - - Ensure all unit test are green for Android and iOS. Check [running unit tests](DevelopmentWorkflow.md#running-unit-tests). + - Ensure all unit test are green for Android and iOS. Check [running unit tests](DevelopmentWorkflow.md#running-unit-tests). - Ensure your changes pass tslint validation. (run `npm run tslint` in the root of the repo). 6. Push your fork. If you have rebased you might have to use force-push your branch: @@ -223,32 +223,26 @@ Instructions how to release a new version for **NativeScript Core Team Members** ``` git checkout release ``` -2. Create a PR to cut the release: +#### If we prepare major or minor release, merge master in release branch else **skip this step**. ``` -export RELEASE_VERSION=version -export BRANCH="release-${RELEASE_VERSION}" -git checkout -b ${BRANCH} -git push --set-upstream origin ${BRANCH} +git merge --ff-only origin/master ``` -#### Merge master in release branch or cherry-pick commits. If the commits are in release branch **skip this step**. -``` -git merge --ff-only origin/master or git cherry-pick commit-sha -git push --set-upstream origin prep-release-version -``` -3. Execute `npm i` to install dependencies: +*** Note: If there are commits in release branch which are not merged in master branch '-ff-merge' command will fail. +In this case the commits should be merge firstly from release in master branch as explained in section 'Merge changes from release into master' and then repeat step 1. + +2. Execute `npm i` to install dependencies: ``` npm i ``` -4. Execute [`npm version`](https://docs.npmjs.com/cli/version) to bump the version of `tns-platform-declarations`: +3. Execute [`npm version`](https://docs.npmjs.com/cli/version) to bump the version of `tns-platform-declarations`: ``` cd tns-platform-declarations npm --no-git-tag-version version [major|minor|patch] -m "release: cut the %s release" cd .. ``` -5. Execute [`npm version`](https://docs.npmjs.com/cli/version) to bump the version of `tns-core-modules`, -tag the release and update the CHANGELOG.md. -In case we need to publish release version we need simply to use npm version x.x.x-rc +4. Execute [`npm version`](https://docs.npmjs.com/cli/version) to bump the version of `tns-core-modules`, +tag the release and update the CHANGELOG.md. Don't forget to check the auto-generated CHANGELOG.md ``` cd tns-core-modules npm --no-git-tag-version version [major|minor|patch] -m "release: cut the %s release" @@ -257,6 +251,11 @@ cd .. 6. Set correct version of **tns-core-modules-widgets** in tns-core-modules/package.json. Usually tns-core-modules-widgets should already have been released and we need to set the official version. +7. Create release-branch with change log +``` +git checkout -b release-[release-version] +``` + 7. Add changes ``` git add changed-files @@ -268,13 +267,13 @@ git push git tag release-version git push --tags ``` -9. Create a pull request. Replace env variables ${RELEASE_VERSION} and ${BRANCH} with their values +9. Create a pull request. Be careful to base your branch on the correct branch ``` -curl -d '{"title": "release: cut the ${RELEASE_VERSION} release","body": "docs: update changelog","head": "${BRANCH}","base": "release"}' -X POST https://api.github.com/repos/NativeScript/NativeScript/pulls -H "Authorization: token ${GIT_TOKEN}" +curl -d '{"title": "release: cut the [release-version] release","body": "docs: update changelog","head": "${BRANCH}","base": "release"}' -X POST https://api.github.com/repos/NativeScript/NativeScript/pulls -H "Authorization: token ${GIT_TOKEN}" ``` 10. Merge PR into release branch. -11. If all checks has passed publish package. +11. If all checks has passed publish package. Usually the night builds will be triggered and the package will be ready to be released on the next day. ## Merge changes from release into master diff --git a/build/create-release-changelog-pr.js b/build/create-release-changelog-pr.js new file mode 100644 index 000000000..409f46dda --- /dev/null +++ b/build/create-release-changelog-pr.js @@ -0,0 +1,18 @@ +const { readFileSync } = require("fs"); +const { resolve } = require("path"); +const { createPR, argsParser, gitBranch } = require("./pr-helper"); + +const currentBranch = argsParser().currentBranch || gitBranch; +const modulesPackageVersion = argsParser().packageVersion || JSON.parse(readFileSync(resolve(process.cwd(), "tns-core-modules/package.json")).toString()).version; +const title = argsParser().title || `release: cut the ${modulesPackageVersion} release`; +const baseBranch = argsParser().base || "release"; +const body = argsParser().body || "docs: update changelog"; + +const postQuery = { + "body": body, + "head": currentBranch, + "base": baseBranch, + "title": title +} + +createPR(postQuery); \ No newline at end of file diff --git a/build/merge-release-in-master-pr.js b/build/merge-release-in-master-pr.js new file mode 100644 index 000000000..7282a575d --- /dev/null +++ b/build/merge-release-in-master-pr.js @@ -0,0 +1,9 @@ +const { createPR, gitBranch } = require("./pr-helper"); + +const postQuery = { + "head": gitBranch, + "base": "master", + "title": "chore: merge release in master" +} + +createPR(postQuery); \ No newline at end of file diff --git a/build/pr-helper.js b/build/pr-helper.js new file mode 100644 index 000000000..c8dcba549 --- /dev/null +++ b/build/pr-helper.js @@ -0,0 +1,39 @@ +const { execSync } = require('child_process'); +const { writeFileSync, unlinkSync } = require("fs"); +const { resolve } = require("path"); + +exports.gitBranch = execSync("git branch").toString() + .split("\n") + .filter(f => f.trim().startsWith("*"))[0] + .replace("*", "").trim(); + +exports.createPR = (postQuery) => { + if (!process.env.GIT_TOKEN) { + console.error("Missing env variable GIT_TOKEN"); + process.exit(1); + } + const releaseDataJsonPath = resolve(process.cwd(), "git-helper.json"); + writeFileSync(releaseDataJsonPath, JSON.stringify(postQuery)); + const result = execSync(` curl -d "@${releaseDataJsonPath}" -X POST https://api.github.com/repos/NativeScript/NativeScript/pulls -H "Authorization: token ${process.env.GIT_TOKEN}" `); + console.log(result.toString()); + unlinkSync(releaseDataJsonPath); + + const requesResultJson = JSON.parse(result); + execSync(`open ${requesResultJson.html_url}`); + + return requesResultJson; +} + +exports.argsParser = () => { + args = {}; + process.argv + .filter(a => a.startsWith("--")) + .map(el => { + el = el.split("="); + const prop = el[0].replace("--", "").replace("-", "").trim(); + const value = el[1].trim(); + args[prop] = value; + }); + + return args; +} \ No newline at end of file diff --git a/merge-guidance-schema.png b/merge-guidance-schema.png index 0e83bc8fd..4bcccd2d5 100644 Binary files a/merge-guidance-schema.png and b/merge-guidance-schema.png differ diff --git a/release-contribution-guide-schema.png b/release-contribution-guide-schema.png index 625cc83c2..ddfec3335 100644 Binary files a/release-contribution-guide-schema.png and b/release-contribution-guide-schema.png differ