mirror of
https://github.com/navidrome/navidrome.git
synced 2024-08-28 13:31:28 +02:00
192 lines
4.9 KiB
YAML
192 lines
4.9 KiB
YAML
name: Pipeline
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
tags:
|
|
- "v*"
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
jobs:
|
|
go-lint:
|
|
name: Lint Go code
|
|
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
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: golangci-lint
|
|
uses: golangci/golangci-lint-action@v3
|
|
with:
|
|
version: latest
|
|
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
|
|
|
|
go:
|
|
name: Test with Go ${{ matrix.go_version }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
go_version: [1.18.x,1.19.x]
|
|
steps:
|
|
- name: Install taglib
|
|
run: sudo apt-get install libtag1-dev
|
|
|
|
- name: Check out code into the Go module directory
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Go ${{ matrix.go_version }}
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: ${{ matrix.go_version }}
|
|
cache: true
|
|
|
|
- name: Download dependencies
|
|
if: steps.cache-go.outputs.cache-hit != 'true'
|
|
continue-on-error: ${{contains(matrix.go_version, 'beta') || contains(matrix.go_version, 'rc')}}
|
|
run: go mod download
|
|
|
|
- name: Test
|
|
continue-on-error: ${{contains(matrix.go_version, 'beta') || contains(matrix.go_version, 'rc')}}
|
|
run: go test -race -cover ./... -v
|
|
|
|
js:
|
|
name: Build JS bundle
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
NODE_OPTIONS: '--max_old_space_size=4096'
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 16
|
|
cache: 'npm'
|
|
cache-dependency-path: '**/package-lock.json'
|
|
|
|
- name: npm install dependencies
|
|
run: |
|
|
cd ui
|
|
npm ci
|
|
|
|
- name: npm lint
|
|
run: |
|
|
cd ui
|
|
npm run check-formatting && npm run lint
|
|
|
|
- name: npm test
|
|
run: |
|
|
cd ui
|
|
npm test
|
|
|
|
- name: npm build
|
|
run: |
|
|
cd ui
|
|
npm run build
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: js-bundle
|
|
path: ui/build
|
|
retention-days: 7
|
|
|
|
binaries:
|
|
name: Build binaries
|
|
needs: [js, go, go-lint]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
name: js-bundle
|
|
path: ui/build
|
|
|
|
- name: Show Tags
|
|
run: git tag
|
|
|
|
- name: Show Version
|
|
run: git describe --tags
|
|
|
|
- name: Run GoReleaser - SNAPSHOT
|
|
if: startsWith(github.ref, 'refs/tags/') != true
|
|
uses: docker://deluan/ci-goreleaser:1.19.3-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.19.3-1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
args: goreleaser release --rm-dist
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: binaries
|
|
path: |
|
|
dist
|
|
!dist/*.tar.gz
|
|
!dist/*.zip
|
|
retention-days: 7
|
|
|
|
docker:
|
|
name: Build Docker images
|
|
needs: [binaries]
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DOCKER_IMAGE: ${{secrets.DOCKER_IMAGE}}
|
|
steps:
|
|
- name: Set up QEMU
|
|
id: qemu
|
|
uses: docker/setup-qemu-action@v2
|
|
if: env.DOCKER_IMAGE != ''
|
|
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
if: env.DOCKER_IMAGE != ''
|
|
|
|
- uses: actions/checkout@v3
|
|
if: env.DOCKER_IMAGE != ''
|
|
|
|
- uses: actions/download-artifact@v3
|
|
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/386,linux/arm/v6,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 .
|