From 6d2d72e007aa04e6213f7d1d43acce49d426bcfe Mon Sep 17 00:00:00 2001 From: emeric Date: Thu, 2 Sep 2021 12:37:35 +0200 Subject: [PATCH] Switched from Travis CI to github actions --- .dockerignore | 1 + .github/workflows/build.yml | 38 +++++++++++++++++++++ Dockerfile-build | 44 +++++++++++++++++++++++++ docker/Dockerfile => Dockerfile-release | 13 +++----- README.md | 2 +- 5 files changed, 88 insertions(+), 10 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/build.yml create mode 100644 Dockerfile-build rename docker/Dockerfile => Dockerfile-release (90%) diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..378eac25 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +build diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..6d23fd62 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,38 @@ +name: Build +on: [push, pull_request] +jobs: + Build: + strategy: + matrix: + BUILD_TYPE: [Release, Debug] + runs-on: ubuntu-latest + steps: + - name: Check Out Repo + uses: actions/checkout@v2 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Build + uses: docker/build-push-action@v2 + with: + context: ./ + file: ./Dockerfile-build + builder: ${{ steps.buildx.outputs.name }} + build-args: LMS_BUILD_TYPE=${{ matrix.BUILD_TYPE }} + push: false + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + platforms: linux/amd64,linux/arm/v6 diff --git a/Dockerfile-build b/Dockerfile-build new file mode 100644 index 00000000..9f5b0824 --- /dev/null +++ b/Dockerfile-build @@ -0,0 +1,44 @@ +FROM alpine:3.13 AS build + +WORKDIR /tmp/workdir + +ARG MAKEFLAGS="-j2" + +ARG PREFIX="/tmp/install" + +ARG BUILD_PACKAGES=" \ + ca-certificates \ + curl \ + coreutils \ + bzip2 \ + pkgconfig \ + g++ \ + ffmpeg-dev \ + make \ + cmake \ + boost-dev \ + libconfig-dev \ + taglib-dev \ + wt-dev \ + gtest-dev" + +RUN apk add --no-cache --update ${BUILD_PACKAGES} + +# STB +ARG STB_VERSION=b42009b3b9d4ca35bc703f5310eedc74f584be58 +RUN \ + DIR=/tmp/stb && mkdir -p ${DIR} && cd ${DIR} && \ + curl -sLO https://github.com/nothings/stb/archive/${STB_VERSION}.tar.gz && \ + tar -x --strip-components=1 -f ${STB_VERSION}.tar.gz && \ + mkdir -p ${PREFIX}/include/stb && \ + cp ./*.h ${PREFIX}/include/stb + +# LMS +COPY . /tmp/lms/ +ARG LMS_BUILD_TYPE="Release" +RUN \ + DIR=/tmp/lms/build && mkdir -p ${DIR} && cd ${DIR} && \ + CXXFLAGS="-I${PREFIX}/include" cmake /tmp/lms/ -DCMAKE_BUILD_TYPE=${LMS_BUILD_TYPE} && \ + VERBOSE=1 make && \ + make test + diff --git a/docker/Dockerfile b/Dockerfile-release similarity index 90% rename from docker/Dockerfile rename to Dockerfile-release index 6528beac..a3ee5277 100644 --- a/docker/Dockerfile +++ b/Dockerfile-release @@ -101,20 +101,15 @@ RUN \ cp ./*.h ${PREFIX}/include/stb # LMS -ARG LMS_VERSION=v3.25.2 +COPY . /tmp/lms/ RUN \ - DIR=/tmp/lms && mkdir -p ${DIR} && cd ${DIR} && \ - curl -sL https://github.com/epoupon/lms/archive/${LMS_VERSION}.tar.gz -o ${LMS_VERSION}.tar.gz && \ - tar -x --strip-components=1 -f ${LMS_VERSION}.tar.gz - -RUN \ - DIR=/tmp/lms && mkdir -p ${DIR} && cd ${DIR} && \ - PKG_CONFIG_PATH=/tmp/install/lib/pkgconfig CXXFLAGS="-I${PREFIX}/include" LDFLAGS="-L${PREFIX}/lib -Wl,--rpath-link=${PREFIX}/lib" cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${PREFIX} -DCMAKE_PREFIX_PATH=${PREFIX} && \ + DIR=/tmp/lms/build && mkdir -p ${DIR} && cd ${DIR} && \ + PKG_CONFIG_PATH=/tmp/install/lib/pkgconfig CXXFLAGS="-I${PREFIX}/include" LDFLAGS="-L${PREFIX}/lib -Wl,--rpath-link=${PREFIX}/lib" cmake /tmp/lms/ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${PREFIX} -DCMAKE_PREFIX_PATH=${PREFIX} && \ LD_LIBRARY_PATH=${PREFIX}/lib VERBOSE=1 make && \ LD_LIBRARY_PATH=${PREFIX}/lib make test && \ make install && \ mkdir -p ${PREFIX}/etc/ && \ - cp conf/lms.conf ${PREFIX}/etc + cp /tmp/lms/conf/lms.conf ${PREFIX}/etc # Now copy all the stuff installed in a new folder (/tmp/fakeroot/) RUN \ diff --git a/README.md b/README.md index 6dc0a0ef..98f14067 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # LMS - Lightweight Music Server -![GitHub release (latest by date)](https://img.shields.io/github/v/release/epoupon/lms) [![Build Status](https://travis-ci.org/epoupon/lms.svg?branch=master)](https://travis-ci.org/epoupon/lms) [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/epoupon/lms.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/epoupon/lms/context:cpp) +[![Last Release](https://img.shields.io/github/v/release/epoupon/lms?logo=github&label=latest)](https://github.com/epoupon/lms/releases) [![Build](https://img.shields.io/github/workflow/status/epoupon/lms/Build?logo=github)](https://github.com/epoupon/lms/actions) [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/epoupon/lms.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/epoupon/lms/context:cpp) _LMS_ is a self-hosted music streaming software: access your music collection from anywhere using a web interface!