Skip to content

Commit

Permalink
ci: setup ci
Browse files Browse the repository at this point in the history
  • Loading branch information
BoruiGu committed Dec 6, 2021
1 parent 775baa1 commit bf8527a
Show file tree
Hide file tree
Showing 7 changed files with 9,251 additions and 3,801 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'monthly'
66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: ci
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'npm'
- run: npm ci
- run: npm run check-format
- run: npm test
- name: Detect if release is necessary
id: should_release
run: |
set -euo pipefail
# workaround https://github.com/conventional-changelog/standard-version/issues/192
script=$(cat << 'EOF'
const commitMessages = process.env.COMMIT_MESSAGES.split(',');
console.error('checking commit messages');
console.error(commitMessages.map(m => `> ${m}`).join('\n'));
const shouldRelease = commitMessages.some(
(message) =>
/^(feat|fix|perf|refactor|revert)/.test(message) ||
message.includes('!:') ||
message.includes('BREAKING CHANGE') ||
message.includes('[create release]')
);
console.error("should release:", shouldRelease);
console.log(shouldRelease ? 'y' : 'n');
EOF
)
should_release=$(echo $script | node -)
echo "::set-output name=should_release::$should_release"
env:
COMMIT_MESSAGES: ${{ join(github.event.commits.*.message) }}
- name: Prepare release
id: prepare_release
run: |
set -euo pipefail
git config user.name "github-actions"
git config user.email "<41898282+github-actions[bot]@users.noreply.github.com>"
# workaround https://github.com/conventional-changelog/standard-version/issues/610
npx standard-version
npx extract-changelog-release > RELEASE_BODY.md
npm run build
git push --follow-tags
echo ::set-output name=tag_name::$(git describe HEAD --abbrev=0)
if: ${{ steps.should_release.outputs.should_release == 'y' }}
- name: Release
uses: softprops/action-gh-release@v1
with:
name: ${{ steps.prepare_release.outputs.tag_name }}
tag_name: ${{ steps.prepare_release.outputs.tag_name }}
body_path: RELEASE_BODY.md
if: ${{ steps.should_release.outputs.should_release == 'y' }}
- name: Publish NPM
run: npm publish
25 changes: 25 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: pr
on: pull_request
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'npm'
- run: npm ci
- run: npm test
format:
name: check code format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'npm'
- run: npm ci
- run: npm run check-format
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run commit-msg
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run pre-commit
Loading

0 comments on commit bf8527a

Please sign in to comment.