Skip to content

Commit

Permalink
Merge pull request #200 from zendesk/andre_automate_releases
Browse files Browse the repository at this point in the history
chore(release): automate copenhagen theme releases
  • Loading branch information
anpa authored Mar 11, 2020
2 parents 6bebfdb + 149cc72 commit ab9d1d8
Show file tree
Hide file tree
Showing 7 changed files with 5,249 additions and 16 deletions.
18 changes: 18 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Description

<!-- a summary of the changes introduced by this PR and the motivation behind them -->

## Screenshots

<!-- (optional) when applicable, please include some screenshots or gifs that illustrate the changes -->

## Checklist

- [ ] :green_book: all commit messages follow the [conventional commits](https://conventionalcommits.org/) standard
- [ ] :nail_care: SASS files are compiled
- [ ] :arrow_left: changes are compatible with RTL direction
- [ ] :wheelchair: changes are accessible
- [ ] :memo: changes are tested in Chrome, Firefox, Safari, Edge, and IE11
- [ ] :+1: PR is approved by @zendesk/vikings

<!-- More info about the contribution process can be found at https://github.com/zendesk/copenhagen_theme#contributing -->
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

name: Release
on:
push:
branches:
- master
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Release
run: yarn semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 18 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"branches": [
"master"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
["@semantic-release/exec", {
"prepareCmd": "./bin/update-manifest-version.sh ${nextRelease.version}"
}],
["@semantic-release/git", {
"assets": ["manifest.json", "CHANGELOG.md"],
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
}],
"@semantic-release/github"
]
}
66 changes: 64 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,68 @@ Now you can compile your SASS files running:
Which will take all the `scss` files inside the `styles/` folder and create the `style.css` file that is consumable by Zendesk Guide.

# Contributing
Pull requests are welcome on GitHub at https://github.com/zendesk/copenhagen_theme
Please mention @zendesk/vikings when creating a pull request.
Pull requests are welcome on GitHub at https://github.com/zendesk/copenhagen_theme. Please mention @zendesk/vikings when creating a pull request.

We use [conventional commits](https://conventionalcommits.org/) to improve readability of the project history and to automate the release process. The commit message should therefore respect the following format:

```
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
```

- type: describes the category of the change. See [supported types](#commit-types).
- scope: (optional) describes what is affected by the change
- subject: a small description of the change
- body: (optional) additional contextual information about the change
- footer: (optional) adds external links, issue references and other meta-information

i.e.:

```
chore: automate release
fix(styles): fix button padding
feat(script): add auto focus to fields with errors
```

We use [`husky`](https://github.com/typicode/husky) and [`commitlint`](https://github.com/conventional-changelog/commitlint) to validate messages when commiting.

We use [Github actions](https://github.com/features/actions) together with [`semantic-release`](https://github.com/semantic-release/semantic-release) to release a new version of the theme once a PR gets merged. On each merge, `semantic-release` analyses the commit messages and infers a semantic version bump. It then creates a git tag, updates the manifest version and generates the corresponding [changelog](CHANGELOG.md).

## Commit types

The list bellow describes the supported commit types and their effect in the release and changelog.

| Type | Description | Release | Changelog |
|----------|--------------------------------------------------------------------------------------------------------|---------|--------------------------|
| build | Changes that affect the build system or external dependencies | - | - |
| chore | Other changes that don't modify the source code | - | - |
| ci | Changes to our CI configuration files and scripts | - | - |
| docs | Documentation only changes | - | - |
| feat | A new feature | minor | Features |
| fix | A bug fix | patch | Bug Fixes |
| perf | A code change that improves performance | patch | Performance Improvements |
| refactor | A code change that neither fixes a bug nor adds a feature | - | - |
| revert | Reverts a previous commit | patch | Reverts |
| style | Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) | - | - |
| test | Adding missing tests or correcting existing tests | - | - |

## Breaking changes

Commits that add a breaking change should include `BREAKING CHANGE` in the body or footer of the commit message.

i.e.:

```
feat: update theme to use theming api v2
BREAKING CHANGE: theme is now relying on functionality that is exclusive to the theming api v2
```

This will then generate a major release and add a `BREAKING CHANGES` section in the [changelog](CHANGELOG.md).

# Bug reports
Bug reports must be submitted through Zendesk's standard support channels: https://www.zendesk.com/contact/
10 changes: 10 additions & 0 deletions bin/update-manifest-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# EXIT ON ERROR
set -e

# UPDATE MANIFEST VERSION
NEW_VERSION=$1
mv manifest.json manifest.temp.json
jq -r '.version |= "'${NEW_VERSION}'"' manifest.temp.json > manifest.json
rm manifest.temp.json
19 changes: 18 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@
"node-fetch": "^2.1.2"
},
"devDependencies": {
"js-yaml": "^3.13.1"
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"@semantic-release/changelog": "^5.0.0",
"@semantic-release/exec": "^5.0.0",
"@semantic-release/git": "^9.0.0",
"husky": "^4.2.3",
"js-yaml": "^3.13.1",
"semantic-release": "^17.0.4"
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
}
Loading

0 comments on commit ab9d1d8

Please sign in to comment.