2020-04-24 00:32:51 +02:00
|
|
|
name: Pipeline
|
2020-04-25 18:12:48 +02:00
|
|
|
on:
|
2020-04-25 18:06:05 +02:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
2020-04-25 18:35:36 +02:00
|
|
|
tags:
|
|
|
|
- "v*"
|
2020-04-25 18:06:05 +02:00
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- master
|
2020-01-26 18:36:24 +01:00
|
|
|
jobs:
|
2021-10-01 21:32:24 +02:00
|
|
|
go-lint:
|
2021-09-09 06:26:56 +02:00
|
|
|
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
|
|
|
|
|
2023-02-16 04:21:50 +01:00
|
|
|
- name: Set up Go 1.20
|
2022-09-27 04:44:54 +02:00
|
|
|
uses: actions/setup-go@v3
|
2021-10-01 21:32:24 +02:00
|
|
|
with:
|
2023-02-16 04:27:03 +01:00
|
|
|
go-version: 1.20.1
|
2021-10-01 21:32:24 +02:00
|
|
|
|
2022-09-27 04:44:54 +02:00
|
|
|
- uses: actions/checkout@v3
|
2020-09-05 21:10:21 +02:00
|
|
|
|
|
|
|
- name: golangci-lint
|
2022-09-27 04:44:54 +02:00
|
|
|
uses: golangci/golangci-lint-action@v3
|
2020-09-05 21:10:21 +02:00
|
|
|
with:
|
2022-09-27 04:44:54 +02:00
|
|
|
version: latest
|
2020-09-05 21:10:21 +02:00
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
args: --timeout 2m
|
|
|
|
|
2021-10-01 21:32:24 +02:00
|
|
|
- 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-03-07 01:38:20 +01:00
|
|
|
echo 'To fix this check, run "goimports -w $(find . -name '*.go' | grep -v '_gen.go$') && go mod tidy"'
|
2021-10-01 21:32:24 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-09-05 21:10:21 +02:00
|
|
|
go:
|
2021-09-09 06:26:56 +02:00
|
|
|
name: Test with Go ${{ matrix.go_version }}
|
2020-09-05 21:10:21 +02:00
|
|
|
runs-on: ubuntu-latest
|
2021-02-03 20:39:59 +01:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-02-07 20:27:11 +01:00
|
|
|
go_version: [1.20.x,1.19.x]
|
2020-09-05 21:10:21 +02:00
|
|
|
steps:
|
|
|
|
- name: Install taglib
|
|
|
|
run: sudo apt-get install libtag1-dev
|
|
|
|
|
|
|
|
- name: Check out code into the Go module directory
|
2022-09-27 04:44:54 +02:00
|
|
|
uses: actions/checkout@v3
|
2020-09-05 21:10:21 +02:00
|
|
|
|
2022-11-26 20:11:39 +01:00
|
|
|
- name: Set up Go ${{ matrix.go_version }}
|
|
|
|
uses: actions/setup-go@v3
|
2020-09-05 21:10:21 +02:00
|
|
|
with:
|
2022-11-26 20:11:39 +01:00
|
|
|
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'
|
2021-02-03 20:39:59 +01:00
|
|
|
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
|
2021-02-03 20:39:59 +01:00
|
|
|
continue-on-error: ${{contains(matrix.go_version, 'beta') || contains(matrix.go_version, 'rc')}}
|
2023-03-23 01:12:12 +01:00
|
|
|
run: go test -shuffle=on -race -cover ./... -v
|
2021-10-01 21:32:24 +02:00
|
|
|
|
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:
|
2022-09-27 04:44:54 +02:00
|
|
|
- uses: actions/checkout@v3
|
2022-11-26 20:11:39 +01:00
|
|
|
- uses: actions/setup-node@v3
|
2020-01-26 18:36:24 +01:00
|
|
|
with:
|
2021-09-19 04:09:16 +02:00
|
|
|
node-version: 16
|
2021-09-19 04:05:57 +02:00
|
|
|
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
|
|
|
|
2021-05-25 15:58:06 +02:00
|
|
|
- name: npm lint
|
2020-04-26 20:48:29 +02:00
|
|
|
run: |
|
|
|
|
cd ui
|
2021-05-25 15:58:06 +02:00
|
|
|
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
|
|
|
|
2022-11-26 20:11:39 +01:00
|
|
|
- uses: actions/upload-artifact@v3
|
2020-04-17 19:52:18 +02:00
|
|
|
with:
|
|
|
|
name: js-bundle
|
|
|
|
path: ui/build
|
2021-05-28 05:39:20 +02:00
|
|
|
retention-days: 7
|
2020-04-17 19:52:18 +02:00
|
|
|
|
|
|
|
binaries:
|
2021-09-09 06:26:56 +02:00
|
|
|
name: Build binaries
|
2021-10-01 21:32:24 +02:00
|
|
|
needs: [js, go, go-lint]
|
2020-04-17 19:52:18 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout Code
|
2022-09-27 04:44:54 +02:00
|
|
|
uses: actions/checkout@v3
|
2020-07-21 23:37:36 +02:00
|
|
|
with:
|
2020-07-22 00:12:59 +02:00
|
|
|
fetch-depth: 0
|
2020-04-17 19:52:18 +02:00
|
|
|
|
2022-11-26 20:11:39 +01:00
|
|
|
- uses: actions/download-artifact@v3
|
2020-04-17 19:52:18 +02:00
|
|
|
with:
|
|
|
|
name: js-bundle
|
|
|
|
path: ui/build
|
|
|
|
|
2023-01-25 21:35:01 +01:00
|
|
|
- name: Config /github/workspace folder as trusted
|
2023-02-16 04:21:50 +01:00
|
|
|
uses: docker://deluan/ci-goreleaser:1.20.1-1
|
2023-01-25 21:35:01 +01:00
|
|
|
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
|
2023-02-16 04:21:50 +01:00
|
|
|
uses: docker://deluan/ci-goreleaser:1.20.1-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/')
|
2023-02-16 04:21:50 +01:00
|
|
|
uses: docker://deluan/ci-goreleaser:1.20.1-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
|
|
|
|
2022-11-26 20:11:39 +01:00
|
|
|
- uses: actions/upload-artifact@v3
|
2020-04-23 02:56:04 +02:00
|
|
|
with:
|
|
|
|
name: binaries
|
2020-07-21 22:07:36 +02:00
|
|
|
path: |
|
|
|
|
dist
|
|
|
|
!dist/*.tar.gz
|
|
|
|
!dist/*.zip
|
2021-05-28 05:39:20 +02:00
|
|
|
retention-days: 7
|
2020-04-23 02:56:04 +02:00
|
|
|
|
2020-04-17 19:52:18 +02:00
|
|
|
docker:
|
2021-09-09 06:26:56 +02:00
|
|
|
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
|
2020-04-26 21:34:24 +02:00
|
|
|
env:
|
|
|
|
DOCKER_IMAGE: ${{secrets.DOCKER_IMAGE}}
|
2020-04-17 19:52:18 +02:00
|
|
|
steps:
|
2021-02-08 19:36:00 +01:00
|
|
|
- name: Set up QEMU
|
|
|
|
id: qemu
|
2022-11-26 20:11:39 +01:00
|
|
|
uses: docker/setup-qemu-action@v2
|
2021-02-08 19:36:00 +01:00
|
|
|
if: env.DOCKER_IMAGE != ''
|
|
|
|
|
2020-04-17 19:52:18 +02:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
id: buildx
|
2022-11-26 20:11:39 +01:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2020-04-27 20:59:12 +02:00
|
|
|
if: env.DOCKER_IMAGE != ''
|
2020-04-17 19:52:18 +02:00
|
|
|
|
2022-09-27 04:44:54 +02:00
|
|
|
- uses: actions/checkout@v3
|
2020-04-27 20:59:12 +02:00
|
|
|
if: env.DOCKER_IMAGE != ''
|
2020-04-17 19:52:18 +02:00
|
|
|
|
2022-11-26 20:11:39 +01:00
|
|
|
- uses: actions/download-artifact@v3
|
2020-04-27 20:59:12 +02:00
|
|
|
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
|
2020-04-27 20:59:12 +02:00
|
|
|
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}}
|
2021-07-24 13:51:12 +02:00
|
|
|
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 .
|