From 1716c25f79cf009e548815f040b37041b412a3a7 Mon Sep 17 00:00:00 2001 From: Nicolas MARTEAU Date: Fri, 5 Jul 2024 10:35:34 +0200 Subject: [PATCH] chore: improve build.yml --- .github/workflows/build.yml | 19 +++++++++---------- package.json | 3 ++- platform/Dockerfile | 10 ++++++++++ 3 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 platform/Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 08ada2a..7bf7c1b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,17 +13,14 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04, macos-11, windows-2019] include: - os: ubuntu-22.04 - dockerfile: ./npm/linux-x64/Dockerfile - platform: linux-x64 - - os: ubuntu-22.04 - dockerfile: ./npm/linuxmusl-x64/Dockerfile platform: linuxmusl-x64 + - os: ubuntu-22.04 + platform: linux-x64 - os: macos-11 platform: darwin-x64 - - os: windows-2019 + - os: windows-2020 platform: windows-x64 steps: @@ -42,9 +39,9 @@ jobs: run: mkdir release - name: Build with Docker (${{ matrix.platform }}) - if: contains(matrix.os, 'ubuntu') && matrix.dockerfile != '' + if: contains(matrix.os, 'ubuntu') run: | - docker build -t ${{ matrix.platform }} -f ${{ matrix.dockerfile }} . + docker build --build-arg PLATFORM=${{ matrix.platform }} --build-arg LIBHEIF_V=v1.17.6 -t test . -f ./platform/Dockerfile docker run --name ${{ matrix.platform }} ${{ matrix.platform }} docker cp ${{ matrix.platform }}:/heif-converter/src/build/Release/converter.node ./release/converter.${{ matrix.platform }}.node docker container rm ${{ matrix.platform }} @@ -63,10 +60,12 @@ jobs: # cp ./src/build/Release/converter.node ./src/build/Release/converter-windows-x64.node - name: Create tarball of the release folder - run: tar -czf ${{ matrix.platform }}.tar.gz -C release . + run: | + cd ./release + tar -czf ${{ matrix.platform }}.tar.gz * - name: Upload artifact uses: actions/upload-artifact@v2 with: name: release - path: ${{ matrix.platform }}.tar.gz + path: ./release/${{ matrix.platform }}.tar.gz diff --git a/package.json b/package.json index 28956c4..3c6fa55 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "types": "index.d.ts", "main": "index.js", "scripts": { - "test": "node --test test/test.spec.js" + "test": "node --test test/test.spec.js", + "build": "node-gyp configure --directory=src && node-gyp build --directory=src" }, "publishConfig": { "@myunisoft:registry": "https://registry.npmjs.org/" diff --git a/platform/Dockerfile b/platform/Dockerfile new file mode 100644 index 0000000..c94b0cf --- /dev/null +++ b/platform/Dockerfile @@ -0,0 +1,10 @@ +ARG PLATFORM +ARG LIBHEIF_V +FROM myunisoft91/heif-converter.$PLATFORM:$LIBHEIF_V +LABEL maintainer="Nicolas Marteau " + +WORKDIR heif-converter +COPY . . +RUN npm install && \ + npm run build && \ + npm run test \ No newline at end of file