navidrome/.github/workflows/pipeline.yml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

162 lines
4.0 KiB
YAML
Raw Normal View History

2020-04-24 00:32:51 +02:00
name: Pipeline
2020-04-25 18:12:48 +02:00
on:
push:
branches:
- master
2020-04-25 18:35:36 +02:00
tags:
- "v*"
pull_request:
branches:
- master
2020-01-26 18:36:24 +01:00
jobs:
2020-04-26 19:12:59 +02:00
golangci-lint:
name: Lint Server
runs-on: ubuntu-latest
steps:
2020-05-08 23:02:24 +02:00
- uses: actions/checkout@v2
- name: golangci-lint
2020-05-18 18:29:19 +02:00
uses: golangci/golangci-lint-action@v1
2020-04-26 19:12:59 +02:00
with:
2020-05-18 18:29:19 +02:00
version: v1.27
2020-05-08 23:02:24 +02:00
github-token: ${{ secrets.GITHUB_TOKEN }}
2020-04-26 19:12:59 +02:00
2020-04-23 02:56:04 +02:00
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
2020-04-17 19:52:18 +02:00
js:
name: Build JS bundle
2020-01-26 18:36:24 +01:00
runs-on: ubuntu-latest
steps:
2020-04-17 19:52:18 +02:00
- uses: actions/checkout@v2
2020-01-26 18:36:24 +01:00
- uses: actions/setup-node@v1
with:
2020-05-27 11:35:25 +02:00
node-version: 14
2020-04-17 19:22:11 +02:00
2020-04-17 19:52:18 +02:00
- 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
2020-01-26 18:36:24 +01:00
run: |
cd ui
npm ci
2020-04-17 19:52:18 +02:00
2020-04-26 20:48:29 +02:00
- name: npm check-formatting
run: |
cd ui
npm run check-formatting
2020-04-17 19:52:18 +02:00
- name: npm build
run: |
cd ui
2020-01-26 18:36:24 +01:00
npm run build
2020-04-17 19:22:11 +02:00
2020-04-17 19:52:18 +02:00
- uses: actions/upload-artifact@v1
with:
name: js-bundle
path: ui/build
binaries:
name: Binaries
2020-04-26 19:12:59 +02:00
needs: [js, go, golangci-lint]
2020-04-17 19:52:18 +02:00
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
2020-04-23 02:56:04 +02:00
- name: Run GoReleaser - SNAPSHOT
if: startsWith(github.ref, 'refs/tags/') != true
uses: docker://deluan/ci-goreleaser:1.14.4-2
2020-04-23 02:56:04 +02:00
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.4-2
2020-01-26 18:36:24 +01:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: goreleaser release --rm-dist
2020-04-17 19:52:18 +02:00
2020-04-23 02:56:04 +02:00
- uses: actions/upload-artifact@v1
with:
name: binaries
path: dist
2020-04-17 19:52:18 +02:00
docker:
name: Docker images
2020-04-23 02:56:04 +02:00
needs: [binaries]
2020-04-17 19:52:18 +02:00
runs-on: ubuntu-latest
env:
DOCKER_IMAGE: ${{secrets.DOCKER_IMAGE}}
2020-04-17 19:52:18 +02:00
steps:
- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
if: env.DOCKER_IMAGE != ''
2020-04-17 19:52:18 +02:00
with:
2020-05-07 15:50:01 +02:00
buildx-version: latest
qemu-version: latest
2020-04-17 19:52:18 +02:00
- uses: actions/checkout@v1
if: env.DOCKER_IMAGE != ''
2020-04-17 19:52:18 +02:00
- uses: actions/download-artifact@v1
if: env.DOCKER_IMAGE != ''
2020-04-17 19:52:18 +02:00
with:
2020-04-23 02:56:04 +02:00
name: binaries
path: dist
2020-04-17 19:52:18 +02:00
- name: Build the Docker image and push
if: env.DOCKER_IMAGE != ''
2020-04-17 19:52:18 +02:00
env:
2020-04-24 00:42:31 +02:00
DOCKER_IMAGE: ${{secrets.DOCKER_IMAGE}}
2020-04-17 19:52:18 +02:00
DOCKER_PLATFORM: linux/amd64,linux/arm/v7,linux/arm64
run: |
echo ${{secrets.DOCKER_PASSWORD}} | docker login -u ${{secrets.DOCKER_USERNAME}} --password-stdin
2020-04-23 02:56:04 +02:00
docker buildx build --platform ${DOCKER_PLATFORM} `.github/workflows/docker-tags.sh` -f .github/workflows/pipeline.dockerfile --push .