diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4ab7a53..b0e6eee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,11 +13,19 @@ 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 @@ -25,14 +33,19 @@ jobs: 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 diff --git a/README.md b/README.md index 22c2f16..3660891 100644 --- a/README.md +++ b/README.md @@ -273,15 +273,18 @@ 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. @@ -289,6 +292,13 @@ You can set the default var `JSONMarshalIndent` or custom a new JSON driver. config.JSONMarshalIndent = " " ``` +**Dump to YAML file** + +```go +_, err := config.DumpTo(buf, config.YAML) +ioutil.WriteFile("my-config.yaml", buf.Bytes(), 0755) +``` + ## Available options ```go diff --git a/README.zh-CN.md b/README.zh-CN.md index 8552431..c89157c 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -255,15 +255,18 @@ 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 驱动程序。 @@ -271,6 +274,13 @@ ioutil.WriteFile("my-config.json", buf.Bytes(), 0755) config.JSONMarshalIndent = " " ``` +**示例:导出为YAML文件** + +```go +_, err := config.DumpTo(buf, config.YAML) +ioutil.WriteFile("my-config.yaml", buf.Bytes(), 0755) +``` + ## 可用选项 ```go