Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Commit

Permalink
chore: convert release script to js, add PR template
Browse files Browse the repository at this point in the history
(cherry picked from commit e8ca8bc)
  • Loading branch information
KaelWD committed Dec 15, 2017
1 parent 65129b9 commit faaff75
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 64 deletions.
9 changes: 5 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ Hello and thank you for interest in helping make Vuetify better. Please take a f
## IMPORTANT INFORMATION
Use https://issues.vuetifyjs.com/ for submitting new bug reports or feature requests, otherwise they will be closed immediately


## Reporting Issues
* The issue list of this repo is <strong>exclusively</strong> for bug reports and feature requests. Non-conforming issues will be closed immediately.
* For general questions, please join <a href="https://chat.vuetifyjs.com">the Discord chat room</a>.
* Try to search for your issue, it may have been answered.
* See if the error is reproduceable with the latest version.
* If reproduceable, please provide a [simple codepen](https://template.vuetifyjs.com) or repository that can be cloned to produce the expected behavior.
* If reproduceable, please provide a [simple codepen](https://template.vuetifyjs.com) or repository that can be cloned to produce the expected behavior. It is preferred that you create an initial commit with no changes first, then another one that will cause the issue.
* **Never** comment "+1" or "me too!" on issues without leaving additional information, use the :+1: button in the top right instead.

## Pull Requests
* Always work on a new branch. Making changes on your fork's `dev` or `master` branch can cause problems. (See [The beginner's guide to contributing to a GitHub project](https://akrabat.com/the-beginners-guide-to-contributing-to-a-github-project/))
* Bug fixes and non-breaking changes should be submitted to the `master` branch
* New features and breaking changes should be submitted to the `dev` branch. Be warned that this branch is unstable, and may be rebased at any time. (See [recovering from upstream rebase](https://git-scm.com/docs/git-rebase#_recovering_from_upstream_rebase))
* Bug fixes should be submitted to the `master` branch.
* New features and breaking changes should be submitted to the `dev` branch.
* Use a descriptive title no more than 64 characters long. This will be used as the commit message when your PR is merged.
* For changes and feature requests, please include an example of what you are trying to solve and an example of the markup. It is preferred that you create an issue first however, as that will allow the team to review your proposal before you start.
* Please reference the issue # that the PR resolves, something like `Fixes #1234` or `Resolves #6458` (See [closing issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
5 changes: 5 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!--
Remember to read the contributing guide first:
https://github.com/vuetifyjs/vuetify/blob/master/.github/CONTRIBUTING.md
-->

158 changes: 158 additions & 0 deletions build/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
const inquirer = require('inquirer')
const semver = require('semver')
const shell = require('shelljs')

shell.set('-e')

if (!shell.which('git')) {
shell.echo('Sorry, this script requires git')
shell.exit(1)
}

if (!shell.which('npm')) {
shell.echo('Sorry, this script requires npm')
shell.exit(1)
}

let tag
let branch = exec('git symbolic-ref --short HEAD')
const latest = exec('npm view vuetify version')
let latestGit = exec('git describe --abbrev=0 --tags')

shell.echo(`
Current branch is ${branch}
Last git version (from the current location) was ${latestGit}
Latest npm version is ${latest}
`)

promptForVersion()
.then(verifyBranch)
.then(confirmVersion)
.then(version => {
lint()
release(version)
afterRelease()
})

//============================ FUNCTIONS =============================//

function exec (command) {
const result = shell.exec(command, { silent: true })
if (result.code) {
shell.echo('')
console.error(result.stdout.trim())
shell.exit(1)
}
return result.stdout.trim()
}

function createVersionOption (name) {
const prerelease = (semver.prerelease(latestGit) || [])[0]
const version = semver.inc(latestGit, name.toLowerCase(), false, prerelease || 'beta')
return {
name: `${name} (${version})`,
value: version,
short: version
}
}

function promptForVersion () {
return inquirer.prompt({
type: 'list',
name: 'version',
message: 'Select new version:',
choices: [
createVersionOption('Major'),
createVersionOption('Minor'),
createVersionOption('Patch'),
createVersionOption('Prerelease'),
createVersionOption('Premajor'),
createVersionOption('Preminor'),
createVersionOption('Prepatch'),
{
name: 'Other',
value: 'other'
}
],
default: () => (
semver.prerelease(latestGit) == null
? createVersionOption('Patch').value
: createVersionOption('Prerelease').value
),
pageSize: 8
}).then(({ version }) => {
if (version === 'other') {
return inquirer.prompt({
type: 'input',
name: 'version',
message: 'Enter new version:',
validate: val => !!semver.valid(val) || `'${val}' is not a valid version number`,
filter: val => semver(val).version
}).then(({ version }) => version)
}
return version
})
}

function verifyBranch (version) {
tag = semver.prerelease(version) == null ? 'latest' : 'next'

if (tag === 'latest' && branch !== 'master') {
shell.echo('\nReleasing on a branch other than \'master\'')
shell.echo('This may have unintended side-effects')
return inquirer.prompt({
type: 'confirm',
name: 'yes',
message: 'Do you want to continue?',
default: false
}).then(({ yes }) => yes ? version : shell.exit(1))
}
return Promise.resolve(version)
}

function confirmVersion (version) {
shell.echo(`Releasing ${version} on ${branch}`)
shell.echo(`Tag: ${tag}`)
return inquirer.prompt({
type: 'confirm',
name: 'yes',
message: 'Are you sure?',
default: true
}).then(({ yes }) => yes ? version : shell.exit(1))
}

function lint () {
shell.exec('npm run lint')
shell.exec('npm run test')
}

function release (version) {
process.env.npm_config_commit_hooks = 'false'

shell.exec(`npm version ${version} --message "[release] ${version}"`)
if (exec(`git config branch.${branch}.remote`)) {
shell.exec(`git push --no-verify --follow-tags`)
} else {
const remote = exec(`git config branch.master.remote`)
shell.exec(`git push --no-verify --follow-tags -u ${remote}`)
}
}

function afterRelease () {
if (branch.match(/release\/.*/)) {
const previousBranch = branch
shell.exec('git checkout master')
branch = 'master'
shell.exec('git pull --ff-only')
shell.exec(`git merge ${previousBranch}`)
shell.echo(`\n\nYou can now push if there are no conflicts`)
}
}

function getBranches () {
return exec(`git for-each-ref refs/heads refs/remotes --format='%(refname)'`)
.split('\n')
.map(ref => (
/refs\/.*?\/(.*)/.exec(ref)[1]
))
}
58 changes: 0 additions & 58 deletions build/release.sh

This file was deleted.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"friendly-errors-webpack-plugin": "^1.6.1",
"function-bind": "^1.1.1",
"husky": "^0.14.3",
"inquirer": "^4.0.1",
"jest": "^21.1.0",
"jest-cli": "^21.1.0",
"jest-css-modules": "^1.1.0",
Expand All @@ -83,6 +84,7 @@
"rimraf": "^2.6.2",
"semver": "^5.4.1",
"serialize-javascript": "^1.3.0",
"shelljs": "^0.7.8",
"style-loader": "^0.18.2",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1",
Expand Down
55 changes: 53 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,10 @@ character-parser@^2.1.1:
dependencies:
is-regex "^1.0.3"

chardet@^0.4.0:
version "0.4.2"
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2"

chokidar@^1.6.0, chokidar@^1.6.1, chokidar@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468"
Expand Down Expand Up @@ -2433,6 +2437,14 @@ external-editor@^2.0.4:
jschardet "^1.4.2"
tmp "^0.0.31"

external-editor@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.1.0.tgz#3d026a21b7f95b5726387d4200ac160d372c3b48"
dependencies:
chardet "^0.4.0"
iconv-lite "^0.4.17"
tmp "^0.0.33"

extglob@^0.3.1:
version "0.3.2"
resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1"
Expand Down Expand Up @@ -2718,7 +2730,7 @@ [email protected]:
once "^1.3.0"
path-is-absolute "^1.0.0"

glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2:
glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
dependencies:
Expand Down Expand Up @@ -3041,6 +3053,25 @@ inquirer@^3.0.6:
strip-ansi "^4.0.0"
through "^2.3.6"

inquirer@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-4.0.1.tgz#b25cd541789394b4bb56f6440fb213b121149096"
dependencies:
ansi-escapes "^3.0.0"
chalk "^2.0.0"
cli-cursor "^2.1.0"
cli-width "^2.0.0"
external-editor "^2.1.0"
figures "^2.0.0"
lodash "^4.3.0"
mute-stream "0.0.7"
run-async "^2.2.0"
rx-lite "^4.0.8"
rx-lite-aggregates "^4.0.8"
string-width "^2.1.0"
strip-ansi "^4.0.0"
through "^2.3.6"

internal-ip@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/internal-ip/-/internal-ip-2.0.2.tgz#bed2b35491e8b42aee087de7614e870908ee80f2"
Expand Down Expand Up @@ -4302,7 +4333,7 @@ os-locale@^2.0.0:
lcid "^1.0.0"
mem "^1.1.0"

os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1:
os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1, os-tmpdir@~1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"

Expand Down Expand Up @@ -5098,6 +5129,12 @@ readdirp@^2.0.0:
readable-stream "^2.0.2"
set-immediate-shim "^1.0.1"

rechoir@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
dependencies:
resolve "^1.1.6"

reduce-css-calc@^1.2.6:
version "1.3.0"
resolved "https://registry.yarnpkg.com/reduce-css-calc/-/reduce-css-calc-1.3.0.tgz#747c914e049614a4c9cfbba629871ad1d2927716"
Expand Down Expand Up @@ -5432,6 +5469,14 @@ shebang-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"

shelljs@^0.7.8:
version "0.7.8"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3"
dependencies:
glob "^7.0.0"
interpret "^1.0.0"
rechoir "^0.6.2"

shellwords@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.0.tgz#66afd47b6a12932d9071cbfd98a52e785cd0ba14"
Expand Down Expand Up @@ -5834,6 +5879,12 @@ tmp@^0.0.31:
dependencies:
os-tmpdir "~1.0.1"

tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
dependencies:
os-tmpdir "~1.0.2"

[email protected]:
version "1.0.4"
resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1"
Expand Down

0 comments on commit faaff75

Please sign in to comment.