Skip to content

Commit

Permalink
Unify GH actions
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Apr 23, 2020
1 parent f7b3ff4 commit 00384a6
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 175 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ navidrome
navidrome.db
navidrome.toml
assets/*gen.go
dist

51 changes: 0 additions & 51 deletions .github/workflows/Dockerfile.pipeline

This file was deleted.

108 changes: 0 additions & 108 deletions .github/workflows/build.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/pipeline.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#####################################################
### Copy platform specific binary
FROM bash as copy-binary
ARG TARGETPLATFORM

RUN echo "Target Platform = ${TARGETPLATFORM}"

COPY dist .
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then cp navidrome_linux_musl_amd64_linux_amd64/navidrome /navidrome; fi
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then cp navidrome_linux_arm64_linux_arm64/navidrome /navidrome; fi
RUN if [ "$TARGETPLATFORM" = "linux/arm/v6" ]; then cp navidrome_linux_arm_linux_arm_6/navidrome /navidrome; fi
RUN if [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then cp navidrome_linux_arm_linux_arm_7/navidrome /navidrome; fi


#####################################################
### Build Final Image
FROM alpine as release
LABEL maintainer="deluan@navidrome.org"

# Install ffmpeg and output build config
RUN apk add --no-cache ffmpeg
RUN ffmpeg -buildconf

COPY --from=copy-binary /navidrome /app/
RUN chmod +x /app/navidrome

VOLUME ["/data", "/music"]
ENV ND_MUSICFOLDER /music
ENV ND_DATAFOLDER /data
ENV ND_SCANINTERVAL 1m
ENV ND_TRANSCODINGCACHESIZE 100MB
ENV ND_SESSIONTIMEOUT 30m
ENV ND_LOGLEVEL info
ENV ND_PORT 4533

EXPOSE ${ND_PORT}
HEALTHCHECK CMD wget -O- http://localhost:${ND_PORT}/ping || exit 1
WORKDIR /app

ENTRYPOINT ["/app/navidrome"]
69 changes: 54 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
name: Release
on:
push:
branches:
- master
tags:
- "v*"
on: push
jobs:
go:
name: Test Server on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# TODO Fix tests in Windows
# os: [macOS-latest, ubuntu-latest, windows-latest]
os: [macOS-latest, ubuntu-latest]

steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- uses: actions/cache@v1
id: cache-go
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download dependencies
if: steps.cache-go.outputs.cache-hit != 'true'
run: go mod download

- name: Test
run: go test -cover ./... -v
js:
name: Build JS bundle
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -41,8 +68,7 @@ jobs:

binaries:
name: Binaries
if: startsWith(github.ref, 'refs/tags/')
needs: [js]
needs: [js, go]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
Expand All @@ -56,17 +82,30 @@ jobs:
name: js-bundle
path: ui/build

- name: Run GoReleaser
- name: Run GoReleaser - SNAPSHOT
if: startsWith(github.ref, 'refs/tags/') != true
uses: docker://deluan/ci-goreleaser:1.14.1-1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: goreleaser release --rm-dist --skip-publish --snapshot

- name: Run GoReleaser - RELEASE
if: startsWith(github.ref, 'refs/tags/')
uses: docker://deluan/ci-goreleaser:1.14.1-1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: goreleaser release --rm-dist

- uses: actions/upload-artifact@v1
with:
name: binaries
path: dist

docker:
name: Docker images
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'
needs: [js]
needs: [binaries]
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
Expand All @@ -79,13 +118,13 @@ jobs:

- uses: actions/download-artifact@v1
with:
name: js-bundle
path: ui/build
name: binaries
path: dist

- name: Build the Docker image and push
env:
DOCKER_IMAGE: deluan/deluan
DOCKER_PLATFORM: linux/amd64,linux/arm/v7,linux/arm64
run: |
echo ${{secrets.DOCKER_PASSWORD}} | docker login -u ${{secrets.DOCKER_USERNAME}} --password-stdin
docker buildx build --platform ${DOCKER_PLATFORM} `.github/workflows/docker-tags.sh` -f .github/workflows/Dockerfile.pipeline --push .
docker buildx build --platform ${DOCKER_PLATFORM} `.github/workflows/docker-tags.sh` -f .github/workflows/pipeline.dockerfile --push .
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# GoReleaser config
project_name: navidrome

before:
hooks:
Expand Down

0 comments on commit 00384a6

Please sign in to comment.