Skip to content

Commit

Permalink
ci: Setup semantic release
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbo2002 committed Feb 27, 2021
1 parent ccfa0f0 commit 0181284
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 61 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/**
dist/**
docs/**
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release
on:
push:
branches:
- main
- develop

jobs:
release:
runs-on: ubuntu-latest
if: contains(toJson(github.event.commits), '[skip ci]') == false
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run lint
- run: npm run test
- name: install semantic-release
run: |
npm i -g semantic-release \
@semantic-release/changelog \
@semantic-release/exec \
@semantic-release/git
- name: semantic-release
run: BRANCH=${GITHUB_REF#refs/heads/} npx semantic-release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/.github
/.nyc_output
/.idea
/dist
/doc
/docs
/node_modules
2 changes: 1 addition & 1 deletion .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"coverage/**",
"node_modules/**"
],
"report-dir": "./doc/coverage/",
"report-dir": "./docs/coverage/",
"temp-directory": "./.nyc_output",
"sourceMap": true,
"reporter": [
Expand Down
15 changes: 11 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env bash
set -e

echo "########################"
echo "# build.sh"
echo "# Branch = ${BRANCH}"
echo "########################"

# Typescript Build in ./dist
npx tsc

if [ "$BRANCH" != "develop" ] && [ "$BRANCH" != "main" ] && [ "$BRANCH" != "" ]; then
Expand All @@ -13,12 +15,17 @@ if [ "$BRANCH" != "develop" ] && [ "$BRANCH" != "main" ] && [ "$BRANCH" != "" ];
fi;


rm -rf ./doc
mkdir -p ./docs/
rm -rf ./docs/coverage/ ./docs/reference/ ./docs/tests/


# TypeDoc in ./docs/referece
npx typedoc

# Test Report in ./docs/tests
npx mocha --reporter mochawesome
mv ./mochawesome-report/mochawesome.html ./mochawesome-report/index.html
mkdir -p ./doc
mv ./mochawesome-report ./doc/tests
mv -f ./mochawesome-report/mochawesome.html ./mochawesome-report/index.html
mv -f ./mochawesome-report ./docs/tests

# Coverage Report in ./doc/coverage
npm run coverage
75 changes: 33 additions & 42 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,3 @@
const plugins = [
['@semantic-release/commit-analyzer', {
'preset': 'angular',
'releaseRules': [
{'type': 'refactor', 'release': 'patch'},
{'type': 'style', 'release': 'patch'},
{'type': 'build', 'scope': 'deps', 'release': 'patch'},
{'type': 'docs', 'release': 'patch'}
]
}],
['@semantic-release/release-notes-generator', {
'preset': 'angular',
'writerOpts': {
'commitsSort': ['subject', 'scope']
}
}],
['@semantic-release/exec', {
'prepareCmd': './build.sh'
}],
['@semantic-release/changelog', {
'changelogFile': 'CHANGELOG.md'
}],
'@semantic-release/npm',
'@semantic-release/github'
];

if (process.env.BRANCH === 'main') {
plugins.push(['@semantic-release/git', {
'assets': ['CHANGELOG.md', 'package.json', 'package-lock.json'],
'message': 'chore(release): :bookmark: ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
}]);
}
if (process.env.BRANCH === 'main' || process.env.BRANCH === 'develop') {
plugins.push(['@qiwi/semantic-release-gh-pages-plugin', {
'msg': 'docs: Updated for <%= nextRelease.gitTag %>',
'src': './doc',
'dst': `./${process.env.BRANCH}`,
'pullTagsBranch': 'main'
}]);
}

module.exports = {
'branches': [
'main',
Expand All @@ -48,5 +7,37 @@ module.exports = {
'prerelease': true
}
],
'plugins': plugins
'plugins': [
['@semantic-release/commit-analyzer', {
'preset': 'angular',
'releaseRules': [
{'type': 'refactor', 'release': 'patch'},
{'type': 'style', 'release': 'patch'},
{'type': 'build', 'scope': 'deps', 'release': 'patch'},
{'type': 'docs', 'release': 'patch'}
]
}],
['@semantic-release/release-notes-generator', {
'preset': 'angular',
'writerOpts': {
'commitsSort': ['subject', 'scope']
}
}],
['@semantic-release/exec', {
'prepareCmd': './build.sh'
}],
'@semantic-release/changelog',
'@semantic-release/npm',
'@semantic-release/github',
['@semantic-release/git', {
'assets': ['CHANGELOG.md'],
'message': 'chore(release): :bookmark: ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
}],
['@qiwi/semantic-release-gh-pages-plugin', {
'msg': 'docs: Updated for <%= nextRelease.gitTag %>',
'src': './doc',
'dst': `./${process.env.BRANCH}`,
'pullTagsBranch': 'main'
}]
]
};
16 changes: 4 additions & 12 deletions typedoc.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
{
"inputFiles": [
"./src/index.ts"
],
"exclude": [
"./lib/tools.ts"
],
"out": "./doc/reference",
"mode": "file",
"entryPoints": ["./src/index.ts"],
"exclude": [],
"out": "./docs/reference",
"theme": "minimal",
"name": "ical-generator",
"readme": "none",
"includeVersion": true,
"excludeNotExported": true,
"excludePrivate": true,
"excludeProtected": true,
"stripInternal": true,
"module": "node"
"excludeProtected": true
}

0 comments on commit 0181284

Please sign in to comment.