Merge pull request #13 from algolia/chore/release-process
chore(release): add release process
This commit is contained in:
commit
03699cf22e
22 changed files with 10632 additions and 31 deletions
15
.travis.yml
15
.travis.yml
|
|
@ -1,16 +1,23 @@
|
|||
language: node_js
|
||||
node_js: 4
|
||||
before_install: npm prune
|
||||
before_install:
|
||||
- 'git config --global user.email "algobot@users.noreply.github.com"'
|
||||
- 'git config --global user.name "algobot"'
|
||||
- npm prune
|
||||
- rvm install 2.2.0
|
||||
- rvm use 2.2.0
|
||||
before_cache: npm prune
|
||||
install: npm install
|
||||
script: npm test
|
||||
script: ./scripts/test-ci
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
# force container based infra
|
||||
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/#Routing-your-build-to-container-based-infrastructure
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
env:
|
||||
global:
|
||||
- secure: Y2qFJk1LUqyGD38psPIOBhgokn6E+G9xOO725KvmcPkmB8B9cFHoY5+tgFeAU96QjSdcePJIISeKBGnknPljyCPQ9q49twHPduS4tT9iIN1MjSEv76C4qJ3M1P9HAV8c3RukWjqlgvDXJQNFA9xCh6Cs3aKqJfiQrJhMpSmGjZlJfsLjfss8N9Rp9gRrsRp0m0vgxKA2ASCKz6ArDl5XxfnnSjDyp487lURD83To/Wijbm+6Wrl/AZVKlEnzXNl2V1Qn62ZZbkHvD6xAbGFm5BNP9yjsFHwhr/YEhpRoINOfmDBsUQojOCZf71offXA8IQiGfwIq3Jg8+gar7aQd+EvgDiiwtzoBwvNDZw82AUfB2bHSAIFYn/RgNDmyWqN9BObKw6rM/MhqCGn+jBFHVEcHP5FtFawsM6j+4OareB03ycpkUu+nFmAvmpVenzHtbSZQtP2GnmBYoRBL+zp4O8CAOZv6VTlxYd/pwJor0yZa7ZKu/DDjfOAyTOD/tBfmvVkxGUS8tRXMBcMDdzh9I6eb/QrBPT0tHc3HLVtWmA+yBJ0B4pTZai4uzEcZFHzyIhNRxshZ36uObbxNWOa+52RKrJlsPJ35Drosdqt7O7rVFrOGH4H0aKfA+WjO7pky6rSB5oILHZdz3r2G4PIXFLpAtyV0pMUso3xk1akR2MI=
|
||||
- secure: d9QgN3kXLHwYt3w/ff0nzqVVtm+UhZ2NS7Xl6oWoEzz4518TEmTXkDjfhPGVm0tTlFm9/oNDQhg5ozIVjiPooiC0wpHUubFBI7wrzLjmxYjvFTgaN3YI+HBJJGlUU120mYtXIiP8WVnoViyceSMkXUIe7jjgeche7XLHgEgQwzR1qYfNlwMiAjEU1iCmJmiJ8Xa+QJHNAeG/RLn+6TtRCvTsIeZlWLpq+uaQH/93ehhtLVnqhaOxE7dPYQT6J1PrDb8PrwUaTqLaeEK1UDGvHJWmqSsXxHVSTMulovXBXYKGNmrk8Kk7fAT7jFdxJBsbYYMjDbIiTE9F1zh4Z39Bwl89NHj33107zjiAlv5nFpOJgHIdoL6wW1bmMoYls3Z5jrcYAHbKwWa9WqPHjW4MbW8MxbGI5t0NqWnk/XGZb96uvzhqN9zyWCNPI7G+uxjHbme0YnL7SyJ5cD+uQyGKxCSJP+/4UJJWXJF+P0dwjKj16qhhSM3XNvKjE2S+iU+/yoH6ZuaiqSz9JMbs48+gtLdc+lz8tqGauKXrj6+WJBGmzj1IZKxi85lwpwWH+9cMfqOJdUoKrENKwEkDdkfcElZGRT5QtdWcnAysIyVpk81ndmayJLv1NP/uqyctJkmfH+X1ghyiz9lennrpgP57ezZtx1u2AAVKGmIvzjWzx3o=
|
||||
|
|
|
|||
234
CONTRIBUTING.md
Normal file
234
CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
Hi (future) collaborator!
|
||||
|
||||
**tl;dr;**
|
||||
- submit pull requests to develop branch
|
||||
- use [conventional changelog](https://github.com/ajoslin/conventional-changelog/blob/master/conventions/angular.md) commit style messages
|
||||
- squash your commits
|
||||
- have fun
|
||||
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||
**Table of Contents**
|
||||
|
||||
- [Where to start?](#where-to-start)
|
||||
- [Development workflow](#development-workflow)
|
||||
- [Adding/Updating a package](#addingupdating-a-package)
|
||||
- [Removing a package](#removing-a-package)
|
||||
- [Commit message guidelines](#commit-message-guidelines)
|
||||
- [Revert](#revert)
|
||||
- [Type](#type)
|
||||
- [Scope](#scope)
|
||||
- [Subject](#subject)
|
||||
- [Body](#body)
|
||||
- [Footer](#footer)
|
||||
- [Stash your commits](#stash-your-commits)
|
||||
- [When are issues closed?](#when-are-issues-closed)
|
||||
- [Milestones](#milestones)
|
||||
- [Releasing](#releasing)
|
||||
- [Beta releases](#beta-releases)
|
||||
- [Hotfixes](#hotfixes)
|
||||
- [Releasing hotfixes](#releasing-hotfixes)
|
||||
- [Documentation updates](#documentation-updates)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
|
||||
# Where to start?
|
||||
|
||||
Have a fix or a new feature? [Search for corresponding issues](https://github.com/algolia/docsearch/issues) first then create a new one.
|
||||
|
||||
Always check the status of the [develop branch](https://github.com/algolia/docsearch/tree/develop) for the freshest code.
|
||||
|
||||
Always submit pull requests to the develop branch.
|
||||
|
||||
# Development workflow
|
||||
|
||||
## Local example
|
||||
|
||||
We use a simple documentation example website as a way to develop the docsearch.js library.
|
||||
|
||||
Requirements:
|
||||
- [Node.js](https://nodejs.org/en/)
|
||||
- npm@2
|
||||
|
||||
```sh
|
||||
npm run dev
|
||||
# open http://localhost:8080
|
||||
```
|
||||
|
||||
## Documentation website
|
||||
|
||||
This is the [Jekyll](https://jekyllrb.com/) instance running at https://community.algolia.com/docsearch.
|
||||
|
||||
Requirements:
|
||||
- [Ruby](https://www.ruby-lang.org/en/)
|
||||
- [Bundler](http://bundler.io/)
|
||||
|
||||
```sh
|
||||
npm run dev:docs
|
||||
# open http://localhost:4000/docsearch/
|
||||
```
|
||||
|
||||
# Adding/Updating a package
|
||||
|
||||
We use a [specific shrinkwrapping tool](https://github.com/uber/npm-shrinkwrap) and npm@2.
|
||||
|
||||
```sh
|
||||
npm install
|
||||
npm install package --save[-dev]
|
||||
npm run shrinkwrap
|
||||
```
|
||||
|
||||
# Removing a package
|
||||
|
||||
```sh
|
||||
npm install
|
||||
npm remove package --save[-dev]
|
||||
npm run shrinkwrap
|
||||
```
|
||||
|
||||
Removing packages can be really tricky to handle if the package was used by
|
||||
both the host project and sub dependencies.
|
||||
|
||||
# In case of shrinkwrap madness
|
||||
|
||||
```sh
|
||||
rm -rf node_modules
|
||||
rm npm-shrinkwrap.json
|
||||
npm cache clean
|
||||
npm install
|
||||
# check everything is working
|
||||
npm run shrinkwrap
|
||||
```
|
||||
|
||||
Don't do this too often because it breaks the whole shrinkwrap idea. Since
|
||||
you are completely rebuilding the dependency tree and possibly updating things.
|
||||
|
||||
# Commit message guidelines
|
||||
|
||||
We use [conventional changelog](https://github.com/ajoslin/conventional-changelog) to generate our changelog from our git commit messages.
|
||||
|
||||
Here are the rules to write commit messages, they are the same than [angular/angular.js](https://github.com/angular/angular.js/blob/7c792f4cc99515ac27ed317e0e35e40940b3a400/CONTRIBUTING.md#commit-message-format).
|
||||
|
||||
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
|
||||
format that includes a **type**, a **scope** and a **subject**:
|
||||
|
||||
```text
|
||||
<type>(<scope>): <subject>
|
||||
<BLANK LINE>
|
||||
<body>
|
||||
<BLANK LINE>
|
||||
<footer>
|
||||
```
|
||||
|
||||
The **header** is mandatory and the **scope** of the header is optional.
|
||||
|
||||
Any line of the commit message cannot be longer 100 characters! This allows the message to be easier
|
||||
to read on GitHub as well as in various git tools.
|
||||
|
||||
## Revert
|
||||
If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.
|
||||
|
||||
## Type
|
||||
Must be one of the following:
|
||||
|
||||
* **feat**: A new feature
|
||||
* **fix**: A bug fix
|
||||
* **docs**: Documentation only changes
|
||||
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing
|
||||
semi-colons, etc)
|
||||
* **refactor**: A code change that neither fixes a bug nor adds a feature
|
||||
* **perf**: A code change that improves performance
|
||||
* **test**: Adding missing tests
|
||||
* **chore**: Changes to the build process or auxiliary tools and libraries such as documentation
|
||||
generation
|
||||
|
||||
## Scope
|
||||
The scope could be anything specifying place of the commit change. For example `RefinementList`,
|
||||
`refinementList`, `rangeSlider`, `CI`, `url`, `build` etc...
|
||||
|
||||
## Subject
|
||||
The subject contains succinct description of the change:
|
||||
|
||||
* use the imperative, present tense: "change" not "changed" nor "changes"
|
||||
* don't capitalize first letter
|
||||
* no dot (.) at the end
|
||||
|
||||
## Body
|
||||
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
|
||||
The body should include the motivation for the change and contrast this with previous behavior.
|
||||
|
||||
## Footer
|
||||
The footer should contain any information about **Breaking Changes** and is also the place to
|
||||
reference GitHub issues that this commit **Closes**.
|
||||
|
||||
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
|
||||
|
||||
# Stash your commits
|
||||
|
||||
Once you are done with a fix or feature and the review was done, [squash](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) your commits to avoid things like "fix dangling comma in bro.js", "fix after review"
|
||||
|
||||
Example:
|
||||
- `feat(widget): new feature blabla..`
|
||||
- `refactor new feature blablabla...`
|
||||
- `fix after review ...`
|
||||
- **both commits should be squashed* in a single commit: `feat(widget) ..`
|
||||
|
||||
# When are issues closed?
|
||||
|
||||
Once the a fix is done, having the fix in the `develop` branch is not sufficient, it needs to be part of a release for us to close the issue.
|
||||
|
||||
So that you never ask yourself "Is this released?".
|
||||
|
||||
Instead of closing the issue, we will add a ` ✔ to be released` label.
|
||||
|
||||
# Releasing
|
||||
|
||||
If you are a maintainer, you can release.
|
||||
|
||||
We use [semver](http://semver-ftw.org/).
|
||||
|
||||
You must be on the master branch.
|
||||
|
||||
```sh
|
||||
npm run release
|
||||
```
|
||||
|
||||
This task will merge develop into master.
|
||||
|
||||
## Beta releases
|
||||
|
||||
You must be on the develop branch.
|
||||
|
||||
```sh
|
||||
npm run release:beta
|
||||
```
|
||||
|
||||
This task will release a beta version of what is currently in develop branch.
|
||||
|
||||
It will not update the `latest` tag of the npm release nor update jsDelivr /1/.
|
||||
|
||||
# Hotfixes
|
||||
|
||||
All our work is done on the develop branch but it could be necessary to push a hotfix to the master
|
||||
branch and do a patch release. To fix a very important bug.
|
||||
|
||||
For this, you should:
|
||||
- add `hotfix` to the commit message **body**
|
||||
- submit your pull request to the master branch
|
||||
|
||||
## Releasing hotfixes
|
||||
|
||||
You must be on the master branch.
|
||||
|
||||
This task will not merge develop in master, only release current master.
|
||||
|
||||
```sh
|
||||
HOTFIX=1 npm run release
|
||||
```
|
||||
|
||||
## Documentation updates
|
||||
|
||||
If you have important documentation update to release without wanting to release
|
||||
a new version of docsearch, you can do a documentation hotfix.
|
||||
|
||||
Then once the hotfix is merged into master, the documentation will be updated automatically.
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# docsearch.js
|
||||
# docsearch
|
||||
|
||||
Add a search autocomplete to any documentation.
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ with default CSS styling of the dropdown.
|
|||
|
||||
The indexing of the website data itself is currently done by an internal tool (to be released).
|
||||
|
||||
Indexing of docsearch.js linked websites takes places every day.
|
||||
Indexing of websites using docsearch takes places every day.
|
||||
|
||||
# Development workflow
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ npm run dev
|
|||
|
||||
## Documentation website
|
||||
|
||||
This is the [Jekyll](https://jekyllrb.com/) instance running at https://community.algolia.com/docsearch.js.
|
||||
This is the [Jekyll](https://jekyllrb.com/) instance running at https://community.algolia.com/docsearch.
|
||||
|
||||
Requirements:
|
||||
- [Ruby](https://www.ruby-lang.org/en/)
|
||||
|
|
@ -67,7 +67,7 @@ Requirements:
|
|||
|
||||
```sh
|
||||
npm run dev:docs
|
||||
# open http://localhost:4000/docsearch.js/
|
||||
# open http://localhost:4000/docsearch/
|
||||
```
|
||||
|
||||
## MacOS
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Site settings
|
||||
title: Documentation Search
|
||||
description: Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum quod hic qui, possimus ab ratione illo reiciendis nostrum sit aperiam debitis enim illum sequi reprehenderit porro error, sint earum rem!
|
||||
baseurl: "/docsearch.js" # the subpath of your site, e.g. /blog/
|
||||
baseurl: "/docsearch" # the subpath of your site, e.g. /blog/
|
||||
twitter_username: algolia
|
||||
github_username: algolia
|
||||
host: 0.0.0.0
|
||||
|
|
|
|||
|
|
@ -40,4 +40,4 @@ layout: default
|
|||
%p Lorem ipsum dolor sit amet, consectetur adipisicing elit. In, sit, veritatis tempora ipsum, provident fugiat quas, eum dicta architecto
|
||||
|
||||
|
||||
%p Here are some examples of what you could build with docsearch.js.
|
||||
%p Here are some examples of what you could build with docsearch.
|
||||
|
|
|
|||
9986
npm-shrinkwrap.json
generated
Normal file
9986
npm-shrinkwrap.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -7,19 +7,19 @@
|
|||
"dev": "./scripts/dev",
|
||||
"dev:docs": "./scripts/dev-docs",
|
||||
"shrinkwrap": "npm-shrinkwrap --dev",
|
||||
"prepublish": "NODE_ENV=production npm run build",
|
||||
"doctoc": "doctoc --maxlevel 3 README.md CONTRIBUTING.md",
|
||||
"build": "./scripts/build",
|
||||
"build:css": "./scripts/build-css",
|
||||
"build:js": "./scripts/build-js",
|
||||
"release": "./scripts/release",
|
||||
"release:beta": "./scripts/release-beta",
|
||||
"lint": "eslint .",
|
||||
"test": "BABEL_ENV=test mocha --reporter dot",
|
||||
"test:watch": "BABEL_ENV=test mocha --reporter min --watch",
|
||||
"gh-pages": "./scripts/gh-pages"
|
||||
"test:watch": "BABEL_ENV=test mocha --reporter min --watch"
|
||||
},
|
||||
"author": "Algolia <support@algolia.com> (https://github.com/algolia/)",
|
||||
"license": "MIT",
|
||||
"repository": "algolia/docsearch.js",
|
||||
"repository": "algolia/docsearch",
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^6.1.2",
|
||||
"babel": "^5.8.29",
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@
|
|||
|
||||
set -e # exit when error
|
||||
|
||||
VERSION=$(json version < package.json)
|
||||
NAME='docsearch.js'
|
||||
LICENSE="/*! ${NAME} ${VERSION:-UNRELEASED} | © Algolia | github.com/algolia/docsearch.js */"
|
||||
NAME='docsearch'
|
||||
LICENSE="/*! ${NAME} ${VERSION:-UNRELEASED} | © Algolia | github.com/algolia/docsearch */"
|
||||
DIST_DIR="dist/cdn"
|
||||
DIST_FILE="$DIST_DIR/${NAME}.css"
|
||||
DIST_FILE_MIN="$DIST_DIR/${NAME}.min.css"
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@
|
|||
|
||||
set -e # exit when error
|
||||
|
||||
VERSION=$(json version < package.json)
|
||||
NAME='docsearch.js'
|
||||
LICENSE="/*! ${NAME} ${VERSION:-UNRELEASED} | © Algolia | github.com/algolia/docsearch.js */"
|
||||
NAME='docsearch'
|
||||
LICENSE="/*! ${NAME} ${VERSION:-UNRELEASED} | © Algolia | github.com/algolia/docsearch */"
|
||||
DIST_DIR_CDN="dist/cdn"
|
||||
DIST_DIR_NPM="dist/npm"
|
||||
DIST_FILE="$DIST_DIR_CDN/${NAME}.js"
|
||||
|
|
|
|||
32
scripts/bump-package-version.js
Normal file
32
scripts/bump-package-version.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import mversion from 'mversion';
|
||||
|
||||
import semver from 'semver';
|
||||
import currentVersion from '../src/lib/version.js';
|
||||
|
||||
if (!process.env.VERSION) {
|
||||
throw new Error('bump: Usage is VERSION=MAJOR.MINOR.PATCH scripts/bump-package-version.js');
|
||||
}
|
||||
let newVersion = process.env.VERSION;
|
||||
|
||||
if (!semver.valid(newVersion)) {
|
||||
throw new Error('bump: Provided new version (' + newVersion + ') is not a valid version per semver');
|
||||
}
|
||||
|
||||
if (semver.gte(currentVersion, newVersion)) {
|
||||
throw new Error('bump: Provided new version is not higher than current version (' + newVersion + ' <= ' + currentVersion + ')');
|
||||
}
|
||||
|
||||
console.log('Bumping ' + newVersion);
|
||||
|
||||
console.log('..Updating src/lib/version.js');
|
||||
|
||||
let versionFile = path.join(__dirname, '../src/lib/version.js');
|
||||
let newContent = "export default '" + newVersion + "';\n";
|
||||
fs.writeFileSync(versionFile, newContent);
|
||||
|
||||
console.log('..Updating package.json, npm-shrinwrap.json');
|
||||
|
||||
mversion.update(newVersion);
|
||||
27
scripts/docs/gh-pages.js
Normal file
27
scripts/docs/gh-pages.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import ghpages from 'gh-pages';
|
||||
import {join} from 'path';
|
||||
|
||||
let basePath = join(__dirname, '../../docs/_site');
|
||||
|
||||
ghpages.clean();
|
||||
|
||||
if (process.env.CI === 'true') {
|
||||
ghpages.publish(basePath, {
|
||||
repo: 'https://' + process.env.GH_TOKEN + '@github.com/algolia/docsearch.git',
|
||||
logger: log
|
||||
}, end);
|
||||
} else {
|
||||
ghpages.publish(basePath, {logger: log}, end);
|
||||
}
|
||||
|
||||
function end(err) {
|
||||
if (err) {
|
||||
throw err;
|
||||
} else {
|
||||
console.log('published gh-pages');
|
||||
}
|
||||
}
|
||||
|
||||
function log(msg) {
|
||||
console.log(msg);
|
||||
}
|
||||
33
scripts/docs/update-website
Executable file
33
scripts/docs/update-website
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
set -ev # exit when error
|
||||
|
||||
if [ -z $TRAVIS_BRANCH ]; then
|
||||
currentBranch=`git rev-parse --abbrev-ref HEAD`
|
||||
else
|
||||
currentBranch=$TRAVIS_BRANCH
|
||||
fi
|
||||
|
||||
if [ $currentBranch != 'master' ]; then
|
||||
printf "update-website: You must be on master"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VERSION=`cat package.json | json version`
|
||||
|
||||
set -e # exit when error
|
||||
|
||||
printf "\nPublish website to gh-pages\n"
|
||||
|
||||
cd docs
|
||||
bundle install
|
||||
rm -rf _site
|
||||
JEKYLL_ENV=production VERSION=${VERSION} bundle exec jekyll build
|
||||
for example in _site/examples/*; do
|
||||
if [ -d "$example" ]; then
|
||||
name=`basename "$example"`
|
||||
(cd "$example" && zip -r ../$name.zip *)
|
||||
fi
|
||||
done
|
||||
cd ..
|
||||
babel-node scripts/docs/gh-pages.js
|
||||
26
scripts/finish-release
Executable file
26
scripts/finish-release
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#! /usr/bin/env bash
|
||||
[ -z $CI ] && CI='false'
|
||||
|
||||
if [ $CI != 'true' ]; then
|
||||
printf "finish-release: Only doable on CI\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -ev # exit when error
|
||||
|
||||
VERSION=`cat package.json | json version`
|
||||
JSDELIVER_URL="http://cdn.jsdelivr.net/docsearch.js/$VERSION/docsearch.min.js"
|
||||
|
||||
while true; do
|
||||
STATUS=$(curl -L -I $JSDELIVER_URL 2>/dev/null | head -n 1 | cut -d$' ' -f2);
|
||||
if [ $STATUS == '200' ]; then
|
||||
printf "$VERSION is now available on jsDelivr\n"
|
||||
break;
|
||||
else
|
||||
printf "$VERSION is not yet published on jsDelivr, retrying in 30s (status was $STATUS)\n"
|
||||
fi
|
||||
sleep 30
|
||||
done
|
||||
|
||||
curl --silent -L $CACHE_URL > /dev/null
|
||||
./scripts/docs/update-website.sh
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
rm -rf node_modules/gh-pages/.cache
|
||||
|
||||
cd ./docs
|
||||
bundle install
|
||||
bundle exec jekyll build
|
||||
gh-pages --dist docs/_site --branch gh-pages
|
||||
|
|
@ -1,11 +1,96 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
[ -z $HOTFIX ] && HOTFIX='0'
|
||||
|
||||
set -e # exit when error
|
||||
|
||||
mversion "${SEMVER_TOKEN:-PLEASE_PROVIDE_A_SEMVER_TOKEN_LIKE_MAJOR_MINOR_PATCH}"
|
||||
if [[ -n $(npm owner add `npm whoami`) ]]; then
|
||||
printf "Release: Not an owner of the npm repo, ask for it"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
currentBranch=`git rev-parse --abbrev-ref HEAD`
|
||||
if [ $currentBranch != 'master' ]; then
|
||||
printf "Release: You must be on master"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n $(git status --porcelain) ]]; then
|
||||
printf "Release: Working tree is not clean (git status)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "\n\nRelease: update working tree"
|
||||
git pull origin master
|
||||
git fetch origin --tags
|
||||
|
||||
if [ $HOTFIX == '0' ]; then
|
||||
printf "\n\nRelease: merge develop branch"
|
||||
git fetch origin develop
|
||||
git merge origin/develop
|
||||
fi
|
||||
|
||||
printf "Release: npm install"
|
||||
npm install
|
||||
|
||||
currentVersion=`cat package.json | json version`
|
||||
|
||||
# header
|
||||
printf "\n\nRelease: current version is $currentVersion"
|
||||
printf "\nRelease: a changelog will be generated only if a fix/feat/performance/breaking token is found in git log"
|
||||
printf "\nRelease: you must choose a new ve.rs.ion (semver)"
|
||||
printf "\nRelease: press q to exit the next screen\n\n"
|
||||
|
||||
# preview changelog
|
||||
read -p "=> Release: press [ENTER] to view changes since latest version.."
|
||||
|
||||
# nd (markdown renderer in terminal)
|
||||
# has some output going on to stderr because of node v4, no big deal
|
||||
conventional-changelog -p angular | nd | less -r 2>/dev/null
|
||||
|
||||
# choose and bump new version
|
||||
# printf "\n\nRelease: Please enter the new chosen version > "
|
||||
printf "\n=> Release: please type the new chosen version > "
|
||||
read -e newVersion
|
||||
VERSION=$newVersion babel-node ./scripts/bump-package-version.js
|
||||
|
||||
# build new version
|
||||
NODE_ENV=production VERSION=$newVersion npm run build
|
||||
|
||||
# update changelog
|
||||
printf "\n\nRelease: update changelog"
|
||||
changelog=`conventional-changelog -p angular`
|
||||
conventional-changelog -p angular -i CHANGELOG.md -w
|
||||
doctoc --maxlevel 3 README.md
|
||||
git commit -am "$(json version < package.json)"
|
||||
|
||||
# regenerate readme TOC
|
||||
printf "\n\nRelease: generate TOCS"
|
||||
npm run doctoc
|
||||
|
||||
# regenerate widgets jsdoc
|
||||
printf "\n\nRelease: regenerate widgets jsdoc"
|
||||
npm run docs:jsdoc
|
||||
|
||||
# git add and tag
|
||||
commitMessage="v$newVersion\n\n$changelog"
|
||||
git add src/lib/version.js npm-shrinkwrap.json package.json CHANGELOG.md README.md docs/_includes/widget-jsdoc
|
||||
printf "$commitMessage" | git commit --file -
|
||||
git tag "v$newVersion"
|
||||
|
||||
printf "\n\nRelease: almost done, check everything in another terminal tab.\n"
|
||||
read -p "=> Release: when ready, press [ENTER] to push to github and publish the package"
|
||||
|
||||
printf "\n\nRelease: push to github, publish on npm"
|
||||
git push origin master
|
||||
git push origin --tags
|
||||
npm publish
|
||||
# also update beta
|
||||
npm publish --tag beta
|
||||
git checkout develop
|
||||
git pull origin develop
|
||||
git merge master
|
||||
git push origin develop
|
||||
git checkout master
|
||||
|
||||
printf "Release:
|
||||
Package was published to npm.
|
||||
A job on travis-ci will be automatically launched to finalize the release."
|
||||
|
|
|
|||
88
scripts/release-beta
Executable file
88
scripts/release-beta
Executable file
|
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e # exit when error
|
||||
|
||||
if [[ -n $(npm owner add `npm whoami`) ]]; then
|
||||
printf "Beta release: Not an owner of the npm repo, ask for it"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
currentBranch=`git rev-parse --abbrev-ref HEAD`
|
||||
if [ $currentBranch != 'develop' ]; then
|
||||
printf "Beta release: You must be on develop"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n $(git status --porcelain) ]]; then
|
||||
printf "Beta release: Working tree is not clean (git status)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "\n\nBeta release: update working tree"
|
||||
git pull origin develop
|
||||
git fetch origin --tags
|
||||
|
||||
printf "Beta release: npm install"
|
||||
npm install
|
||||
|
||||
currentVersion=`cat package.json | json version`
|
||||
|
||||
# if not on a beta version already
|
||||
if [[ $currentVersion != *"-beta"* || $CHOOSE_BUMP ]]
|
||||
then
|
||||
# header
|
||||
printf "\n\nBeta release: current version is $currentVersion"
|
||||
printf "\nBeta release: a changelog will be generated only if a fix/feat/performance/breaking token is found in git log"
|
||||
printf "\nBeta release: you must choose a new ve.rs.ion (semver)"
|
||||
printf "\nBeta release: press q to exit the next screen\n\n"
|
||||
|
||||
# preview changelog
|
||||
read -p "=> Beta release: press [ENTER] to view changes since latest version.."
|
||||
|
||||
# nd (markdown renderer in terminal)
|
||||
# has some output going on to stderr because of node v4, no big deal
|
||||
conventional-changelog -p angular | nd | less -r 2>/dev/null
|
||||
|
||||
# choose and bump new version
|
||||
# printf "\n\nBeta release: Please enter the new chosen version > "
|
||||
printf "\n=> Beta release: please type the new chosen version (-beta will be automatically appended) > "
|
||||
read -e newVersion
|
||||
newVersion="$newVersion-beta.0"
|
||||
else
|
||||
# when already on a beta version, let's bump the beta-.X
|
||||
newVersion=`semver ${currentVersion} -i prerelease -preid beta`
|
||||
|
||||
read -p "
|
||||
=> Beta release: The new version will be ${newVersion},
|
||||
press [ENTER] to continue, CTRL+C to abort.
|
||||
You can force specifying a different bump by using CHOOSE_BUMP=1 npm run release-beta"
|
||||
fi
|
||||
|
||||
VERSION=$newVersion babel-node ./scripts/bump-package-version.js
|
||||
|
||||
# build new version
|
||||
NODE_ENV=production VERSION=$newVersion npm run build
|
||||
|
||||
# regenerate readme TOC
|
||||
printf "\n\nBeta release: generate TOCS"
|
||||
npm run doctoc
|
||||
|
||||
# add a timestamp fake file to dist/ to avoid having beta released published to jsdelivr automatically
|
||||
# https://github.com/jsdelivr/jsdelivr/pull/8107#issuecomment-159562676
|
||||
# You will have to close the open PR afterwards
|
||||
timestamp=$(date "+%Y.%m.%d-%H.%M.%S")
|
||||
tmpfile="dist/avoid-jsdelivr-beta-publish-$timestamp"
|
||||
touch $tmpfile
|
||||
|
||||
# git add and tag
|
||||
commitMessage="v$newVersion\n\n$changelog"
|
||||
git add src/lib/version.js npm-shrinkwrap.json package.json CHANGELOG.md CONTRIBUTING.md README.md docs/_includes/widget-jsdoc
|
||||
printf "$commitMessage" | git commit --file -
|
||||
|
||||
printf "\n\nBeta release: almost done, check everything in another terminal tab.\n"
|
||||
read -p "=> Beta release: when ready, press [ENTER] to push to github and publish the package to the beta channel"
|
||||
|
||||
printf "\n\nBeta release: push to github, publish on npm"
|
||||
git push origin develop
|
||||
npm publish --tag beta
|
||||
rm $tmpfile
|
||||
14
scripts/test-ci
Executable file
14
scripts/test-ci
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -ev # exit when error
|
||||
|
||||
./scripts/validate-pr-done-on-develop
|
||||
npm test
|
||||
npm prune
|
||||
npm run shrinkwrap --dev
|
||||
NODE_ENV=production npm run build
|
||||
./scripts/validate-commit-msgs
|
||||
|
||||
if [ $TRAVIS_PULL_REQUEST == 'false' ] && [ $TRAVIS_BRANCH == 'master' ]; then
|
||||
./scripts/finish-release
|
||||
fi
|
||||
55
scripts/validate-commit-msgs
Executable file
55
scripts/validate-commit-msgs
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e # exit when error
|
||||
|
||||
[ -z $TRAVIS_PULL_REQUEST ] && TRAVIS_PULL_REQUEST="false"
|
||||
|
||||
if [ $TRAVIS_PULL_REQUEST == "false" ]; then
|
||||
echo "No need to validate commit message when not in a pull request"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Checks the commits msgs in the range of commits travis is testing.
|
||||
# Based heavily on
|
||||
# https://raw.githubusercontent.com/angular/angular.js/291d7c467fba51a9cb89cbeee62202d51fe64b09/validate-commit-msg.js
|
||||
|
||||
# Travis's docs are misleading.
|
||||
# Check for either a commit or a range (which apparently isn't always a range) and fix as needed.
|
||||
if [ "$#" -gt 0 ]; then
|
||||
RANGE=$1
|
||||
elif [ "$TRAVIS_COMMIT_RANGE" != "" ]; then
|
||||
RANGE=$TRAVIS_COMMIT_RANGE
|
||||
elif [ "$TRAVIS_COMMIT" != "" ]; then
|
||||
RANGE=$TRAVIS_COMMIT
|
||||
fi
|
||||
|
||||
if [ "$RANGE" == "" ]; then
|
||||
# locally
|
||||
RANGE="origin/develop..HEAD"
|
||||
elif [[ "$RANGE" == *...* ]]; then
|
||||
# Travis sends the ranges with 3 dots. Git only wants 2.
|
||||
RANGE=`echo $TRAVIS_COMMIT_RANGE | sed 's/\.\.\./../'`
|
||||
elif [[ "$RANGE" != *..* ]]; then
|
||||
RANGE="$RANGE~..$RANGE"
|
||||
fi
|
||||
|
||||
EXIT=0
|
||||
for sha in `git log --format=oneline "$RANGE" | cut '-d ' -f1`; do
|
||||
echo -n "Checking commit message for $sha... "
|
||||
|
||||
FIRST_LINE=`git log --format=%B -n 1 $sha | head -1`
|
||||
MSG_LENGTH=`echo "$FIRST_LINE" | wc -c`
|
||||
if [ $MSG_LENGTH -gt 100 ]; then
|
||||
echo "KO (too long): $FIRST_LINE"
|
||||
EXIT=2
|
||||
elif echo $FIRST_LINE | grep -qE '^Merge (pull request|branch)'; then
|
||||
echo "OK (merge)"
|
||||
elif echo $FIRST_LINE | grep -qE '^(feat|fix|docs?|style|refactor|perf|tests?|chore|revert)\(.+\): .*'; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "KO (format): $FIRST_LINE"
|
||||
EXIT=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $EXIT
|
||||
19
scripts/validate-pr-done-on-develop
Executable file
19
scripts/validate-pr-done-on-develop
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e # exit when error
|
||||
|
||||
COMMIT_MSG=`git log --format=%B --no-merges -n 1`
|
||||
|
||||
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||
MSG="No need to check pull request done on develop branch when not in a pull request"
|
||||
EXIT=0
|
||||
elif [[ "$COMMIT_MSG" =~ "hotfix" ]] && [ "$TRAVIS_BRANCH" == 'master' ]; then
|
||||
MSG="Hotfix submitted to master, good"
|
||||
EXIT=0
|
||||
elif [ "$TRAVIS_BRANCH" != 'develop' ]; then
|
||||
MSG="Pull request must be done on develop branch"
|
||||
EXIT=1
|
||||
fi
|
||||
|
||||
echo $MSG;
|
||||
exit $EXIT;
|
||||
|
|
@ -3,6 +3,7 @@ import algoliasearch from 'algoliasearch';
|
|||
import autocomplete from 'autocomplete.js';
|
||||
import templates from './templates.js';
|
||||
import utils from './utils.js';
|
||||
import version from './version.js';
|
||||
import $ from 'npm-zepto';
|
||||
|
||||
/**
|
||||
|
|
@ -38,6 +39,7 @@ class DocSearch {
|
|||
this.checkArguments({apiKey, indexName, inputSelector, algoliaOptions, autocompleteOptions});
|
||||
|
||||
this.client = algoliasearch('BH4D9OD16A', this.apiKey);
|
||||
this.client.addAlgoliaAgent('docsearch.js ' + version);
|
||||
this.autocomplete = autocomplete(this.input, autocompleteOptions, [{
|
||||
source: this.getSource(),
|
||||
templates: {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import toFactory from 'to-factory';
|
||||
import DocSearch from './DocSearch';
|
||||
import version from './version.js';
|
||||
|
||||
let docSearch = toFactory(DocSearch);
|
||||
docSearch.version = version;
|
||||
|
||||
export default docSearch;
|
||||
|
|
|
|||
1
src/lib/version.js
Normal file
1
src/lib/version.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
export default '0.0.1';
|
||||
Loading…
Reference in a new issue