Skip to content

Commit b38e7e1

Browse files
Merge pull request #38 from wednesday-solutions/feat/comment-linters-auto-release
Feat/comment linters auto release
2 parents 5ba4127 + a6fcdba commit b38e7e1

File tree

4 files changed

+185
-1
lines changed

4 files changed

+185
-1
lines changed

.github/workflows/beta-release.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
on:
2+
push:
3+
branches:
4+
- qa
5+
6+
name: Create Beta Release
7+
8+
jobs:
9+
build:
10+
name: Create Beta Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Actions Ecosystem Action Get Merged Pull Request
14+
uses: actions-ecosystem/action-get-merged-pull-request@v1.0.1
15+
id: getMergedPR
16+
with:
17+
github_token: ${{ secrets.GITHUB_TOKEN }}
18+
- name: Checkout code
19+
uses: actions/checkout@v2
20+
- run: |
21+
git fetch --prune --unshallow --tags
22+
- name: Get Commit Message
23+
run: |
24+
declare -A category=( [fix]="" [chore]="" [revert]="" [build]="" [docs]="" [feat]="" [perf]="" [refactor]="" [style]="" [temp]="" [test]="" [ci]="" [others]="")
25+
declare -A categoryTitle=( [fix]="<h5>Bug Fixes</h5>" [build]="<h5>Build</h5>" [docs]="<h5>Documentation</h5>" [feat]="<h5>New Features</h5>" [chore]="<h5>Changes to build process or aux tools</h5>" [ci]="<h5>Changes to CI config</h5>" [temp]="<h5>Temporary commit</h5>" [perf]="<h5>Performance Enhancement</h5>" [revert]="<h5>Revert Commits</h5>" [refactor]="<h5>Refactored</h5>" [style]="<h5>Changed Style</h5>" [test]="<h5>Added Tests</h5>" [others]="<h5>Others</h5>")
26+
msg="#${{ steps.getMergedPR.outputs.number}} ${{ steps.getMergedPR.outputs.title}}"
27+
for i in $(git log --format=%h $(git merge-base HEAD^1 HEAD^2)..HEAD^2)
28+
do
29+
IFS=":" read -r type cmmsg <<< $(git log --format=%B -n 1 $i)
30+
type="${type}" | xargs
31+
text_msg="&nbsp;&nbsp;&nbsp;&nbsp;&#8226; $i - ${cmmsg}<br/>"
32+
flag=1
33+
for i in "${!category[@]}"
34+
do
35+
if [ "${type}" == "$i" ]
36+
then
37+
category[$i]+="${text_msg}"
38+
flag=0
39+
break
40+
fi
41+
done
42+
if [ $flag -eq 1 ]
43+
then
44+
category[others]+="${text_msg}"
45+
fi
46+
done
47+
for i in "${!category[@]}"
48+
do
49+
if [ ! -z "${category[$i]}" ] && [ "others" != "$i" ]
50+
then
51+
msg+="${categoryTitle[$i]}${category[$i]}"
52+
fi
53+
done
54+
# if [ ! -z "${category[others]}" ]
55+
# then
56+
# msg+="${categoryTitle[others]}${category[others]}"
57+
# fi
58+
echo "COMMIT_MESSAGE=${msg}" >> $GITHUB_ENV
59+
- name: Bump version and push tag
60+
run: |
61+
cd "$GITHUB_WORKSPACE"
62+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
63+
git config user.name "$GITHUB_ACTOR"
64+
npm version patch
65+
git push && git push --tags
66+
- name: get-npm-version
67+
id: package-version
68+
uses: martinbeentjes/npm-get-version-action@master
69+
- name: Create Beta Release
70+
uses: actions/create-release@latest
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
with:
74+
tag_name: ${{ steps.package-version.outputs.current-version}}-Beta
75+
release_name: v${{ steps.package-version.outputs.current-version}}-Beta
76+
body: ${{ env.COMMIT_MESSAGE }}
77+
draft: false
78+
prerelease: false

