Skip to content

Commit

Permalink
chore: update CI configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mmorainville committed Dec 29, 2019
1 parent f689b9f commit 5ce038e
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 0 deletions.
132 changes: 132 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2

defaults: &defaults
docker:
- image: circleci/node:10.16.3
working_directory: ~/vue-tour

jobs:
build:
<<: *defaults
steps:
- checkout

# install Cypress dependencies
- run: sudo apt-get update && sudo apt-get install -y libgtk2.0-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 xvfb

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: npm install

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

# run unit tests!
- run: npm run test:unit
- run: npm run build

- run: git worktree add ../vue-tour-landing origin/landing

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "../vue-tour-landing/package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
-
- run:
command: npm install
working_directory: ~/vue-tour-landing

- save_cache:
paths:
- ../vue-tour-landing/node_modules
key: v1-dependencies-{{ checksum "../vue-tour-landing/package.json" }}

# run e2e tests!
- run:
command: npm run test:e2e -- --headless
working_directory: ~/vue-tour-landing

- persist_to_workspace:
root: ~/
paths:
- vue-tour
- vue-tour-landing

publish:
<<: *defaults
steps:
- attach_workspace:
at: ~/

- add_ssh_keys:
fingerprints:
- "eb:09:ae:75:b5:8e:66:63:27:9a:c0:cb:64:6e:79:d5"

# generate a new landing build and commit it to the gh-pages branch
- run:
command: npm run build
working_directory: ~/vue-tour-landing

- run:
command: cp -R ./dist ../
working_directory: ~/vue-tour-landing

- run:
command: |
ssh-keyscan github.com >> ~/.ssh/known_hosts
git checkout --track origin/gh-pages
rm -rf *
cp -R ../dist/. ./
git config user.email "[email protected]"
git config user.name "Mathieu Morainville"
git status
git add .
git commit -m "chore(ci): generate a new build"
git push origin gh-pages
working_directory: ~/vue-tour-landing

# we could use standard-version here to generating a changelog, bump the version with a tag and commit it

- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
when: always

- run:
name: Publish package
command: cat .npmrc
# command: npm publish

# use workflows to publish only on tagged commits (see: https://circleci.com/blog/publishing-npm-packages-using-circleci-2-0/)
workflows:
version: 2
build-publish:
jobs:
- build:
filters:
branches:
only:
- master
- staging
- publish:
requires:
- build
filters:
tags:
only: /^v.*/
branches:
only:
- master
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ yarn-error.log*
*.njsproj
*.sln
*.sw?

.npmrc
29 changes: 29 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,38 @@

## Table of Contents

- [Developing Vue Tour](#developing-vue-tour)
- [Generating a Changelog](#generating-a-changelog)
- [Git Commit Guidelines](#git-commit-guidelines)

## Developing Vue Tour

Vue Tour is a library which means that in order to be tested it has to be used in a project.
For this you have two options:
- Use `public/index.html` but then you're limited to a built version
- Use the `landing` branch as a git worktree:
```
git worktree add ../vue-tour-landing landing
```

To make a new release we:
- Generate a changelog and a tagged commit by running:
```
standard-version
```
- We publish the package to npm if the CI doesn't do it for us already:
```
npm publish
```

The best practice would be to push all the changes for a new release to a `staging` branch to ensure everything is fine.
Then, when the new version is ready:
- Generate the changelog
- Merge to `master`
- Eventually run `npm publish` if not done by the CI

The landing page is built by the CI using the last sources.

## Generating a Changelog

By using "standard" guidelines we are able to automatically generate a changelog from our git commit messages.
Expand Down

0 comments on commit 5ce038e

Please sign in to comment.