@@ -13,17 +13,18 @@ jobs:
1313 permissions :
1414 contents : read
1515 outputs :
16- run_suffix_present : ${{ steps.check_run_suffix_present.outputs.run_suffix_present }}
17- run_suffix_force_version : ${{ steps.check_run_suffix_present.outputs.run_suffix_force_version }}
16+ is_suffix_present : ${{ steps.check_create_release_suffix.outputs.is_suffix_present }}
17+ is_version_bump : ${{ steps.check_create_release_suffix.outputs.is_version_bump }}
18+ force_version : ${{ steps.check_create_release_suffix.outputs.force_version }}
1819 steps :
1920 - name : Checkout the Codebase
2021 uses : actions/checkout@v4
2122 with :
2223 ref : main # branch to checkout
2324 fetch-depth : 0
2425
25- - name : Check commit message suffix for `[create-release]`
26- id : check_run_suffix_present
26+ - name : Check commit message suffix for `[create-release-TYPE ]`
27+ id : check_create_release_suffix
2728 uses : actions/github-script@v7
2829 with :
2930 script : |
@@ -32,24 +33,45 @@ jobs:
3233 const lastCommitMessage = context.payload.head_commit.message;
3334 const lastCommitMessageFirstLine = lastCommitMessage.split('\n')[0];
3435
35- let run_suffix_present = "false";
36- let run_suffix_force_version = "";
36+ let is_suffix_present = "false";
37+ let is_version_bump = "false";
38+ let force_version = "";
39+
40+ const allowedTypes = [
41+ "auto",
42+ "major",
43+ "minor",
44+ "patch",
45+ "premajor",
46+ "preminor",
47+ "prepatch",
48+ "prerelease",
49+ ];
3750
3851 const regex = /\[create-release(?:-([a-z]+))?\]/;
3952 const match = lastCommitMessageFirstLine.match(regex);
4053
4154 if (match) {
42- run_suffix_present = "true";
55+ is_suffix_present = "true";
4356 if(match[1]){
44- run_suffix_force_version = `--${match[1]}`
57+ if(!allowedTypes.includes(match[1])){
58+ throw new Error(`Invalid release TYPE: ${match[1]}`);
59+ }
60+ is_version_bump = "true";
61+ if(match[1] !== "auto"){
62+ force_version = `--${match[1]}`
63+ }
4564 }
4665 }
4766
48- console.dir(`Set output: run_suffix_present =${run_suffix_present }`);
49- core.setOutput("run_suffix_present ", run_suffix_present );
67+ console.dir(`Set output: is_suffix_present =${is_suffix_present }`);
68+ core.setOutput("is_suffix_present ", is_suffix_present );
5069
51- console.dir(`Set output: run_suffix_force_version=${run_suffix_force_version}`);
52- core.setOutput("run_suffix_force_version", run_suffix_force_version);
70+ console.dir(`Set output: is_version_bump=${is_version_bump}`);
71+ core.setOutput("is_version_bump", is_version_bump);
72+
73+ console.dir(`Set output: force_version=${force_version}`);
74+ core.setOutput("force_version", force_version);
5375
5476 dependence-lint :
5577 name : Depend on Lint
5981 needs :
6082 - check_conditions
6183 - dependence-lint
62- if : needs.check_conditions.outputs.run_suffix_present == 'true'
84+ if : needs.check_conditions.outputs.is_suffix_present == 'true'
6385 name : Create GitHub Release & NPM Publish
6486 runs-on : ubuntu-latest
6587 permissions :
@@ -86,20 +108,30 @@ jobs:
86108 git config --global user.name "github-actions[bot]"
87109 git config --global user.email "no-reply@todde.tv"
88110
111+ - name : Install dependencies
112+ run : pnpm install --frozen-lockfile
113+
89114 # - name: Get old `package.json` version
90115 # id: get_package_version_old
91116 # run: echo version=$(node -p "require('./package.json').version") >> $GITHUB_OUTPUT
92117
93- - name : Bump `package.json` version & generate changelog both from conventional commits
118+ - name : Bump `package.json` version depending on given TYPE from commit message
119+ if : needs.check_conditions.outputs.is_version_bump == 'true'
94120 # -from "v${{ steps.get_package_version_old.outputs.version }}"
95- run : pnpx changelogen@0.5.7 --output CHANGELOG.md -- bump --no-commit --no-tag ${{ needs.check_conditions.outputs.run_suffix_force_version }}
121+ run : pnpm changelogen --bump ${{ needs.check_conditions.outputs.force_version }} --no-commit --no-tag
96122 env :
97123 GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
98124
99125 - name : Get new `package.json` version
100126 id : get_package_version_new
101127 run : echo version=$(node -p "require('./package.json').version") >> $GITHUB_OUTPUT
102128
129+ - name : Generate changelog from conventional commits
130+ # -from "v${{ steps.get_package_version_old.outputs.version }}"
131+ run : pnpm changelogen --output CHANGELOG.md -r "${{ steps.get_package_version_new.outputs.version }}" --no-commit --no-tag
132+ env :
133+ GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
134+
103135 - name : Git add, commit & push changes made to `package.json` & `CHANGELOG.md` to `main`
104136 run : |
105137 git add .
@@ -112,14 +144,13 @@ jobs:
112144 git push origin --tags
113145
114146 - name : Sync tags with GitHub releases & create the new release
115- # run: pnpx changelogen@0.5.7 gh release "v${{ steps.get_package_version_new.outputs.version }}"
116- # run: pnpx changelogen@0.5.7 gh release
117- run : pnpx changelogen@0.5.7 gh release all
147+ # run: pnpm changelogen gh release all
148+ run : pnpm changelogen gh release "v${{ steps.get_package_version_new.outputs.version }}"
118149 env :
119150 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
120151
121- - name : Install dependencies
122- run : pnpm install --frozen-lockfile
152+ # - name: Install dependencies
153+ # run: pnpm install --frozen-lockfile
123154
124155 - name : Build the project
125156 run : pnpm run build
0 commit comments