.github/workflows/prod-release.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
6+
name: Create Production Release
7+
8+
jobs:
9+
build:
10+
name: Create Production Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Actions Ecosystem Action Get Merged Pull Request
14+
uses: actions-ecosystem/action-get-merged-pull-request@v1.0.1
15+
id: getMergedPR
16+
with:
17+
github_token: ${{ secrets.GITHUB_TOKEN }}
18+
- name: Checkout code
19+
uses: actions/checkout@v2
20+
- run: |
21+
git fetch --prune --unshallow --tags
22+
- name: Get Commit Message
23+
run: |
24+
declare -A category=( [fix]="" [chore]="" [revert]="" [build]="" [docs]="" [feat]="" [perf]="" [refactor]="" [style]="" [temp]="" [test]="" [ci]="" [others]="")
25+
declare -A categoryTitle=( [fix]="<h5>Bug Fixes</h5>" [build]="<h5>Build</h5>" [docs]="<h5>Documentation</h5>" [feat]="<h5>New Features</h5>" [chore]="<h5>Changes to build process or aux tools</h5>" [ci]="<h5>Changes to CI config</h5>" [temp]="<h5>Temporary commit</h5>" [perf]="<h5>Performance Enhancement</h5>" [revert]="<h5>Revert Commits</h5>" [refactor]="<h5>Refactored</h5>" [style]="<h5>Changed Style</h5>" [test]="<h5>Added Tests</h5>" [others]="<h5>Others</h5>")
26+
msg="#${{ steps.getMergedPR.outputs.number}} ${{ steps.getMergedPR.outputs.title}}"
27+
for i in $(git log --format=%h $(git merge-base HEAD^1 HEAD^2)..HEAD^2)
28+
do
29+
IFS=":" read -r type cmmsg <<< $(git log --format=%B -n 1 $i)
30+
type="${type}" | xargs
31+
text_msg="&nbsp;&nbsp;&nbsp;&nbsp;&#8226; $i - ${cmmsg}<br/>"
32+
flag=1
33+
for i in "${!category[@]}"
34+
do
35+
if [ "${type}" == "$i" ]
36+
then
37+
category[$i]+="${text_msg}"
38+
flag=0
39+
break
40+
fi
41+
done
42+
if [ $flag -eq 1 ]
43+
then
44+
category[others]+="${text_msg}"
45+
fi
46+
done
47+
for i in "${!category[@]}"
48+
do
49+
if [ ! -z "${category[$i]}" ] && [ "others" != "$i" ]
50+
then
51+
msg+="${categoryTitle[$i]}${category[$i]}"
52+
fi
53+
done
54+
if [ ! -z "${category[others]}" ]
55+
then
56+
msg+="${categoryTitle[others]}${category[others]}"
57+
fi
58+
echo "COMMIT_MESSAGE=${msg}" >> $GITHUB_ENV
59+
- name: Bump version and push tag
60+
run: |
61+
cd "$GITHUB_WORKSPACE"
62+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
63+
git config user.name "$GITHUB_ACTOR"
64+
npm version major
65+
git push
66+
- name: get-npm-version
67+
id: package-version
68+
uses: martinbeentjes/npm-get-version-action@master
69+
- name: Create Prod Release
70+
uses: actions/create-release@latest
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
with:
74+
tag_name: ${{ steps.package-version.outputs.current-version}}
75+
release_name: v${{ steps.package-version.outputs.current-version}}
76+
body: ${{ env.COMMIT_MESSAGE }}
77+
draft: false
78+
prerelease: false

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"eslint-plugin-prettier": "^4.0.0",
8686
"eslint-plugin-promise": "^4.2.1",
8787
"eslint-plugin-standard": "^4.0.1",
88+
"git-commit-msg-linter": "^4.1.2",
8889
"jest": "^27.4.7",
8990
"link-module-alias": "^1.2.0",
9091
"mockingoose": "^2.15.2",

