Skip to content

Commit

Permalink
add automatic changelog for builds (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosmoura committed Jun 24, 2017
1 parent 6e210f0 commit e3c3746
Show file tree
Hide file tree
Showing 14 changed files with 15,979 additions and 19 deletions.
1 change: 0 additions & 1 deletion .gitignore
@@ -1,6 +1,5 @@
.DS_Store
node_modules/
dist/
coverage/
.nyc_output/
yarn-debug.log
Expand Down
21 changes: 18 additions & 3 deletions .travis.yml
@@ -1,11 +1,12 @@
language: node_js
node_js:
- "7"
- '7'
sudo: false
dist: trusty
env:
- CODACY_PROJECT_TOKEN="2c41cbf105884e6fa05a596e8bf031e6"
global:
- NODE_ENV="CI"
- secure: n8S9oRQc7C9vq6UsQKFS3dclz83GohtPH5iF0xUkOurhgIrZ8NwFtxYNoi5BDHuxCo/HdVd1vN8hKBcyPdsuVZstvA39O8xbtdDs+pgDAPDmoVLCkEK10yva+aYvf8fdleJi40mcoucgtWCBYkOwMZlbBqwNZ7pf9CT3QMzjvbnC7skP1A5Ju0PXm43eFgZ8OEBWEd0qHl8cFIwOljWcYcwErdcq9Xo0VNwbp8cELTAM+GkNbGLtSJmArG3dkGxb1MINb+FkjjW94j2oF3U1QjbdTvQ2f/gbrrg0i9el+T1mLdukGoaZRpG3LzBTYs9e37MyIqgIm3kwCwjYTJP4Uqv9cI6egSnBDsuQ314LEyKkQeYFIXzeKEoNJ8PnROY20TjFmoAvNoA09hbgdrfcCALn5Tpp6PjayD0pb7+HWSfY0tEqJsLWzArRsKRXSozYud8sDMyySyQTAtAG4AxsDR5+wFz1T7faZP61JJulHJYZY5UbmjDPe8FHUq8SNrxwOFYa59jb1yCyGftTgWfLCNrYL9JOw0jMPTVuCeo94l0yCF5N8Mo18iYnnZd/6btWR0OO7Q3CgPJQGUMxLx6UhfYiIlhDq4OKsAEUD/+ZQDfWueM0lmHyn3tsRi9bVwNvf5HlFYkgc5x4UbkGUsCQUjM8ceoKlnfhup72fyWesQI=
addons:
code_climate:
repo_token: 2bcf2bd351aa016cb70c405b0571f454f353d5150531fb92e6a111634c6e0feb
Expand All @@ -20,4 +21,18 @@ after_success:
- yarn add --dev codeclimate-test-reporter
- yarn add --dev codacy-coverage
- codeclimate-test-reporter < ./coverage/lcov.info
- cat ./coverage/lcov.info | ./node_modules/.bin/codacy-coverage
- yarn changelog
- RELEASE_NOTES=`cat RELEASE_NOTES.md`
- PACKAGE_VERSION=$(grep '"version":' package.json | cut -d\" -f4)
- yarn github-release -- delete \
--owner=vuematerial \
--repo=vue-material-experiments \
--tag="v${PACKAGE_VERSION}" \
--name="v${PACKAGE_VERSION}"
- yarn github-release -- upload \
--owner=vuematerial \
--repo=vue-material-experiments \
--tag="${PACKAGE_VERSION}" \
--name="v${PACKAGE_VERSION}" \
--body="v${RELEASE_NOTES}"
- rm -rf RELEASE_NOTES.md CHANGELOG.md
Empty file added CHANGELOG.md
Empty file.
12 changes: 1 addition & 11 deletions build/generate-changelog.js
@@ -1,21 +1,13 @@
import cc from 'conventional-changelog'
import config from 'conventional-changelog-vue-material'
import ora from 'ora'
import { green } from 'chalk'
import concat from 'concat'
import { createWriteStream } from 'fs'
import packageJson from '../package.json'

const { version } = packageJson
const releaseNotesFile = './RELEASE_NOTES.MD'
const releaseNotesFile = './RELEASE_NOTES.md'
const changelogFile = './CHANGELOG.md'
const releaseNotes = createWriteStream(releaseNotesFile)
const spinner = ora({
text: 'Generating changelog...',
color: 'green'
})

spinner.start()

config.then(data => {
const changelogConfig = {
Expand All @@ -30,7 +22,5 @@ config.then(data => {

cc(changelogConfig).pipe(releaseNotes).on('close', () => {
concat([releaseNotesFile, changelogFile], changelogFile)

spinner.succeed(green('Changelog released!'))
})
})
2 changes: 1 addition & 1 deletion build/git-hooks/pre-commit
@@ -1,6 +1,6 @@
#!/bin/bash

files_to_lint=$(git diff --staged --cached --name-only --diff-filter=ACM | grep '.js\|.vue$')
files_to_lint=$(git diff --staged --cached --name-only --diff-filter=ACM | grep '.\(js\|vue\)$')

if [ -n "$files_to_lint" ]; then
NODE_ENV=production node ./node_modules/eslint/bin/eslint --quiet $files_to_lint
Expand Down
4 changes: 3 additions & 1 deletion build/lib/webpack.js
Expand Up @@ -90,7 +90,9 @@ export default entry => {
webpackConfig = merge({
plugins: [
new ExtractTextPlugin('[name].min.css'),
new OptimizeCssAssetsPlugin()
new OptimizeCssAssetsPlugin({
canPrint: false
})
],
module: {
rules: [
Expand Down
53 changes: 53 additions & 0 deletions build/release.sh
@@ -0,0 +1,53 @@
set -e

CLEAR='\033c'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m'

# init the process
if [[ -z $1 ]]; then
printf $CLEAR
echo "${BLUE}Enter new version: ${NC}"
read VERSION
else
VERSION=$1
fi

read -p "Releasing $VERSION - are you sure? (y/n) " -n 1 -r

if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "${CLEAR}Releasing Vue Material - ${GREEN}Version $VERSION${NC}"


echo "\n${YELLOW}Checking for errors... ${NC}"
yarn lint


echo "\n${YELLOW}Running all tests... ${NC}"
yarn test


echo "\n${YELLOW}Generating build... ${NC}"
VERSION=$VERSION yarn build


echo "\n${YELLOW}Generating changelog... ${NC}"
yarn changelog
rm -rf RELEASE_NOTES.md


echo "\n${YELLOW}Commiting... ${NC}"
git add -A
git commit -m "chore: build $VERSION"
npm version $VERSION --message "chore: release $version"
git push


echo "\n${YELLOW}Publishing a new release... ${NC}"
npm publish


echo "\n${GREEN}BUILD FINISHED WITH SUCCESS!${NC}"
fi

0 comments on commit e3c3746

Please sign in to comment.