navidrome/.github/workflows/pipeline.yml

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

187 lines
4.8 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-09-05 21:10:21 +02:00
golangci-lint:
name: Lint Server
runs-on: ubuntu-latest
steps:
- name: Install taglib
run: sudo apt-get install libtag1-dev
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
2020-09-05 21:10:21 +02:00
with:
version: v1.40
2020-09-05 21:10:21 +02:00
github-token: ${{ secrets.GITHUB_TOKEN }}
args: --timeout 2m
go:
name: Test Server with Go ${{ matrix.go_version }}
2020-09-05 21:10:21 +02:00
runs-on: ubuntu-latest
strategy:
matrix:
go_version: [1.16.x]
2020-09-05 21:10:21 +02:00
steps:
- name: Install taglib
run: sudo apt-get install libtag1-dev
- name: Set up Go ${{ matrix.go_version }}
2020-10-12 17:58:38 +02:00
uses: actions/setup-go@v2
2020-09-05 21:10:21 +02:00
with:
stable: '!contains(${{ matrix.go_version }}, "beta") && !contains(${{ matrix.go_version }}, "rc")'
go-version: ${{ matrix.go_version }}
2020-09-05 21:10:21 +02:00
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
2020-10-12 17:58:38 +02:00
- uses: actions/cache@v2
2020-09-05 21:10:21 +02:00
id: cache-go
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.go_version }}-${{ hashFiles('**/go.sum') }}
2020-09-05 21:10:21 +02:00
restore-keys: |
${{ runner.os }}-go-${{ matrix.go_version }}-
2020-09-05 21:10:21 +02:00
- name: Download dependencies
if: steps.cache-go.outputs.cache-hit != 'true'
continue-on-error: ${{contains(matrix.go_version, 'beta') || contains(matrix.go_version, 'rc')}}
2020-09-05 21:10:21 +02:00
run: go mod download
- name: Test
continue-on-error: ${{contains(matrix.go_version, 'beta') || contains(matrix.go_version, 'rc')}}
2020-09-05 21:10:21 +02:00
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
2021-02-01 22:40:55 +01:00
env:
NODE_OPTIONS: '--max_old_space_size=4096'
2020-01-26 18:36:24 +01:00
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:
2021-05-25 16:53:16 +02:00
node-version: 16
2020-04-17 19:22:11 +02:00
2020-10-12 17:58:38 +02:00
- uses: actions/cache@v2
2020-04-17 19:52:18 +02:00
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
- name: npm lint
2020-04-26 20:48:29 +02:00
run: |
cd ui
npm run check-formatting && npm run lint
2020-04-26 20:48:29 +02:00
2020-11-11 02:45:04 +01:00
- name: npm test
run: |
cd ui
npm test
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
- uses: actions/upload-artifact@v2
2020-04-17 19:52:18 +02:00
with:
name: js-bundle
path: ui/build
binaries:
name: Binaries
2020-10-27 20:58:27 +01: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
with:
2020-07-22 00:12:59 +02:00
fetch-depth: 0
2020-04-17 19:52:18 +02:00
- uses: actions/download-artifact@v2
2020-04-17 19:52:18 +02:00
with:
name: js-bundle
path: ui/build
2020-07-21 21:38:23 +02:00
- name: Show Tags
run: git tag
- name: Show Version
run: git describe --tags
2020-04-23 02:56:04 +02:00
- name: Run GoReleaser - SNAPSHOT
if: startsWith(github.ref, 'refs/tags/') != true
2021-05-14 20:31:07 +02:00
uses: docker://deluan/ci-goreleaser:1.16.4-1
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/')
2021-05-14 20:31:07 +02:00
uses: docker://deluan/ci-goreleaser:1.16.4-1
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
- uses: actions/upload-artifact@v2
2020-04-23 02:56:04 +02:00
with:
name: binaries
path: |
dist
!dist/*.tar.gz
!dist/*.zip
2020-04-23 02:56:04 +02:00
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 QEMU
id: qemu
uses: docker/setup-qemu-action@v1
if: env.DOCKER_IMAGE != ''
2020-04-17 19:52:18 +02:00
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
if: env.DOCKER_IMAGE != ''
2020-04-17 19:52:18 +02:00
2020-10-12 17:58:38 +02:00
- uses: actions/checkout@v2
if: env.DOCKER_IMAGE != ''
2020-04-17 19:52:18 +02:00
- uses: actions/download-artifact@v2
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}}
DOCKER_PLATFORM: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
2020-04-17 19:52:18 +02:00
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 .