diff --git a/.github/workflows/build-darwin.yml b/.github/workflows/build-darwin.yml new file mode 100644 index 0000000..b352958 --- /dev/null +++ b/.github/workflows/build-darwin.yml @@ -0,0 +1,37 @@ +name: Build for Darwin + +on: + workflow_call: + inputs: + output-artifact-name: + description: Name of artifact as which Darwin executable to be uploaded + required: true + type: string + +jobs: + build-darwin: + name: Build MacOS executable + runs-on: macos-latest + steps: + - name: Install Conan + run: pip3 install conan==2.0.10 + + - uses: actions/checkout@v3 + + - name: Detect conan profile + run: conan profile detect + + - name: Install conan dependencies + run: conan install . --build=missing -s build_type=Release + + - name: Invoke 'conan-release' preset + run: cmake --preset conan-release + + - name: Build the app + run: cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt && cmake --build . --config Release + + - name: Upload executable as artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.output-artifact-name }} + path: bin/lottie_to_png diff --git a/.github/workflows/build-linux-and-docker.yml b/.github/workflows/build-linux-and-docker.yml new file mode 100644 index 0000000..20d0d7a --- /dev/null +++ b/.github/workflows/build-linux-and-docker.yml @@ -0,0 +1,73 @@ +name: Build for Linux & Docker + +on: + workflow_call: + inputs: + output-artifact-name: + description: Name of artifact as which Docker image to be uploaded + required: true + type: string + arch: + description: "amd64 or arm64" + required: true + type: string + +jobs: + build-docker: + name: Build linux and docker images + runs-on: ubuntu-latest + env: + DOCKER_BUILDKIT: 1 + steps: + - uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker caching + uses: jpribyl/action-docker-layer-caching@v0.1.1 + continue-on-error: true + + - name: Build lottie-to-apng + run: docker build -t lottie-to-apng:${{ inputs.arch }} --target lottie-to-apng --platform ${{ inputs.arch }} . + + - name: Upload lottie-to-apng as artifact + uses: ishworkh/container-image-artifact-upload@v1.0.0 + with: + image: lottie-to-apng:${{ inputs.arch }} + + - name: Build lottie-to-gif + run: docker build -t lottie-to-gif:${{ inputs.arch }} --target lottie-to-gif --platform ${{ inputs.arch }} . + + - name: Upload lottie-to-gif as artifact + uses: ishworkh/container-image-artifact-upload@v1.0.0 + with: + image: lottie-to-gif:${{ inputs.arch }} + + - name: Build lottie-to-png + run: docker build -t lottie-to-png:${{ inputs.arch }} --target lottie-to-png --platform ${{ inputs.arch }} . + + - name: Upload lottie-to-png as artifact + uses: ishworkh/container-image-artifact-upload@v1.0.0 + with: + image: lottie-to-png:${{ inputs.arch }} + + - name: Build lottie-to-webp + run: docker build -t lottie-to-webp:${{ inputs.arch }} --target lottie-to-webp --platform ${{ inputs.arch }} . + + - name: Upload lottie-to-webp as artifact + uses: ishworkh/container-image-artifact-upload@v1.0.0 + with: + image: lottie-to-webp:${{ inputs.arch }} + + - name: Extract executable + run: | + id=$(docker create lottie-to-png:${{ inputs.arch }}) && + docker cp $id:/usr/bin/lottie_to_png bin/ && + docker rm -v $id + + - name: Upload executable as artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.output-artifact-name }} + path: bin/lottie_to_png diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml new file mode 100644 index 0000000..7eb1409 --- /dev/null +++ b/.github/workflows/build-windows.yml @@ -0,0 +1,37 @@ +name: Build for Windows + +on: + workflow_call: + inputs: + output-artifact-name: + description: Name of artifact as which Windows executable to be uploaded + required: true + type: string + +jobs: + build-windows: + name: Build Windows executable + runs-on: windows-latest + steps: + - name: Install Conan + run: pip3 install conan==2.0.10 + + - uses: actions/checkout@v3 + + - name: Detect conan profile + run: conan profile detect + + - name: Install conan dependencies + run: conan install . --build=missing -s build_type=Release + + - name: Invoke 'conan-default' preset + run: cmake --preset conan-default + + - name: Build the app + run: cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt && cmake --build . --config Release + + - name: Upload executable as artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.output-artifact-name }} + path: bin/Release/lottie_to_png.exe diff --git a/.github/workflows/ci-build-and-test.yml b/.github/workflows/ci-build-and-test.yml index 53a9a1e..94988ea 100644 --- a/.github/workflows/ci-build-and-test.yml +++ b/.github/workflows/ci-build-and-test.yml @@ -4,275 +4,64 @@ on: push: pull_request: +env: + linux-executable-artifact-name: lottie-to-png.linux + linux-test-results-artifact-name: test-results.linux + darwin-executable-artifact-name: lottie-to-png.darwin.amd64 + darwin-test-results-artifact-name: test-results.darwin + windows-executable-artifact-name: lottie-to-png.windows.amd64.exe + windowsarwin-test-results-artifact-name: test-results.windows + jobs: - build-docker: - name: Build docker images - runs-on: ubuntu-latest + build-docker-and-linux: + name: Build Docker image & Linux executable + uses: ./.github/workflows/build-linux-and-docker.yml strategy: matrix: - platform: - - amd64 + arch: - arm64 - env: - DOCKER_BUILDKIT: 1 - steps: - - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker caching - uses: jpribyl/action-docker-layer-caching@v0.1.1 - continue-on-error: true - - - name: Build lottie-to-apng - run: docker build -t lottie-to-apng:${{ matrix.platform }} --target lottie-to-apng --platform ${{ matrix.platform }} . - - - name: Upload lottie-to-apng as artifact - uses: ishworkh/container-image-artifact-upload@v1.0.0 - with: - image: lottie-to-apng:${{ matrix.platform }} - - - name: Build lottie-to-gif - run: docker build -t lottie-to-gif:${{ matrix.platform }} --target lottie-to-gif --platform ${{ matrix.platform }} . - - - name: Upload lottie-to-gif as artifact - uses: ishworkh/container-image-artifact-upload@v1.0.0 - with: - image: lottie-to-gif:${{ matrix.platform }} - - - name: Build lottie-to-png - run: docker build -t lottie-to-png:${{ matrix.platform }} --target lottie-to-png --platform ${{ matrix.platform }} . - - - name: Upload lottie-to-png as artifact - uses: ishworkh/container-image-artifact-upload@v1.0.0 - with: - image: lottie-to-png:${{ matrix.platform }} - - - name: Build lottie-to-webp - run: docker build -t lottie-to-webp:${{ matrix.platform }} --target lottie-to-webp --platform ${{ matrix.platform }} . - - - name: Upload lottie-to-webp as artifact - uses: ishworkh/container-image-artifact-upload@v1.0.0 - with: - image: lottie-to-webp:${{ matrix.platform }} - - - name: Extract executable - run: | - id=$(docker create lottie-to-png:${{ matrix.platform }}) && - docker cp $id:/usr/bin/lottie_to_png bin/ && - docker rm -v $id - - - name: Upload executable as artifact - uses: actions/upload-artifact@v3 - with: - name: lottie-to-png.linux.${{ matrix.platform }} - path: bin/lottie_to_png + - amd64 + with: + output-artifact-name: ${{ env.linux-executable-artifact-name }}.${{ matrix.arch }} + arch: ${{ matrix.arch }} test-docker: - name: Run tests - needs: build-docker - runs-on: ubuntu-latest + name: Run tests on Docker + needs: build-docker-and-linux + uses: ./.github/workflows/test-docker.yml strategy: matrix: - image: - - apng - - gif - - png - - webp - platform: + arch: - amd64 - arm64 - steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Download ${{ matrix.image }} image as artefact - uses: ishworkh/container-image-artifact-download@v1.0.0 - with: - image: lottie-to-${{ matrix.image }}:${{ matrix.platform }} - - - uses: actions/checkout@v3 - - - name: Run tests - run: docker run --rm -v $(pwd)/test-files:/source --platform ${{ matrix.platform }} lottie-to-${{ matrix.image }}:${{ matrix.platform }} - - - name: Upload test results as artifacts - uses: actions/upload-artifact@v3 - with: - name: test-results.linux.${{ matrix.platform }}.${{ matrix.image }} - path: test-files + with: + output-artifact-name: ${{ env.linux-test-results-artifact-name }}.${{ matrix.arch }} + arch: ${{ matrix.arch }} build-darwin: - name: Build MacOS executable - runs-on: macos-latest - steps: - - name: Install Conan - run: pip3 install conan==2.0.10 - - - uses: actions/checkout@v3 - - - name: Detect conan profile - run: conan profile detect - - - name: Install conan dependencies - run: conan install . --build=missing -s build_type=Release - - - name: Invoke 'conan-release' preset - run: cmake --preset conan-release - - - name: Build the app - run: cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt && cmake --build . --config Release - - - name: Upload executable as artifact - uses: actions/upload-artifact@v3 - with: - name: lottie-to-png.darwin.amd64 - path: bin/lottie_to_png + name: Build Darwin executable + uses: ./.github/workflows/build-darwin.yml + with: + output-artifact-name: ${{ env.darwin-executable-artifact-name }} test-darwin: - name: Test MacOS + name: Test on Darwin needs: build-darwin - runs-on: macos-latest - strategy: - matrix: - case: - - apng - - gif - - png - - webp - steps: - - uses: actions/checkout@v3 - - - name: Install run-time dependencies - run: | - [[ "${{ matrix.case }}" == "apng" ]] && brew install ffmpeg || echo ok; - [[ "${{ matrix.case }}" == "gif" ]] && brew install gifski || echo ok; - [[ "${{ matrix.case }}" == "webp" ]] && brew install webp || echo ok; - - - name: Download artifact - uses: actions/download-artifact@v3 - with: - name: lottie-to-png.darwin.amd64 - path: bin - - - name: Run tests - run: | - chmod +x bin/lottie_to_png && \ - bash -c "\ - find test-files -type f \( -iname \*.json -o -iname \*.lottie -o -iname \*.tgs \) | while IFS=$'\n' read -r FILE; do \ - echo Converting \${FILE}... && ./bin/lottie_to_${{ matrix.case }}.sh \$FILE && echo Done.; \ - done \ - " - - - name: Upload test results as artifacts - uses: actions/upload-artifact@v3 - with: - name: test-results.darwin.amd64.${{ matrix.case }} - path: test-files + uses: ./.github/workflows/test-darwin.yml + with: + input-artifact-name: ${{ env.darwin-executable-artifact-name }} + output-artifact-name: ${{ env.darwin-test-results-artifact-name }} build-windows: name: Build Windows executable - runs-on: windows-latest - steps: - - name: Install Conan - run: pip3 install conan==2.0.10 - - - uses: actions/checkout@v3 - - - name: Detect conan profile - run: conan profile detect - - - name: Install conan dependencies - run: conan install . --build=missing -s build_type=Release - - - name: Invoke 'conan-default' preset - run: cmake --preset conan-default - - - name: Build the app - run: cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt && cmake --build . --config Release - continue-on-error: true - - - name: Upload executable as artifact - uses: actions/upload-artifact@v3 - with: - name: lottie-to-png.windows.amd64.exe - path: bin/Release/lottie_to_png.exe + uses: ./.github/workflows/build-windows.yml + with: + output-artifact-name: ${{ env.windows-executable-artifact-name }} test-windows: - name: Test Windows + name: Test on Windows needs: build-windows - runs-on: windows-latest - strategy: - matrix: - case: - - apng - - gif - - png - steps: - - uses: actions/checkout@v3 - - - name: Install run-time dependencies - shell: bash - run: | - [[ "${{ matrix.case }}" == "apng" ]] && winget install ffmpeg || echo ok; - [[ "${{ matrix.case }}" == "gif" ]] && cargo install gifski || echo ok; - - - name: Download artifact - uses: actions/download-artifact@v3 - with: - name: lottie-to-png.windows.amd64.exe - path: bin - - - name: Run tests - shell: bash - run: | - bash -c "\ - find test-files -type f \( -iname \*.json -o -iname \*.lottie -o -iname \*.tgs \) | while IFS=$'\n' read -r FILE; do \ - echo Converting \${FILE}... && sh ./bin/lottie_to_${{ matrix.case }}.sh \$FILE && echo Done.; \ - done \ - " - - - name: Upload test results as artifacts - uses: actions/upload-artifact@v3 - with: - name: test-results.windows.amd64.${{ matrix.case }} - path: test-files - - release: - name: Release executables - needs: - - test-darwin - - test-windows - - test-docker - runs-on: ubuntu-latest - strategy: - matrix: - file: - - linux.amd64 - - linux.arm64 - - darwin.amd64 - - windows.amd64.exe - env: - filename: lottie-converter.${{ matrix.file }}.zip - steps: - - uses: actions/checkout@v3 - - - name: Extract - uses: dawidd6/action-download-artifact@v2 - with: - name: lottie-to-png.${{ matrix.file }} - path: bin - - - name: Archive Release - uses: thedoctor0/zip-release@0.7.1 - with: - type: 'zip' - path: bin - filename: ${{ env.filename }} - - - name: Release - uses: softprops/action-gh-release@v1 - with: - files: ${{ env.filename }} - draft: true + uses: ./.github/workflows/test-windows.yml + with: + input-artifact-name: ${{ env.windows-executable-artifact-name }} + output-artifact-name: ${{ env.windows-test-results-artifact-name }} diff --git a/.github/workflows/test-darwin.yml b/.github/workflows/test-darwin.yml new file mode 100644 index 0000000..4d4dc54 --- /dev/null +++ b/.github/workflows/test-darwin.yml @@ -0,0 +1,54 @@ +name: Test on Darwin + +on: + workflow_call: + inputs: + input-artifact-name: + description: Name of artifact as which Darwin executable is uploaded + required: true + type: string + output-artifact-name: + description: Name of artifact as which Darwin test results to be uploaded + required: true + type: string + +jobs: + test-darwin: + name: Test on Darwin + runs-on: macos-latest + strategy: + matrix: + case: + - apng + - gif + - png + - webp + steps: + - uses: actions/checkout@v3 + + - name: Install run-time dependencies + run: | + [[ "${{ matrix.case }}" == "apng" ]] && brew install ffmpeg || echo ok; + [[ "${{ matrix.case }}" == "gif" ]] && brew install gifski || echo ok; + [[ "${{ matrix.case }}" == "webp" ]] && brew install webp || echo ok; + + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.input-artifact-name }} + path: bin + + - name: Run tests + run: | + chmod +x bin/lottie_to_png && \ + bash -c "\ + find test-files -type f \( -iname \*.json -o -iname \*.lottie -o -iname \*.tgs \) | while IFS=$'\n' read -r FILE; do \ + echo Converting \${FILE}... && ./bin/lottie_to_${{ matrix.case }}.sh \$FILE && echo Done.; \ + done \ + " + + - name: Upload test results as artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.output-artifact-name }}.${{ matrix.case }} + path: test-files diff --git a/.github/workflows/test-docker.yml b/.github/workflows/test-docker.yml new file mode 100644 index 0000000..c689ecf --- /dev/null +++ b/.github/workflows/test-docker.yml @@ -0,0 +1,44 @@ +name: Test in Docker + +on: + workflow_call: + inputs: + arch: + description: "amd64 or arm64" + required: true + type: string + output-artifact-name: + description: Name of artifact as which Docker test results to be uploaded + required: true + type: string + +jobs: + test-docker: + name: Run docker tests + runs-on: ubuntu-latest + strategy: + matrix: + image: + - apng + - gif + - png + - webp + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Download ${{ matrix.image }} image as artefact + uses: ishworkh/container-image-artifact-download@v1.0.0 + with: + image: lottie-to-${{ matrix.image }}:${{ inputs.arch }} + + - uses: actions/checkout@v3 + + - name: Run tests + run: docker run --rm -v $(pwd)/test-files:/source --platform ${{ inputs.arch }} lottie-to-${{ matrix.image }}:${{ inputs.arch }} + + - name: Upload test results as artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.output-artifact-name }}.${{ matrix.image }} + path: test-files diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml new file mode 100644 index 0000000..0aed3ec --- /dev/null +++ b/.github/workflows/test-windows.yml @@ -0,0 +1,53 @@ +name: Tes in Windows + +on: + workflow_call: + inputs: + input-artifact-name: + description: Name of artifact as which Windows executable is uploaded + required: true + type: string + output-artifact-name: + description: Name of artifact as which Windows test results to be uploaded + required: true + type: string + +jobs: + test-windows: + name: Test Windows + runs-on: windows-latest + strategy: + matrix: + case: + - apng + - gif + - png + steps: + - uses: actions/checkout@v3 + + - name: Install run-time dependencies + shell: bash + run: | + [[ "${{ matrix.case }}" == "apng" ]] && winget install ffmpeg || echo ok; + [[ "${{ matrix.case }}" == "gif" ]] && cargo install gifski || echo ok; + + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.input-artifact-name }} + path: bin + + - name: Run tests + shell: bash + run: | + bash -c "\ + find test-files -type f \( -iname \*.json -o -iname \*.lottie -o -iname \*.tgs \) | while IFS=$'\n' read -r FILE; do \ + echo Converting \${FILE}... && sh ./bin/lottie_to_${{ matrix.case }}.sh \$FILE && echo Done.; \ + done \ + " + + - name: Upload test results as artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{inputs.output-artifact-name }}.${{ matrix.case }} + path: test-files