Skip to content

Commit

Permalink
feat(automation release): standard commit msg and release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
winixt authored and wanchun committed Sep 25, 2020
1 parent d3f2a5f commit 1d7c6d1
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 4 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release

on:
push:
tags: ["v*"]

jobs:
github_release:
name: Trigger GitHub release
runs-on: ubuntu-latest
steps:
- name: Checkout the new tag
uses: actions/[email protected]

- name: Get tag info
id: tags
uses: babel/actions/get-release-tags@v2

- name: Generate the changelog
id: changelog
uses: babel/actions/generate-lerna-changelog@v2
with:
from: ${{ steps.tags.outputs.old }}
to: ${{ steps.tags.outputs.new }}
env:
GITHUB_AUTH: ${{ secrets.ACCESS_TOKEN }}

- name: Create a draft GitHub release
uses: babel/actions/publish-github-release@v2
with:
tag: ${{ steps.tags.outputs.new }}
changelog: ${{ steps.changelog.outputs.changelog }}
token: ${{ secrets.ACCESS_TOKEN }}

- name: Check if releasing from master
id: is_master
uses: babel/actions/ref-matches-branch@v2
with:
name: master

- name: Update CHANGELOG.md
if: steps.is_master.outputs.result == 1
uses: babel/actions/update-changelog@v2
with:
changelog: ${{ steps.changelog.outputs.changelog }}

- name: Commit CHANGELOG.md
if: steps.is_master.outputs.result == 1
run: |
git add CHANGELOG.md
git -c user.name="wanchun" -c user.email="[email protected]" \
commit -m "Add ${{ steps.tags.outputs.new }} to CHANGELOG.md [skip ci]" --no-verify --quiet
git push "https://wanchun:${{ secrets.ACCESS_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" master
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ node_modules
npm-debug.log
/packages/fes-template/dist
/packages/fes-doc/docs/.vuepress/dist
package-lock.json
package-lock.json

/.changelog
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
28 changes: 26 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
{
"version": "0.1.0",
"changelog": {
"repo": "WeBankFinTech/fes.js",
"cacheDir": ".changelog",
"labels": {
"PR: Spec Compliance :eyeglasses:": ":eyeglasses: Spec Compliance",
"PR: Breaking Change :boom:": ":boom: Breaking Change",
"PR: New Feature :rocket:": ":rocket: New Feature",
"PR: Bug Fix :bug:": ":bug: Bug Fix",
"PR: Polish :nail_care:": ":nail_care: Polish",
"PR: Docs :memo:": ":memo: Documentation",
"PR: Internal :house:": ":house: Internal",
"PR: Performance :running_woman:": ":running_woman: Performance",
"PR: Revert :leftwards_arrow_with_hook:": ":leftwards_arrow_with_hook: Revert"
}
},
"command": {
"publish": {
"ignoreChanges": ["*.md", "**/test/**"]
},
"version": {
"push": false
}
},
"packages": [
"packages/*"
],
"version": "independent",
"npmClient": "npm"
"npmClient": "npm",
"ignoreChanges": ["**/fes-doc/**", "**/test/**", "**/*.md"]
}
24 changes: 23 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,28 @@
"lerna": "^3.18.4"
},
"devDependencies": {
"@webank/eslint-config-webank": "^0.1.7"
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@webank/eslint-config-webank": "^0.1.7",
"commitizen": "^4.2.1",
"cz-lerna-changelog": "^2.0.3",
"husky": "^4.3.0",
"lint-staged": "^10.4.0"
},
"lint-staged": {
"*.{js,fes,jsx,vue,ts}": [
"eslint --format=codeframe"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"config": {
"commitizen": {
"path": "./node_modules/cz-lerna-changelog"
}
}
}

0 comments on commit 1d7c6d1

Please sign in to comment.