Skip to content

Commit

Permalink
up: update readme and release action
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed May 18, 2022
1 parent 02b6ba5 commit 9d268b9
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 13 deletions.
31 changes: 22 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,39 @@ jobs:
strategy:
fail-fast: true
matrix:
go: [1.17]
go_version: [1.17]

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Go Faster
uses: WillAbides/setup-go-faster@v1.7.0
timeout-minutes: 3
with:
go-version: ${{ matrix.go_version }}

- name: Setup ENV
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
run: |
echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
echo "RELEASE_NAME=$GITHUB_WORKFLOW" >> $GITHUB_ENV
- name: Display Env
run: env
- name: Generate changelog
run: |
go install github.com/gookit/gitw/cmd/chlog@latest
chlog -config .github/changelog.yml -output testdata/changelog.md prev last
# https://github.com/actions/create-release
- uses: meeDamian/github-release@2.0
# https://github.com/softprops/action-gh-release
- name: Create release and upload assets
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
gzip: false
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.RELEASE_TAG }}
name: ${{ env.RELEASE_TAG }}
# files: kite-${{ env.RELEASE_TAG }}.phar
tag_name: ${{ env.RELEASE_TAG }}
body_path: testdata/changelog.md
token: ${{ secrets.GITHUB_TOKEN }}
# files: macos-chlog.exe
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,22 +273,32 @@ fire the: clean.data

## Dump config data

> Can use `config.DumpTo()` export the configuration data to the specified `writer`, such as: buffer,file
**Dump to JSON file**

```go
buf := new(bytes.Buffer)

_, err := config.DumpTo(buf, config.JSON)

ioutil.WriteFile("my-config.json", buf.Bytes(), 0755)
```

**Pretty dump JSON**
**Dump pretty JSON**

You can set the default var `JSONMarshalIndent` or custom a new JSON driver.

```go
config.JSONMarshalIndent = " "
```

**Dump to YAML file**

```go
_, err := config.DumpTo(buf, config.YAML)
ioutil.WriteFile("my-config.yaml", buf.Bytes(), 0755)
```

## Available options

```go
Expand Down
14 changes: 12 additions & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,22 +255,32 @@ fire the: clean.data

## 导出配置到文件

> 可以使用 `config.DumpTo(out io.Writer, format string)` 将整个配置数据导出到指定的writer, 比如 buffer,file。
**示例:导出为JSON文件**

```go
buf := new(bytes.Buffer)

_, err := config.DumpTo(buf, config.JSON)

ioutil.WriteFile("my-config.json", buf.Bytes(), 0755)
```

**示例:美化导出的JSON**
**示例:导出格式化的JSON**

可以设置默认变量 `JSONMarshalIndent` 的值 或 自定义新的 JSON 驱动程序。

```go
config.JSONMarshalIndent = " "
```

**示例:导出为YAML文件**

```go
_, err := config.DumpTo(buf, config.YAML)
ioutil.WriteFile("my-config.yaml", buf.Bytes(), 0755)
```

## 可用选项

```go
Expand Down

0 comments on commit 9d268b9

Please sign in to comment.