yarn.lock

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2683,6 +2683,14 @@ dezalgo@1.0.3:
26832683
asap "^2.0.0"
26842684
wrappy "1"
26852685

2686+
did-you-mean@^0.0.1:
2687+
version "0.0.1"
2688+
resolved "https://registry.yarnpkg.com/did-you-mean/-/did-you-mean-0.0.1.tgz#8851ce82407903cb62c12cb6ad4f676921ccdec3"
2689+
integrity sha1-iFHOgkB5A8tiwSy2rU9naSHM3sM=
2690+
dependencies:
2691+
levenshtein "*"
2692+
underscore "*"
2693+
26862694
diff-sequences@^27.4.0:
26872695
version "27.4.0"
26882696
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-27.4.0.tgz#d783920ad8d06ec718a060d00196dfef25b132a5"
@@ -3674,6 +3682,15 @@ get-them-args@1.3.2:
36743682
resolved "https://registry.yarnpkg.com/get-them-args/-/get-them-args-1.3.2.tgz#74a20ba8a4abece5ae199ad03f2bcc68fdfc9ba5"
36753683
integrity sha1-dKILqKSr7OWuGZrQPyvMaP38m6U=
36763684

3685+
git-commit-msg-linter@^4.1.2:
3686+
version "4.1.2"
3687+
resolved "https://registry.yarnpkg.com/git-commit-msg-linter/-/git-commit-msg-linter-4.1.2.tgz#a1b7b5ac0069c57b9624ee72d51d6141f72a22ba"
3688+
integrity sha512-m0UZwDV1nKaDdCUKphHIgeCbq8qmSUjkYyMvxjF3sxGAhqD2DPCA2h9MT4AUvjg5spvTQBU69Lu7KozEkOCT5w==
3689+
dependencies:
3690+
chalk "^2.4.2"
3691+
did-you-mean "^0.0.1"
3692+
supports-color "^8.1.1"
3693+
36773694
glob-parent@^5.0.0, glob-parent@^5.1.2, glob-parent@~5.1.2:
36783695
version "5.1.2"
36793696
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
@@ -5108,6 +5125,11 @@ leven@^2.1.0:
51085125
resolved "https://registry.yarnpkg.com/leven/-/leven-2.1.0.tgz#c2e7a9f772094dee9d34202ae8acce4687875580"
51095126
integrity sha1-wuep93IJTe6dNCAq6KzORoeHVYA=
51105127

5128+
levenshtein@*:
5129+
version "1.0.5"
5130+
resolved "https://registry.yarnpkg.com/levenshtein/-/levenshtein-1.0.5.tgz#3911737a9cb56da345d008f55782c6f138979ba3"
5131+
integrity sha1-ORFzepy1baNF0Aj1V4LG8TiXm6M=
5132+
51115133
levn@^0.3.0, levn@~0.3.0:
51125134
version "0.3.0"
51135135
resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee"
@@ -7335,7 +7357,7 @@ supports-color@^7.0.0, supports-color@^7.1.0:
73357357
dependencies:
73367358
has-flag "^4.0.0"
73377359

7338-
supports-color@^8.0.0:
7360+
supports-color@^8.0.0, supports-color@^8.1.1:
73397361
version "8.1.1"
73407362
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c"
73417363
integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==
@@ -7603,6 +7625,11 @@ undefsafe@^2.0.5:
76037625
resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c"
76047626
integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==
76057627

7628+
underscore@*:
7629+
version "1.13.3"
7630+
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.3.tgz#54bc95f7648c5557897e5e968d0f76bc062c34ee"
7631+
integrity sha512-QvjkYpiD+dJJraRA8+dGAU4i7aBbb2s0S3jA45TFOvg2VgqvdCDd/3N6CqA8gluk1W91GLoXg5enMUx560QzuA==
7632+
76067633
unherit@^1.0.4:
76077634
version "1.1.3"
76087635
resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.3.tgz#6c9b503f2b41b262330c80e91c8614abdaa69c22"

0 commit comments

Comments
 (0)