navidrome/.github/workflows/pipeline.yml

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

201 lines
5.1 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:
go-lint:
name: Lint Go code
2020-09-05 21:10:21 +02:00
runs-on: ubuntu-latest
steps:
- name: Install taglib
run: sudo apt-get install libtag1-dev
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.19
id: go
- uses: actions/checkout@v3
2020-09-05 21:10:21 +02:00
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
2020-09-05 21:10:21 +02:00
with:
version: latest
2020-09-05 21:10:21 +02:00
github-token: ${{ secrets.GITHUB_TOKEN }}
args: --timeout 2m
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports
- run: goimports -w `find . -name '*.go' | grep -v '_gen.go$'`
- run: go mod tidy
- name: Verify no changes from goimports and go mod tidy
run: |
git status --porcelain
if [ -n "$(git status --porcelain)" ]; then
exit 1
fi
2020-09-05 21:10:21 +02:00
go:
name: Test with Go ${{ matrix.go_version }}
2020-09-05 21:10:21 +02:00
runs-on: ubuntu-latest
strategy:
matrix:
go_version: [1.18.x,1.19.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 }}
uses: actions/setup-go@v3
2020-09-05 21:10:21 +02:00
with:
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@v3
2020-09-05 21:10:21 +02:00
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:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
2020-01-26 18:36:24 +01:00
with:
node-version: 16
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
2020-04-17 19:52:18 +02:00
- 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
retention-days: 7
2020-04-17 19:52:18 +02:00
binaries:
name: Build binaries
needs: [js, go, go-lint]
2020-04-17 19:52:18 +02:00
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
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
uses: docker://deluan/ci-goreleaser:1.19.3-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/')
uses: docker://deluan/ci-goreleaser:1.19.3-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
retention-days: 7
2020-04-23 02:56:04 +02:00
2020-04-17 19:52:18 +02:00
docker:
name: Build 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
- uses: actions/checkout@v3
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/386,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 .