Skip to content

Commit b90d981

Browse files
feat: build for release
1 parent e23f277 commit b90d981

File tree

3 files changed

+142
-8
lines changed

3 files changed

+142
-8
lines changed

README.ja.md

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ jobs:
6161
6262
[対象イベントの詳細](#action-%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88%E8%A9%B3%E7%B4%B0)
6363
64+
## CLI ツール
65+
[![technote-space/release-github-actions-cli - GitHub](https://gh-card.dev/repos/technote-space/release-github-actions-cli.svg)](https://github.com/technote-space/release-github-actions-cli)
66+
6467
## スクリーンショット
6568
1. リリース作成前
6669
![Before publish release](https://raw.githubusercontent.com/technote-space/release-github-actions/images/screenshot-1.png)
@@ -91,9 +94,6 @@ jobs:
9194
| ORIGINAL_TAG_PREFIX | 元のタグを残す際に付与するプリフィックス | | | `original/` |
9295
| GITHUB_TOKEN | アクセストークン | `${{github.token}}` | true | `${{secrets.ACCESS_TOKEN}}` |
9396

94-
## CLI ツール
95-
[![technote-space/release-github-actions-cli - GitHub](https://gh-card.dev/repos/technote-space/release-github-actions-cli.svg)](https://github.com/technote-space/release-github-actions-cli)
96-
9797
## Execute commands
9898
### ビルド
9999
- `build`、 `production`、 `prod` または `package` が package.json の scripts に含まれる場合、ビルド用のコマンドとしてそれを使用します。([BUILD_COMMAND_TARGET](#build_command_target) で変更可能です)
@@ -131,7 +131,74 @@ rm -rdf __tests__ src
131131
https://github.com/actions/typescript-action
132132
https://github.com/actions/javascript-action
133133

134-
不要なファイルが削除された`GitHub Actions`の例を以下で確認できます。
134+
ただし上記テンプレートにはセキュリティ上の問題などがあるため、以下の対応が必要です。
135+
136+
#### JavaScriptのActionテンプレート
137+
138+
プルリクエストにビルドしたファイルが含まれる場合、悪意のあるコードが埋め込まれていてもレビューで見逃す可能性が高いため、`.gitignore` を次のように修正する必要があります。
139+
140+
`.gitignore`
141+
```diff
142+
+ /dist
143+
```
144+
145+
#### TypeScriptのActionテンプレート
146+
147+
`ncc` による処理は不要なため、コマンド及びパッケージを削除し `tsc` でビルドされたスクリプトを使用するように修正します。
148+
149+
`action.yml`
150+
```diff
151+
name: 'Your name here'
152+
description: 'Provide a description here'
153+
author: 'Your name or organization here'
154+
inputs:
155+
myInput: # change this
156+
description: 'input description here'
157+
default: 'default value if applicable'
158+
runs:
159+
using: 'node12'
160+
- main: 'dist/index.js'
161+
+ main: 'lib/main.js'
162+
```
163+
164+
`package.json`
165+
```diff
166+
"scripts": {
167+
"build": "tsc",
168+
"format": "prettier --write **/*.ts",
169+
"format-check": "prettier --check **/*.ts",
170+
"lint": "eslint src/**/*.ts",
171+
- "pack": "ncc build",
172+
- "test": "jest",
173+
- "all": "npm run build && npm run format && npm run lint && npm run pack && npm test"
174+
+ "test": "jest"
175+
},
176+
```
177+
178+
```diff
179+
"devDependencies": {
180+
"@types/jest": "^24.0.23",
181+
"@types/node": "^12.7.12",
182+
"@typescript-eslint/parser": "^2.8.0",
183+
- "@zeit/ncc": "^0.20.5",
184+
"eslint": "^5.16.0",
185+
"eslint-plugin-github": "^2.0.0",
186+
"eslint-plugin-jest": "^22.21.0",
187+
"jest": "^24.9.0",
188+
"jest-circus": "^24.9.0",
189+
"js-yaml": "^3.13.1",
190+
"prettier": "^1.19.1",
191+
"ts-jest": "^24.2.0",
192+
"typescript": "^3.6.4"
193+
}
194+
```
195+
196+
または、私が作成したテンプレートを使用してください。
197+
198+
[![technote-space/gh-actions-template - GitHub](https://gh-card.dev/repos/technote-space/gh-actions-template.svg)](https://github.com/technote-space/gh-actions-template)
199+
200+
201+
不要なファイルが削除された`GitHub Actions`の例は以下で確認できます。
135202
https://github.com/technote-space/release-github-actions/tree/gh-actions
136203

137204
## Action イベント詳細

README.md

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ jobs:
6161
6262
[More details of target event](#action-event-details)
6363
64+
## CLI Tool
65+
[![technote-space/release-github-actions-cli - GitHub](https://gh-card.dev/repos/technote-space/release-github-actions-cli.svg)](https://github.com/technote-space/release-github-actions-cli)
66+
6467
## Screenshots
6568
1. Before publish release
6669
![Before publish release](https://raw.githubusercontent.com/technote-space/release-github-actions/images/screenshot-1.png)
@@ -91,9 +94,6 @@ jobs:
9194
| ORIGINAL_TAG_PREFIX | Prefix to add when leaving the original tag | | | `original/` |
9295
| GITHUB_TOKEN | Access token | `${{github.token}}` | true | `${{secrets.ACCESS_TOKEN}}` |
9396

94-
## CLI Tool
95-
[![technote-space/release-github-actions-cli - GitHub](https://gh-card.dev/repos/technote-space/release-github-actions-cli.svg)](https://github.com/technote-space/release-github-actions-cli)
96-
9797
## Execute commands
9898
### Build
9999
- If package.json includes `build`, `production`, `prod` or `package` in scripts, the command is used for build. (You can change this with [BUILD_COMMAND_TARGET](#build_command_target))
@@ -132,6 +132,73 @@ The default setting assumes the use of `Action template for TypeScript` or `Acti
132132
https://github.com/actions/typescript-action
133133
https://github.com/actions/javascript-action
134134

135+
However, these templates have security issues etc, you must do the following.
136+
137+
#### Action template for JavaScript
138+
139+
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:
140+
141+
`.gitignore`
142+
```diff
143+
+ /dist
144+
```
145+
146+
#### Action template for TypeScript
147+
148+
Since processing by `ncc` is unnecessary, delete the related commands and packages and modify `action.yml` to use script built with `tsc`.
149+
150+
`action.yml`
151+
```diff
152+
name: 'Your name here'
153+
description: 'Provide a description here'
154+
author: 'Your name or organization here'
155+
inputs:
156+
myInput: # change this
157+
description: 'input description here'
158+
default: 'default value if applicable'
159+
runs:
160+
using: 'node12'
161+
- main: 'dist/index.js'
162+
+ main: 'lib/main.js'
163+
```
164+
165+
`package.json`
166+
```diff
167+
"scripts": {
168+
"build": "tsc",
169+
"format": "prettier --write **/*.ts",
170+
"format-check": "prettier --check **/*.ts",
171+
"lint": "eslint src/**/*.ts",
172+
- "pack": "ncc build",
173+
- "test": "jest",
174+
- "all": "npm run build && npm run format && npm run lint && npm run pack && npm test"
175+
+ "test": "jest"
176+
},
177+
```
178+
179+
```diff
180+
"devDependencies": {
181+
"@types/jest": "^24.0.23",
182+
"@types/node": "^12.7.12",
183+
"@typescript-eslint/parser": "^2.8.0",
184+
- "@zeit/ncc": "^0.20.5",
185+
"eslint": "^5.16.0",
186+
"eslint-plugin-github": "^2.0.0",
187+
"eslint-plugin-jest": "^22.21.0",
188+
"jest": "^24.9.0",
189+
"jest-circus": "^24.9.0",
190+
"js-yaml": "^3.13.1",
191+
"prettier": "^1.19.1",
192+
"ts-jest": "^24.2.0",
193+
"typescript": "^3.6.4"
194+
}
195+
```
196+
197+
Or use the template I created.
198+
199+
[![technote-space/gh-actions-template - GitHub](https://gh-card.dev/repos/technote-space/gh-actions-template.svg)](https://github.com/technote-space/gh-actions-template)
200+
201+
135202
You can see an example of `GitHub Actions` with unnecessary files deleted below.
136203
https://github.com/technote-space/release-github-actions/tree/gh-actions
137204

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":"fe6606a6d57c93f83f8b04700152cb91b1361928","ref":"refs/tags/v4.0.0","tagName":"v4.0.0","branch":"releases/v4","tags":["v4.0.0","v4.0","v4"],"updated_at":"2020-03-06T06:25:39.130Z"}
1+
{"owner":"technote-space","repo":"release-github-actions","sha":"d006c8e6c345aa104db8e546b2ad1e902f9a2ec1","ref":"refs/tags/test/v4.0.1","tagName":"test/v4.0.1","branch":"releases/v4","tags":["test/v4.0.1","test/v4.0","test/v4"],"updated_at":"2020-03-07T19:23:44.658Z"}

0 commit comments

Comments
 (0)