Skip to content

Commit

Permalink
ci: automated semantic-release workflow (#420)
Browse files Browse the repository at this point in the history
* add release.config.js

* add release.yml
  • Loading branch information
jooohhn authored Nov 30, 2020
1 parent 37a6b0b commit 59f5b37
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 1 deletion.
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Release

on:
workflow_dispatch:
inputs:
dryRun:
description: 'Do a dry run to preview instead of a real release'
required: true
default: 'true'

env:
stable-node-version: "14.x"
e2e-eslint-version: "eslint@7" # Used because e2e and benchmark tests use ESLint's Node.js API class introduced in eslint@7

jobs:
authorize:
name: Authorize
runs-on: ubuntu-18.04
steps:
- name: ${{ github.actor }} permission check to do a release
uses: octokit/[email protected]
with:
route: GET /repos/:repository/collaborators/${{ github.actor }}
repository: ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release:
name: Release
runs-on: ubuntu-18.04
needs: [authorize]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ stable-node-version }}

- name: node_modules cache
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn install --frozen-lockfile && yarn add --dev ${{ e2e-eslint-version }}

- name: Run tests
run: yarn test && yarn spec:e2e

- name: Release --dry-run # Uses release.config.js
if: ${{ github.event.inputs.dryRun == 'true'}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release --dry-run

- name: Release # Uses release.config.js
if: ${{ github.event.inputs.dryRun == 'false'}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
36 changes: 36 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = {
branches: ["master"],
plugins: [
[
"@semantic-release/commit-analyzer",
{
preset: "angular",
parserOpts: {
noteKeywords: ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"],
},
},
],
[
"@semantic-release/release-notes-generator",
{
preset: "angular",
},
],
[
"@semantic-release/changelog",
{
changelogFile: "CHANGELOG.md",
},
],
"@semantic-release/npm",
"@semantic-release/github",
[
"@semantic-release/git",
{
assets: ["package.json", "CHANGELOG.md"],
message:
"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}", // eslint-disable-line no-template-curly-in-string
},
],
],
};
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"include": [
"src/**/*.ts",
"test/**/*.ts",
".eslintrc.js"
".eslintrc.js",
"release.config.js"
]
}

0 comments on commit 59f5b37

Please sign in to comment.