Skip to content

Commit 2a41cf2

Browse files
feat: build for release
1 parent 1864da1 commit 2a41cf2

File tree

5 files changed

+56
-149
lines changed

5 files changed

+56
-149
lines changed

README.ja.md

Lines changed: 4 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
| name | description | default | required | e.g. |
7373
|:---:|:---|:---:|:---:|:---:|
7474
| BUILD_COMMAND | ビルド用コマンド<br>[コマンドの詳細](#execute-commands) | | | `yarn build:all` |
75-
| CLEAN_TARGETS | リリース前に掃除するファイルやディレクトリ (カンマ区切り)<br>絶対パスや `..` は使用できません<br>[コマンドの詳細](#execute-commands) |`.[!.]*,__tests__,docs,src,*.js,*.ts,*.json,*.lock,*.yml,*.yaml` | true | `.[!.]*,*.txt` |
75+
| CLEAN_TARGETS | リリース前に掃除するファイルやディレクトリ (カンマ区切り)<br>絶対パスや `..` は使用できません<br>[コマンドの詳細](#execute-commands) |`.[!.]*,__tests__,docs,src,*.[jt]s,*.[mc][jt]s,*.json,*.lock,*.yml,*.yaml` | true | `.[!.]*,*.txt` |
7676
| PACKAGE_MANAGER | 依存関係のインストールに使用するパッケージマネージャー<br>`yarn.lock` や `package-lock.json` がある場合は自動で使用するパッケージマネージャーを決定しますが、このオプションで強制することができます<br>(`npm` または `yarn`) | | | `yarn` |
7777
| COMMIT_MESSAGE | コミット時に設定するメッセージ | `feat: build for release` | true | `feat: release` |
7878
| COMMIT_NAME | コミット時に設定する名前 | `github-actions[bot]` | true | |
@@ -117,12 +117,14 @@ yarn install --production
117117
そして `GitHub Actions` は使用されるたびにダウンロードされるため、ファイルは少ないほうが良いです。
118118

119119
`CLEAN_TARGETS` オプションはこの目的のために使用されます。
120-
default: `.[!.]*,__tests__,docs,src,*.js,*.ts,*.json,*.lock,*.yml,*.yaml`
120+
default: `.[!.]*,__tests__,docs,src,*.[jt]s,*.[mc][jt]s,*.json,*.lock,*.yml,*.yaml`
121121

122122
```shell
123123
rm -rdf .[!.]*
124124
rm -rdf *.js
125+
rm -rdf *.mjs
125126
rm -rdf *.ts
127+
rm -rdf *.cts
126128
rm -rdf *.json
127129
rm -rdf *.lock
128130
rm -rdf *.yml
@@ -132,75 +134,6 @@ rm -rdf __tests__ docs src
132134

133135
(action.yml は削除の対象ではありません)
134136

135-
このデフォルト値は「TypeScriptのActionテンプレート」や「JavaScriptのActionテンプレート」の使用を想定した値になっています。
136-
https://github.com/actions/typescript-action
137-
https://github.com/actions/javascript-action
138-
139-
ただし上記テンプレートにはセキュリティ上の問題などがあるため、以下の対応が必要です。
140-
141-
#### JavaScriptのActionテンプレート
142-
143-
プルリクエストにビルドしたファイルが含まれる場合、悪意のあるコードが埋め込まれていてもレビューで見逃す可能性が高いため、`.gitignore` を次のように修正する必要があります。
144-
145-
`.gitignore`
146-
```diff
147-
+ /dist
148-
```
149-
150-
#### TypeScriptのActionテンプレート
151-
152-
`ncc` による処理は不要なため、コマンド及びパッケージを削除し `tsc` でビルドされたスクリプトを使用するように修正します。
153-
154-
`action.yml`
155-
```diff
156-
name: 'Your name here'
157-
description: 'Provide a description here'
158-
author: 'Your name or organization here'
159-
inputs:
160-
myInput: # change this
161-
description: 'input description here'
162-
default: 'default value if applicable'
163-
runs:
164-
using: 'node12'
165-
- main: 'dist/index.js'
166-
+ main: 'lib/main.js'
167-
```
168-
169-
`package.json`
170-
```diff
171-
"scripts": {
172-
"build": "tsc",
173-
"format": "prettier --write **/*.ts",
174-
"format-check": "prettier --check **/*.ts",
175-
"lint": "eslint src/**/*.ts",
176-
- "package": "ncc build --source-map --license licenses.txt",
177-
- "test": "jest",
178-
- "all": "npm run build && npm run format && npm run lint && npm run package && npm test"
179-
+ "test": "jest"
180-
},
181-
```
182-
183-
```diff
184-
"devDependencies": {
185-
"@types/jest": "^26.0.10",
186-
"@types/node": "^14.6.0",
187-
"@typescript-eslint/parser": "^3.10.1",
188-
- "@vercel/ncc": "^0.23.0",
189-
"eslint": "^7.7.0",
190-
"eslint-plugin-github": "^4.1.1",
191-
"eslint-plugin-jest": "^23.20.0",
192-
"jest": "^24.9.0",
193-
"jest-circus": "^26.4.2",
194-
"js-yaml": "^3.14.0",
195-
"prettier": "2.1.1",
196-
"ts-jest": "^24.3.0",
197-
"typescript": "^4.0.2"
198-
}
199-
```
200-
201-
不要なファイルが削除された`GitHub Actions`の例は以下で確認できます。
202-
https://github.com/technote-space/release-github-actions/tree/gh-actions
203-
204137
## Action イベント詳細
205138
### 対象イベント
206139
| eventName: action | condition |

README.md

Lines changed: 4 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
| name | description | default | required | e.g. |
7373
|:---:|:---|:---:|:---:|:---:|
7474
| BUILD_COMMAND | Build command<br>[More details of execute command](#execute-commands) | | | `yarn build:all` |
75-
| CLEAN_TARGETS | Files or directories to clean before release (Comma separated)<br>Absolute path and `..` are not permitted to use.<br>[More details of execute command](#execute-commands) | `.[!.]*,__tests__,docs,src,*.js,*.ts,*.json,*.lock,*.yml,*.yaml` | true | `.[!.]*,*.txt` |
75+
| CLEAN_TARGETS | Files or directories to clean before release (Comma separated)<br>Absolute path and `..` are not permitted to use.<br>[More details of execute command](#execute-commands) | `.[!.]*,__tests__,docs,src,*.[jt]s,*.[mc][jt]s,*.json,*.lock,*.yml,*.yaml` | true | `.[!.]*,*.txt` |
7676
| PACKAGE_MANAGER | Package manager to use to install dependencies<br>If there is `yarn.lock` or` package-lock.json`, the action automatically determines the package manager to use, but this option can be used to specify it explicitly.<br>(`npm` or `yarn`) | | | `yarn` |
7777
| COMMIT_MESSAGE | Commit message | `feat: build for release` | true | `feat: release` |
7878
| COMMIT_NAME | Commit name | `github-actions[bot]` | true | |
@@ -118,12 +118,14 @@ To execute `GitHub Actions`, `src files used for build`, `test files`, `test set
118118
And `GitHub Actions` is downloaded every time when it is used, so fewer files are better.
119119

120120
`CLEAN_TARGETS` option is used for this purpose.
121-
default: `.[!.]*,__tests__,docs,src,*.js,*.ts,*.json,*.lock,*.yml,*.yaml`
121+
default: `.[!.]*,__tests__,docs,src,*.[jt]s,*.[mc][jt]s,*.json,*.lock,*.yml,*.yaml`
122122

123123
```shell
124124
rm -rdf .[!.]*
125125
rm -rdf *.js
126+
rm -rdf *.mjs
126127
rm -rdf *.ts
128+
rm -rdf *.cts
127129
rm -rdf *.json
128130
rm -rdf *.lock
129131
rm -rdf *.yml
@@ -133,75 +135,6 @@ rm -rdf __tests__ docs src
133135

134136
(action.yml is not subject to deletion.)
135137

136-
The default setting assumes the use of `Action template for TypeScript` or `Action template for JavaScript`.
137-
https://github.com/actions/typescript-action
138-
https://github.com/actions/javascript-action
139-
140-
However, these templates have security issues etc, you must do the following.
141-
142-
#### Action template for JavaScript
143-
144-
If a pull request includes a built file, it is highly likely that even malicious code will be missed in a review, so you need to fix `.gitignore` as follows:
145-
146-
`.gitignore`
147-
```diff
148-
+ /dist
149-
```
150-
151-
#### Action template for TypeScript
152-
153-
Since processing by `ncc` is unnecessary, delete the related commands and packages and modify `action.yml` to use script built with `tsc`.
154-
155-
`action.yml`
156-
```diff
157-
name: 'Your name here'
158-
description: 'Provide a description here'
159-
author: 'Your name or organization here'
160-
inputs:
161-
myInput: # change this
162-
description: 'input description here'
163-
default: 'default value if applicable'
164-
runs:
165-
using: 'node12'
166-
- main: 'dist/index.js'
167-
+ main: 'lib/main.js'
168-
```
169-
170-
`package.json`
171-
```diff
172-
"scripts": {
173-
"build": "tsc",
174-
"format": "prettier --write **/*.ts",
175-
"format-check": "prettier --check **/*.ts",
176-
"lint": "eslint src/**/*.ts",
177-
- "package": "ncc build --source-map --license licenses.txt",
178-
- "test": "jest",
179-
- "all": "npm run build && npm run format && npm run lint && npm run package && npm test"
180-
+ "test": "jest"
181-
},
182-
```
183-
184-
```diff
185-
"devDependencies": {
186-
"@types/jest": "^26.0.10",
187-
"@types/node": "^14.6.0",
188-
"@typescript-eslint/parser": "^3.10.1",
189-
- "@vercel/ncc": "^0.23.0",
190-
"eslint": "^7.7.0",
191-
"eslint-plugin-github": "^4.1.1",
192-
"eslint-plugin-jest": "^23.20.0",
193-
"jest": "^24.9.0",
194-
"jest-circus": "^26.4.2",
195-
"js-yaml": "^3.14.0",
196-
"prettier": "2.1.1",
197-
"ts-jest": "^24.3.0",
198-
"typescript": "^4.0.2"
199-
}
200-
```
201-
202-
You can see an example of `GitHub Actions` with unnecessary files deleted below.
203-
https://github.com/technote-space/release-github-actions/tree/gh-actions
204-
205138
## Action event details
206139
### Target events
207140
| eventName: action | condition |

build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"owner":"technote-space","repo":"release-github-actions","sha":"FETCH_HEAD","ref":"refs/heads/master","tagName":"test/v7.2.5","branch":"gh-actions","tags":["test/v7.2.5","test/v7.2","test/v7"],"updated_at":"2022-10-13T18:36:29.906Z"}
1+
{"owner":"technote-space","repo":"release-github-actions","sha":"FETCH_HEAD","ref":"refs/heads/master","tagName":"test/v8.0.1","branch":"gh-actions","tags":["test/v8.0.1","test/v8.0","test/v8"],"updated_at":"2022-10-14T13:48:04.314Z"}

node_modules/.yarn-integrity

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rollup.config.mjs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import pluginCommonjs from '@rollup/plugin-commonjs';
2+
import pluginJson from '@rollup/plugin-json';
3+
import pluginNodeResolve from '@rollup/plugin-node-resolve';
4+
import pluginTypescript from '@rollup/plugin-typescript';
5+
6+
const common = {
7+
plugins: [
8+
pluginTypescript(),
9+
pluginNodeResolve(),
10+
pluginCommonjs(),
11+
pluginJson(),
12+
],
13+
};
14+
15+
export default [
16+
{
17+
...common,
18+
input: 'src/main.ts',
19+
output: {
20+
file: 'lib/main.js',
21+
format: 'cjs',
22+
},
23+
},
24+
{
25+
...common,
26+
input: 'src/index.ts',
27+
output: {
28+
file: 'lib/index.cjs',
29+
format: 'cjs',
30+
},
31+
},
32+
{
33+
...common,
34+
input: 'src/index.ts',
35+
output: {
36+
file: 'lib/index.mjs',
37+
format: 'es',
38+
},
39+
},
40+
];

0 commit comments

Comments
 (0)