Skip to content

Commit

Permalink
fix: ✨ read config optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
Aimerny committed May 30, 2024
1 parent c6f350f commit 40aa060
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ jobs:

outputs:
releases_created: ${{ steps.release-please.outputs.releases_created }}
tag_name: ${{ steps.release-please.outputs[format('{0}--tag_name', steps.get-path.outputs.path)] }}
path: ${{ steps.get-path.outputs.path }}
#tag_name: ${{ steps.release-please.outputs[format('{0}--tag_name', steps.get-path.outputs.path)] }}

steps:
- name: Release Please
Expand All @@ -23,12 +22,6 @@ jobs:
config-file: .release-please/release-please-config.json
manifest-file: .release-please/.release-please-manifest.json

- name: Get Path
id: get-path
if: ${{ steps.release-please.outputs.releases_created == 'true' }}
run: |
echo "path=${{ fromJson(steps.release-please.outputs.paths_released)[0] }}" >> $GITHUB_OUTPUT
goreleaser:
runs-on: ubuntu-latest
name: release
Expand Down
4 changes: 2 additions & 2 deletions .release-please/release-please-config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"release-type": "simple",
"pull-request-title-pattern": "chore${scope}: 🔖 release${component} ${version}",
"separate-pull-requests": true,
"packages": {
"src": {
"package-name": "kook-go"
"release-type": "go",
"include-v-in-tag": true
}
}
}
7 changes: 5 additions & 2 deletions src/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ var defaultConf = &Config{
Compress: true,
}

func ReadConfig() *Config {

func ReadConfig(configPath string) *Config {
configData, err := os.ReadFile(configPath)
if err != nil {
if os.IsNotExist(err) {
Expand All @@ -37,3 +36,7 @@ func ReadConfig() *Config {
}
return conf
}

func ReadDefaultConfig() *Config {
return ReadConfig(configPath)
}
2 changes: 1 addition & 1 deletion src/core/action/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func Init() {
config := common.ReadConfig()
config := common.ReadConfig("./../../conf.json")
helper.InitHelper(config.BotToken)
common.InitLogger()
}
Expand Down
2 changes: 1 addition & 1 deletion src/example/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func main() {

common.InitLogger()
config := common.ReadConfig()
config := common.ReadDefaultConfig()

globalSession, err := session.CreateSession(config.BotToken, config.Compress)
if err != nil {
Expand Down

0 comments on commit 40aa060

Please sign in to comment.