From 3149c71aa01eb133408bcc04e53b49f90096c5dd Mon Sep 17 00:00:00 2001 From: anhoder Date: Sat, 9 Sep 2023 19:26:53 +0800 Subject: [PATCH] fix: inject --- .goreleaser.yaml | 14 +++++++------- Makefile | 2 ++ internal/configs/registry.go | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 58c3ce3..19c9787 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -18,7 +18,7 @@ builds: goos: - linux ldflags: - - -s -w -X github.com/go-musicfox/spotifox/internal/constants.AppVersion={{.Tag}} -X github.com/go-musicfox/spotifox/internal/constants.LastfmKey={{.Env.LASTFM_KEY}} -X github.com/go-musicfox/spotifox/internal/constants.LastfmSecret={{.Env.LASTFM_SECRET}} -X github.com/go-musicfox/spotifox/internal/constants.SpotifyClientId={{.Env.SPOTIFY_CLIENT_ID}} + - -s -w -X github.com/go-musicfox/spotifox/internal/types.AppVersion={{.Tag}} -X github.com/go-musicfox/spotifox/internal/types.LastfmKey={{.Env.LASTFM_KEY}} -X github.com/go-musicfox/spotifox/internal/types.LastfmSecret={{.Env.LASTFM_SECRET}} -X github.com/go-musicfox/spotifox/internal/types.SpotifyClientId={{.Env.SPOTIFY_CLIENT_ID}} - id: spotifox-linux-arm64 main: ./cmd/spotifox.go binary: spotifox @@ -34,7 +34,7 @@ builds: - LDFLAGS=-L/usr/aarch64-linux-gnu/lib:$LDFLAGS - PKG_CONFIG_PATH=/usr/aarch64-linux-gnu/lib/pkgconfig:$PKG_CONFIG_PATH ldflags: - - -s -w -X github.com/go-musicfox/spotifox/internal/constants.AppVersion={{.Tag}} -X github.com/go-musicfox/spotifox/internal/constants.LastfmKey={{.Env.LASTFM_KEY}} -X github.com/go-musicfox/spotifox/internal/constants.LastfmSecret={{.Env.LASTFM_SECRET}} -X github.com/go-musicfox/spotifox/internal/constants.SpotifyClientId={{.Env.SPOTIFY_CLIENT_ID}} + - -s -w -X github.com/go-musicfox/spotifox/internal/types.AppVersion={{.Tag}} -X github.com/go-musicfox/spotifox/internal/types.LastfmKey={{.Env.LASTFM_KEY}} -X github.com/go-musicfox/spotifox/internal/types.LastfmSecret={{.Env.LASTFM_SECRET}} -X github.com/go-musicfox/spotifox/internal/types.SpotifyClientId={{.Env.SPOTIFY_CLIENT_ID}} - id: spotifox-linux-arm main: ./cmd/spotifox.go binary: spotifox @@ -50,7 +50,7 @@ builds: - LDFLAGS=-L/usr/arm-linux-gnueabi/lib:$LDFLAGS - PKG_CONFIG_PATH=/usr/arm-linux-gnueabi/lib/pkgconfig:$PKG_CONFIG_PATH ldflags: - - -s -w -X github.com/go-musicfox/spotifox/internal/constants.AppVersion={{.Tag}} -X github.com/go-musicfox/spotifox/internal/constants.LastfmKey={{.Env.LASTFM_KEY}} -X github.com/go-musicfox/spotifox/internal/constants.LastfmSecret={{.Env.LASTFM_SECRET}} -X github.com/go-musicfox/spotifox/internal/constants.SpotifyClientId={{.Env.SPOTIFY_CLIENT_ID}} + - -s -w -X github.com/go-musicfox/spotifox/internal/types.AppVersion={{.Tag}} -X github.com/go-musicfox/spotifox/internal/types.LastfmKey={{.Env.LASTFM_KEY}} -X github.com/go-musicfox/spotifox/internal/types.LastfmSecret={{.Env.LASTFM_SECRET}} -X github.com/go-musicfox/spotifox/internal/types.SpotifyClientId={{.Env.SPOTIFY_CLIENT_ID}} - id: spotifox-windows-amd64 main: ./cmd/spotifox.go binary: spotifox @@ -59,7 +59,7 @@ builds: goos: - windows ldflags: - - -s -w -X github.com/go-musicfox/spotifox/internal/constants.AppVersion={{.Tag}} -X github.com/go-musicfox/spotifox/internal/constants.LastfmKey={{.Env.LASTFM_KEY}} -X github.com/go-musicfox/spotifox/internal/constants.LastfmSecret={{.Env.LASTFM_SECRET}} -X github.com/go-musicfox/spotifox/internal/constants.SpotifyClientId={{.Env.SPOTIFY_CLIENT_ID}} + - -s -w -X github.com/go-musicfox/spotifox/internal/types.AppVersion={{.Tag}} -X github.com/go-musicfox/spotifox/internal/types.LastfmKey={{.Env.LASTFM_KEY}} -X github.com/go-musicfox/spotifox/internal/types.LastfmSecret={{.Env.LASTFM_SECRET}} -X github.com/go-musicfox/spotifox/internal/types.SpotifyClientId={{.Env.SPOTIFY_CLIENT_ID}} env: - CC=/usr/local/mingw/bin/x86_64-w64-mingw32-gcc - CXX=/usr/local/mingw/bin/x86_64-w64-mingw32-g++ @@ -74,7 +74,7 @@ builds: goos: - windows ldflags: - - -s -w -X github.com/go-musicfox/spotifox/internal/constants.AppVersion={{.Tag}} -X github.com/go-musicfox/spotifox/internal/constants.LastfmKey={{.Env.LASTFM_KEY}} -X github.com/go-musicfox/spotifox/internal/constants.LastfmSecret={{.Env.LASTFM_SECRET}} -X github.com/go-musicfox/spotifox/internal/constants.SpotifyClientId={{.Env.SPOTIFY_CLIENT_ID}} + - -s -w -X github.com/go-musicfox/spotifox/internal/types.AppVersion={{.Tag}} -X github.com/go-musicfox/spotifox/internal/types.LastfmKey={{.Env.LASTFM_KEY}} -X github.com/go-musicfox/spotifox/internal/types.LastfmSecret={{.Env.LASTFM_SECRET}} -X github.com/go-musicfox/spotifox/internal/types.SpotifyClientId={{.Env.SPOTIFY_CLIENT_ID}} env: - CC=/usr/local/mingw/bin/aarch64-w64-mingw32-gcc - CXX=/usr/local/mingw/bin/aarch64-w64-mingw32-g++ @@ -89,7 +89,7 @@ builds: goos: - darwin ldflags: - - -s -w -X github.com/go-musicfox/spotifox/internal/constants.AppVersion={{.Tag}} -X github.com/go-musicfox/spotifox/internal/constants.LastfmKey={{.Env.LASTFM_KEY}} -X github.com/go-musicfox/spotifox/internal/constants.LastfmSecret={{.Env.LASTFM_SECRET}} -X github.com/go-musicfox/spotifox/internal/constants.SpotifyClientId={{.Env.SPOTIFY_CLIENT_ID}} + - -s -w -X github.com/go-musicfox/spotifox/internal/types.AppVersion={{.Tag}} -X github.com/go-musicfox/spotifox/internal/types.LastfmKey={{.Env.LASTFM_KEY}} -X github.com/go-musicfox/spotifox/internal/types.LastfmSecret={{.Env.LASTFM_SECRET}} -X github.com/go-musicfox/spotifox/internal/types.SpotifyClientId={{.Env.SPOTIFY_CLIENT_ID}} env: - CC=oa64-clang - CXX=oa64-clang++ @@ -101,7 +101,7 @@ builds: goos: - darwin ldflags: - - -s -w -X github.com/go-musicfox/spotifox/internal/constants.AppVersion={{.Tag}} -X github.com/go-musicfox/spotifox/internal/constants.LastfmKey={{.Env.LASTFM_KEY}} -X github.com/go-musicfox/spotifox/internal/constants.LastfmSecret={{.Env.LASTFM_SECRET}} -X github.com/go-musicfox/spotifox/internal/constants.SpotifyClientId={{.Env.SPOTIFY_CLIENT_ID}} + - -s -w -X github.com/go-musicfox/spotifox/internal/types.AppVersion={{.Tag}} -X github.com/go-musicfox/spotifox/internal/types.LastfmKey={{.Env.LASTFM_KEY}} -X github.com/go-musicfox/spotifox/internal/types.LastfmSecret={{.Env.LASTFM_SECRET}} -X github.com/go-musicfox/spotifox/internal/types.SpotifyClientId={{.Env.SPOTIFY_CLIENT_ID}} env: - CC=o64-clang - CXX=o64-clang++ diff --git a/Makefile b/Makefile index 149ed3d..303ee71 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ INJECT_PACKAGE ?= github.com/go-musicfox/spotify/pkg/constants LDFLAGS := -s -w LASTFM_KEY ?= LASTFM_SECRET ?= +SPOTIFY_CLIENT_ID ?= REGISTRY ?= GORELEASER_IMAGE ?= alanalbert/goreleaser-musicfox:$(GOLANG_CROSS_VERSION) @@ -80,6 +81,7 @@ release-debug-shell: -it \ --rm \ --privileged \ + --env-file .release-env \ -e CGO_ENABLED=1 \ -v /var/run/docker.sock:/var/run/docker.sock \ -v `pwd`:/go/src/$(PACKAGE_NAME) \ diff --git a/internal/configs/registry.go b/internal/configs/registry.go index 8ced983..fd7f1c9 100644 --- a/internal/configs/registry.go +++ b/internal/configs/registry.go @@ -141,11 +141,11 @@ func NewRegistryFromIniFile(filepath string) *Registry { registry.Main.DualColumn = ini.Bool("main.dualColumn", true) registry.Main.LastfmKey = types.LastfmKey - if key := ini.Get("main.lastfmKey"); key != "" { + if key := ini.String("main.lastfmKey"); key != "" { registry.Main.LastfmKey = key } registry.Main.LastfmSecret = types.LastfmSecret - if secret := ini.Get("main.lastfmSecret"); secret != "" { + if secret := ini.String("main.lastfmSecret"); secret != "" { registry.Main.LastfmSecret = secret }