diff --git a/.drone.yml b/.drone.yml index 8535dff..8159556 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,50 +1,65 @@ +kind: secret +name: token_github +get: + path: secrets + name: token_github_storezhang +--- + + kind: pipeline type: docker -name: # TODO +name: 发布 clone: disable: true +environment: + CHANGELOG_TAG_OUTPUT: CHANGELOG.tag.md + + steps: - name: 代码 image: ccr.ccs.tencentyun.com/dronestock/git + pull: always - name: 编译 image: ccr.ccs.tencentyun.com/pangum/drone + pull: always volumes: - name: go path: /var/lib/go settings: - output: # TODO + compress: + enabled: false + + - name: 改变 + image: ccr.ccs.tencentyun.com/dronestock/changelog + pull: always + when: + event: + - tag + settings: + output: $${CHANGELOG_TAG_OUTPUT} - name: 发布 - image: ccr.ccs.tencentyun.com/dronestock/docker - privileged: true - volumes: - - name: docker - path: /var/lib/docker + image: ccr.ccs.tencentyun.com/dronestock/github + pull: always + when: + event: + - tag environment: - PASSWORD_DOCKER: - from_secret: token_docker - PASSWORD_CCR: - from_secret: password_tencentyun_ccr + TOKEN: + from_secret: token_github settings: - repository: # TODO - registries: - - username: # TODO - password: $${PASSWORD_DOCKER} - - hostname: ccr.ccs.tencentyun.com - username: "160290688" - password: $${PASSWORD_CCR} - required: true + release: + tag: $${DRONE_TAG} + token: $${TOKEN} + body: file('$${CHANGELOG_TAG_OUTPUT}') volumes: - name: go host: path: /var/lib/cache/go - - name: docker - host: - path: /var/lib/cache/docker diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3addd99..ecb8cad 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,18 +3,7 @@ updates: - package-ecosystem: gomod directory: / schedule: - interval: weekly - pull-request-branch-name: - separator: "-" - assignees: - - storezhang - reviewers: - - storezhang - - - package-ecosystem: npm - directory: /doc - schedule: - interval: weekly + interval: daily pull-request-branch-name: separator: "-" assignees: diff --git a/generator.go b/generator.go index beaf649..2fa56a5 100644 --- a/generator.go +++ b/generator.go @@ -2,29 +2,7 @@ package pid import ( "github.com/goexl/id" - "github.com/pangum/logging" - "github.com/pangum/pangu" ) -// Generator 点位,以直接引入带替间接引入 -type Generator struct { - id.Generator -} - -func newGenerator(config *pangu.Config, logger *logging.Logger) (generator *Generator, err error) { - panguConfig := new(panguConfig) - if err = config.Load(panguConfig); nil != err { - return - } - - generator = new(Generator) - _config := panguConfig.Id - builder := id.New(id.Logger(logger)) - if nil != _config.Autoincrement { - generator.Generator = builder.Autoincrement().From(_config.Autoincrement.From).Build() - } else if nil != _config.Snowflake { - generator.Generator = builder.Snowflake(_config.Snowflake.Node).Build() - } - - return -} +// Generator 以直接引入带替间接引入 +type Generator = id.Generator diff --git a/go.mod b/go.mod index 7d18455..e7fb722 100644 --- a/go.mod +++ b/go.mod @@ -4,40 +4,40 @@ go 1.19 require ( github.com/goexl/id v0.0.2 - github.com/pangum/logging v0.1.9 - github.com/pangum/pangu v0.3.0 + github.com/pangum/logging v0.2.0 + github.com/pangum/pangu v0.3.1 ) require ( github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/drone/envsubst v1.0.3 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/go-playground/locales v0.14.0 // indirect - github.com/go-playground/universal-translator v0.18.0 // indirect - github.com/go-playground/validator/v10 v10.11.1 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.12.0 // indirect github.com/goexl/baozheng v0.0.1 // indirect github.com/goexl/env v0.0.2 // indirect github.com/goexl/exc v0.0.5 // indirect - github.com/goexl/gfx v0.1.6 // indirect - github.com/goexl/gox v0.1.6 // indirect - github.com/goexl/mengpo v0.2.3 // indirect - github.com/goexl/simaqian v0.2.1 // indirect + github.com/goexl/gfx v0.1.7 // indirect + github.com/goexl/gox v0.3.0 // indirect + github.com/goexl/mengpo v0.2.4 // indirect + github.com/goexl/simaqian v0.2.4 // indirect github.com/goexl/xiren v0.0.5 // indirect github.com/google/uuid v1.3.0 // indirect - github.com/leodido/go-urn v1.2.1 // indirect + github.com/leodido/go-urn v1.2.2 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/rs/xid v1.4.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/storezhang/dig v0.0.1 // indirect - github.com/urfave/cli/v2 v2.23.6 // indirect + github.com/urfave/cli/v2 v2.25.0 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect github.com/zs5460/art v0.2.0 // indirect go.uber.org/atomic v1.10.0 // indirect - go.uber.org/multierr v1.8.0 // indirect + go.uber.org/multierr v1.10.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.3.0 // indirect - golang.org/x/sys v0.3.0 // indirect - golang.org/x/text v0.5.0 // indirect + golang.org/x/crypto v0.7.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/new.go b/new.go new file mode 100644 index 0000000..053b66a --- /dev/null +++ b/new.go @@ -0,0 +1,24 @@ +package pid + +import ( + "github.com/goexl/id" + "github.com/pangum/logging" + "github.com/pangum/pangu" +) + +func newGenerator(config *pangu.Config, logger logging.Logger) (generator Generator, err error) { + wrap := new(wrapper) + if err = config.Load(wrap); nil != err { + return + } + + conf := wrap.Id + builder := id.New(id.Logger(logger)) + if nil != conf.Autoincrement { + generator = builder.Autoincrement().From(conf.Autoincrement.From).Build() + } else if nil != conf.Snowflake { + generator = builder.Snowflake(conf.Snowflake.Node).Build() + } + + return +} diff --git a/pangu_config.go b/wrapper.go similarity index 50% rename from pangu_config.go rename to wrapper.go index 90b0e6c..64bf7a8 100644 --- a/pangu_config.go +++ b/wrapper.go @@ -1,5 +1,5 @@ package pid -type panguConfig struct { +type wrapper struct { Id *config }