From 7437b830a665d342c94d4705e6c5d1eb013a900d Mon Sep 17 00:00:00 2001 From: khorevaa Date: Fri, 26 Feb 2021 14:24:37 +0300 Subject: [PATCH] add go releaser & readme --- .github/workflows/goreleaser.yaml | 29 ++++++++++ .goreleaser.yaml | 18 +++++++ README.md | 89 +++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 .github/workflows/goreleaser.yaml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/goreleaser.yaml b/.github/workflows/goreleaser.yaml new file mode 100644 index 0000000..fac4887 --- /dev/null +++ b/.github/workflows/goreleaser.yaml @@ -0,0 +1,29 @@ +name: goreleaser + +on: + pull_request: + push: + tags: + - '*' +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - + name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..3760878 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,18 @@ +project_name: updateApiClient +before: + hooks: + - go mod tidy +# - docker login +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + - Merge pull request + - Merge branch +build: + skip: true +release: + github: + prerelease: auto \ No newline at end of file diff --git a/README.md b/README.md index 3a1a6bf..8fa5a69 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,91 @@ # update-api-1c Client for update-api.1c.ru + +[![go.dev][pkg-img]][pkg] [![goreport][report-img]][report] [![build][build-img]][build] [![coverage][cov-img]][cov] ![stability-stable][stability-img] + + +## How to use + +### Quick start + +```go +package main + +import ( + apiClient "github.com/v8platform/updateApiClient" + + "io" + "io/ioutil" + "log" + "os" + "path/filepath" + "strings" +) + +func main() { + + client := apiClient.NewClient("ITS_USER", "ITS_PASSWORD") + + updateInfo, err := client.GetUpdateInfo("Accounting", + "3.0.88.22", + apiClient.NewProgramOrRedactionUpdateType, "8.3.15.2107") + + if err != nil { + log.Fatal(err) + } + + updateData, err := client.GetUpdate(updateInfo.ConfigurationUpdate.ProgramVersionUin, updateInfo.ConfigurationUpdate.UpgradeSequence) + + if err != nil { + log.Fatal(err) + } + + for _, data := range updateData.ConfigurationUpdateDataList { + + updateDataFile, err := client.GetConfigurationUpdateData(data) + + if err != nil { + log.Fatal(err) + } + + log.Println("Download:", updateDataFile.UpdateFileUrl) + + distPath := strings.ReplaceAll(updateDataFile.TemplatePath, "\\", string(os.PathSeparator)) + distPath = filepath.Join(".", distPath) + log.Println("Path:", distPath) + + err = os.MkdirAll(distPath, os.ModeDir) + if err != nil { + log.Fatal(err) + } + + f, err := ioutil.TempFile("", "."+updateDataFile.UpdateFileFormat) + if err != nil { + log.Fatal(err) + } + _, err = io.Copy(f, updateDataFile) + + f.Close() + updateDataFile.Close() + + err = apiClient.UnzipFile(f.Name(), distPath) + if err != nil { + log.Fatal(err) + } + + } + +} + +``` + +[pkg-img]: http://img.shields.io/badge/godoc-reference-5272B4.svg +[pkg]: https://godoc.org/github.com/v8platform/updateApiClient +[report-img]: https://goreportcard.com/badge/github.com/v8platform/updateApiClient +[report]: https://goreportcard.com/report/github.com/v8platform/updateApiClient +[build-img]: https://github.com/v8platform/updateApiClient/workflows/goreleaser/badge.svg +[build]: https://github.com/v8platform/updateApiClient/actions +[cov-img]: http://gocover.io/_badge/github.com/v8platform/updateApiClient +[cov]: https://gocover.io/github.com/v8platform/updateApiClient +[stability-img]: https://img.shields.io/badge/stability-stable-green.svg +