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 5fdb944
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
11 changes: 3 additions & 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 @@ -22,12 +21,7 @@ jobs:
with:
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
skip-github-release: false

goreleaser:
runs-on: ubuntu-latest
Expand All @@ -50,6 +44,7 @@ jobs:
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
workdir: src/
version: latest
args: release --clean
env:
Expand Down
2 changes: 1 addition & 1 deletion .release-please/.release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"src": "0.1.10"
"src": "0.2.0"
}
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
}
}
}
1 change: 1 addition & 0 deletions src/.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ before:
release:
draft: true
discussion_category_name: General
replace_existing_artifacts: true
builds:
- main: example/example.go
id: kook-go
Expand Down
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 5fdb944

Please sign in to comment.