mirror of
https://github.com/navidrome/navidrome.git
synced 2024-09-11 12:02:51 +02:00
164 lines
4.2 KiB
YAML
164 lines
4.2 KiB
YAML
name: Pipeline
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
tags:
|
|
- "v*"
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
jobs:
|
|
golangci-lint:
|
|
name: Lint Server
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out code into the Go module directory
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Run golangci-lint
|
|
uses: actions-contrib/golangci-lint@v1
|
|
with:
|
|
golangci_lint_version: v1.25.0
|
|
# TODO Enable github actions output format: https://github.com/actions-contrib/golangci-lint/issues/11
|
|
# args: run --out-format github-actions
|
|
|
|
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
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-node@v1
|
|
with:
|
|
node-version: 13
|
|
|
|
- uses: actions/cache@v1
|
|
id: cache-npm
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-node-${{ hashFiles('ui/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-
|
|
|
|
- name: npm install dependencies
|
|
run: |
|
|
cd ui
|
|
npm ci
|
|
|
|
- name: npm check-formatting
|
|
run: |
|
|
cd ui
|
|
npm run check-formatting
|
|
|
|
- name: npm build
|
|
run: |
|
|
cd ui
|
|
npm run build
|
|
|
|
- uses: actions/upload-artifact@v1
|
|
with:
|
|
name: js-bundle
|
|
path: ui/build
|
|
|
|
binaries:
|
|
name: Binaries
|
|
needs: [js, go, golangci-lint]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Unshallow
|
|
run: git fetch --prune --unshallow
|
|
|
|
- uses: actions/download-artifact@v1
|
|
with:
|
|
name: js-bundle
|
|
path: ui/build
|
|
|
|
- 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
|
|
needs: [binaries]
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DOCKER_IMAGE: ${{secrets.DOCKER_IMAGE}}
|
|
steps:
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: crazy-max/ghaction-docker-buildx@v1
|
|
if: env.DOCKER_IMAGE != ''
|
|
with:
|
|
version: latest
|
|
|
|
- uses: actions/checkout@v1
|
|
if: env.DOCKER_IMAGE != ''
|
|
|
|
- uses: actions/download-artifact@v1
|
|
if: env.DOCKER_IMAGE != ''
|
|
with:
|
|
name: binaries
|
|
path: dist
|
|
|
|
- name: Build the Docker image and push
|
|
if: env.DOCKER_IMAGE != ''
|
|
env:
|
|
DOCKER_IMAGE: ${{secrets.DOCKER_IMAGE}}
|
|
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/pipeline.dockerfile --push .
|