Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ ARG GOCC
ARG GOARCH
ARG GOAMD64
ARG GOARM
ARG VERSION

WORKDIR /src
ENV CGO_ENABLED=1 PKG_CONFIG_PATH="/build/vcpkg_installed/$TRIPLET/lib/pkgconfig" CC="$GOCC" \
GOARCH="$GOARCH" GOAMD64="$GOAMD64" GOARM="$GOARM" \
GOCACHE=/src/.gocache/go-build GOMODCACHE=/src/.gocache/mod
CMD ["go", "build", "-o", "./go-librespot", "-a", "-ldflags", "-s -w", "./cmd/daemon"]
CMD ["go", "build", "-o", "./go-librespot", "-a", "-ldflags", "-s -w -X github.com/devgianlu/go-librespot.version=$VERSION", "./cmd/daemon"]
5 changes: 5 additions & 0 deletions crosscompile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ if [ -z "$VARIANT" ]; then
exit 1
fi

# Get the tag associated with the current commit
VERSION="$(git tag --points-at HEAD)"
VERSION="${VERSION#v}"

# Validate and map variant to compilation envs
if [ "$VARIANT" = "x86_64" ]; then
TARGET="x86-64-linux-gnu"
Expand Down Expand Up @@ -47,6 +51,7 @@ DOCKER_IMAGE_NAME="go-librespot-build-${VARIANT}"
# Build the image for cross-compilation
docker build \
--build-arg "TARGET=$TARGET" \
--build-arg "VERSION=$VERSION" \
--build-arg "TRIPLET=$TRIPLET" \
--build-arg "GOARCH=$GOARCH" \
--build-arg "GOAMD64=$GOAMD64" \
Expand Down
8 changes: 2 additions & 6 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

const SpotifyVersionCode = 125200442

var commit, version string
var version string

// Extract and return the commit hash stored in the binary, if available.
func commitHash() string {
Expand All @@ -26,8 +26,6 @@ func commitHash() string {
func VersionNumberString() string {
if len(version) > 0 {
return strings.TrimPrefix(version, "v")
} else if len(commit) >= 8 {
return commit[:8]
} else if commit := commitHash(); len(commit) >= 8 {
return commit[:8]
} else {
Expand All @@ -37,9 +35,7 @@ func VersionNumberString() string {

func SpotifyLikeClientVersion() string {
if len(version) > 0 {
if len(commit) >= 8 {
return fmt.Sprintf("%s.g%s", version, commit[:8])
} else if commit := commitHash(); len(commit) >= 8 {
if commit := commitHash(); len(commit) >= 8 {
return fmt.Sprintf("%s.g%s", version, commit[:8])
} else {
return version
Expand Down