navidrome/.github/workflows/pipeline.yml

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

231 lines
6.1 KiB
YAML
Raw Normal View History

name: "Pipeline: Test, Lint, Build"
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: Update ubuntu repo
run: sudo apt-get update
2020-09-05 21:10:21 +02:00
- name: Install taglib
run: sudo apt-get install libtag1-dev
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- uses: actions/checkout@v4
2020-09-05 21:10:21 +02:00
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
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
2023-06-19 17:15:51 +02:00
echo 'To fix this check, run "make format" and commit the changes'
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.22.x, 1.21.x]
2020-09-05 21:10:21 +02:00
steps:
- name: Update ubuntu repo
run: sudo apt-get update
2020-09-05 21:10:21 +02:00
- name: Install taglib
run: sudo apt-get install libtag1-dev ffmpeg
2020-09-05 21:10:21 +02:00
- name: Check out code into the Go module directory
uses: actions/checkout@v4
2020-09-05 21:10:21 +02:00
- name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v5
2020-09-05 21:10:21 +02:00
with:
go-version: ${{ matrix.go_version }}
cache: true
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')}}
run: go test -shuffle=on -race -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@v4
- uses: actions/setup-node@v4
2020-01-26 18:36:24 +01:00
with:
node-version: 20
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@v4
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@v4
with:
2020-07-22 00:12:59 +02:00
fetch-depth: 0
2020-04-17 19:52:18 +02:00
- uses: actions/download-artifact@v4
2020-04-17 19:52:18 +02:00
with:
name: js-bundle
path: ui/build
- name: Config /github/workspace folder as trusted
uses: docker://deluan/ci-goreleaser:1.22.0-1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: /bin/bash -c "git config --global --add safe.directory /github/workspace; git describe --dirty --always --tags"
2020-07-21 21:38:23 +02:00
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.22.0-1
2020-04-23 02:56:04 +02:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
2023-11-25 00:08:34 +01:00
args: goreleaser release --clean --skip=publish --snapshot
2020-04-23 02:56:04 +02:00
- name: Run GoReleaser - RELEASE
if: startsWith(github.ref, 'refs/tags/')
uses: docker://deluan/ci-goreleaser:1.22.0-1
2020-01-26 18:36:24 +01:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
2023-11-25 00:08:34 +01:00
args: goreleaser release --clean
2020-04-17 19:52:18 +02:00
- uses: actions/upload-artifact@v4
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:
2023-04-11 15:15:08 +02:00
name: Build and publish 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@v3
if: env.DOCKER_IMAGE != ''
2020-04-17 19:52:18 +02:00
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
if: env.DOCKER_IMAGE != ''
2020-04-17 19:52:18 +02:00
- uses: actions/checkout@v4
if: env.DOCKER_IMAGE != ''
2020-04-17 19:52:18 +02:00
- uses: actions/download-artifact@v4
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: Login to Docker Hub
if: env.DOCKER_IMAGE != ''
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
if: env.DOCKER_IMAGE != ''
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
if: env.DOCKER_IMAGE != ''
id: meta
uses: docker/metadata-action@v5
with:
labels: |
maintainer=deluan
images: |
name=${{secrets.DOCKER_IMAGE}}
name=ghcr.io/${{ github.repository }}
tags: |
type=ref,event=pr
type=semver,pattern={{version}}
type=raw,value=develop,enable={{is_default_branch}}
- name: Build and Push
if: env.DOCKER_IMAGE != ''
uses: docker/build-push-action@v5
with:
context: .
file: .github/workflows/pipeline.dockerfile
platforms: linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}