ci: create versions with goreleaser

This commit is contained in:
Deluan 2020-01-26 12:36:24 -05:00
parent 4e3b13050b
commit 476c695cf1
10 changed files with 155 additions and 32 deletions

View File

@ -8,4 +8,7 @@ data
testDB
*_test.go
navidrome
navidrome.db
navidrome.toml
assets/*gen.go
dist

31
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,31 @@
name: Release
on:
create:
tags:
- v*.*.*
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v1
with:
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: 13
- name: Build UI
run: |
cd ui
npm ci
npm run build
- name: Fetch tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Run GoReleaser
uses: docker://bepsays/ci-goreleaser:1.13-4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: goreleaser release --rm-dist

1
.gitignore vendored
View File

@ -18,4 +18,3 @@ navidrome.db
*.swp
*_gen.go
dist
.goreleaser.yml

86
.goreleaser.yml Normal file
View File

@ -0,0 +1,86 @@
# GoReleaser config
before:
hooks:
- go get -u github.com/go-bindata/go-bindata/...
- go-bindata -fs -prefix ui/build -tags embed -nocompress -pkg assets -o assets/embedded_gen.go ui/build/...
- git checkout .
builds:
- id: navidrome_darwin
env:
- CGO_ENABLED=1
- CC=o64-clang
- CXX=o64-clang++
goos:
- darwin
goarch:
- amd64
flags:
- -tags=embed
ldflags:
- -X main.gitSha={{.ShortCommit}} -X main.gitTag={{.Tag}}
- id: navidrome_linux
env:
- CGO_ENABLED=1
goos:
- linux
goarch:
- amd64
flags:
- -tags=embed
ldflags:
- "-extldflags '-static'"
- -X main.gitSha={{.ShortCommit}} -X main.gitTag={{.Tag}}
- id: navidrome_windows_i686
env:
- CGO_ENABLED=1
- CC=i686-w64-mingw32-gcc
- CXX=i686-w64-mingw32-g++
goos:
- windows
goarch:
- 386
flags:
- -tags=embed
ldflags:
- "-extldflags '-static'"
- -X main.gitSha={{.ShortCommit}} -X main.gitTag={{.Tag}}
- id: navidrome_windows_x64
env:
- CGO_ENABLED=1
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
goos:
- windows
goarch:
- amd64
flags:
- -tags=embed
ldflags:
- "-extldflags '-static'"
- -X main.gitSha={{.ShortCommit}} -X main.gitTag={{.Tag}}
archives:
-
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
release:
draft: true
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

View File

@ -34,7 +34,8 @@ COPY --from=jsbuilder /src/build/* /src/ui/build/
COPY --from=jsbuilder /src/build/static/css/* /src/ui/build/static/css/
COPY --from=jsbuilder /src/build/static/js/* /src/ui/build/static/js/
RUN rm -rf /src/build/css /src/build/js
RUN make buildall
RUN go-bindata -fs -prefix ui/build -tags embed -nocompress -pkg assets -o assets/embedded_gen.go ui/build/...\
&& go build -ldflags="-X main.gitSha=${SOURCE_COMMIT} -X main.gitTag=${SOURCE_BRANCH}" -tags=embed
#####################################################
### Build Final Image

View File

@ -1,10 +1,7 @@
GO_VERSION=1.13
NODE_VERSION=v13.7.0
GIT_HASH=$(shell git rev-parse --short HEAD)
GIT_BRANCH=$(shell git symbolic-ref --short -q HEAD)
GIT_TAG=$(shell git describe --tags --abbrev=0 2> /dev/null)
GIT_COUNT=$(shell git rev-list HEAD --count)
GIT_SHA=$(shell git rev-parse --short HEAD)
.PHONY: dev
dev: check_env data
@ -72,10 +69,8 @@ assets/embedded_gen.go: ui/build
.PHONY: build
build: check_go_env
go build -ldflags="-X main.gitCount=$(GIT_COUNT) -X main.gitHash=$(GIT_HASH) -X main.gitBranch=$(GIT_BRANCH) -X main.gitTag=$(GIT_TAG)"
go build -ldflags="-X main.gitSha=$(GIT_SHA) -X main.gitTag=master"
.PHONY: buildall
buildall: check_go_env assets/embedded_gen.go
go build -ldflags="-X main.gitCount=$(GIT_COUNT) -X main.gitHash=$(GIT_HASH) -X main.gitBranch=$(GIT_BRANCH) -X main.gitTag=$(GIT_TAG)" \
-tags embed
go build -ldflags="-X main.gitSha=$(GIT_SHA) -X main.gitTag=master" -tags=embed

View File

@ -40,9 +40,21 @@ on a frequent basis. Some upcoming features planned:
## Installation
Currently there are no downloadable binaries (WIP). The available options are:
Various options are available:
### Run it with Docker
### Pre-build executables
Just head to the [releases page](https://github.com/deluan/navidrome/releases) and download the latest version for you
platform. There are builds available for Linux, macOS and Windows (32 and 64 bits).
Remember to install [ffmpeg](https://ffmpeg.org/download.html) in your system, a requirement for Navidrome to work properly.
If you have any issues with these binaries, or need a binary for a different platform, please
[open an issue](https://github.com/deluan/navidrome/issues)
### Docker
Docker images are available. Example of usage:
```yaml
# This is just an example. Customize it to your needs.
@ -65,10 +77,10 @@ services:
- "/Users/deluan/Music/iTunes/iTunes Media/Music:/music"
```
### Build it yourself / Development Environment
### Build it yourself
You will need to install [Go 1.13](https://golang.org/dl/) and [Node 13.7](http://nodejs.org).
You'll also need [ffmpeg](ffmpeg.org) installed in your system
You'll also need [ffmpeg](https://ffmpeg.org) installed in your system
After the prerequisites above are installed, build the application with:
@ -77,14 +89,16 @@ $ make setup
$ make buildall
```
This will generate the `navidrome` binary in the project's root folder. Start the server with:
This will generate the `navidrome` binary executable in the project's root folder.
### Running for the first time
Start the server with:
```shell script
./navidrome
```
The server should start listening for requests on the default port __4533__
### Running for the first time
After starting Navidrome for the first time, go to http://localhost:4533. It will ask you to create your first admin
user.

View File

@ -9,25 +9,19 @@ import (
var (
// This will be set in build time. If not, version will be set to "dev"
gitBranch string
gitTag string
gitHash string
gitCount string
gitTag string
gitSha string
)
// Formats:
// dev
// v0.2.0 (596-5b84188)
// master (600-9ed35cb)
// v0.2.0 (5b84188)
// master (9ed35cb)
func getVersion() string {
if gitHash == "" {
if gitSha == "" {
return "dev"
}
version := fmt.Sprintf(" (%s-%s)", gitCount, gitHash)
if gitTag != "" {
return gitTag + version
}
return gitBranch + version
return fmt.Sprintf("%s (%s)", gitTag, gitSha)
}
func getBanner() string {

6
ui/.gitignore vendored
View File

@ -8,9 +8,6 @@
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
@ -21,3 +18,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
build/*
!build/.gitkeep

0
ui/build/.gitkeep Normal file
View File