ci: update build.yml to run on macos #71
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Retrieve Compiled Files | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, reopened, synchronize] | |
jobs: | |
push_on_main: | |
if: github.event_name == 'push' | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-22.04 | |
platform: linuxmusl-x64 | |
- os: ubuntu-22.04 | |
platform: linux-x64 | |
- os: macos-12 | |
platform: darwin-x64 | |
- os: windows-latest | |
platform: win32-x64 | |
- os: windows-latest | |
platform: win32-ia32 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: Install dependencies and test | |
run: | | |
npm install | |
npm run test | |
pull_request: | |
if: github.event_name == 'pull_request' | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
# - os: ubuntu-22.04 | |
# platform: linuxmusl-x64 | |
# - os: ubuntu-22.04 | |
# platform: linux-x64 | |
- os: macos-12 | |
platform: darwin-x64 | |
# - os: windows-latest | |
# platform: win32-x64 | |
# - os: windows-latest | |
# platform: win32-ia32 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Create a folder for the tarball | |
run: | | |
mkdir release | |
cd release | |
mkdir lib | |
- name: Build and run Docker container | |
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'windows') | |
run: | | |
# Build image | |
docker build --build-arg PLATFORM=${{ matrix.PLATFORM }} -t ${{ matrix.PLATFORM }} . -f ./.github/Dockerfile | |
# Run container and copy the built file | |
docker run --name ${{ matrix.PLATFORM }} ${{ matrix.PLATFORM }} | |
# Copy .node file from the container | |
docker cp ${{ matrix.PLATFORM }}:/heif-converter/src/build/Release/converter.node ./release/lib/converter.${{ matrix.PLATFORM }}.node | |
- name: Copy .dll files from the container (Windows) | |
if: contains(matrix.os, 'windows') | |
env: | |
SRC_PATH: /heif-converter/src/build/Release | |
run: | | |
docker cp ${{ matrix.PLATFORM }}:${{ env.SRC_PATH }}/heif.dll ./release/lib/heif.dll | |
docker cp ${{ matrix.PLATFORM }}:${{ env.SRC_PATH }}/turbojpeg.dll ./release/lib/turbojpeg.dll | |
docker cp ${{ matrix.PLATFORM }}:${{ env.SRC_PATH }}/jpeg62.dll ./release/lib/jpeg62.dll | |
docker cp ${{ matrix.PLATFORM }}:${{ env.SRC_PATH }}/libde265.dll ./release/lib/libde265.dll | |
docker cp ${{ matrix.PLATFORM }}:${{ env.SRC_PATH }}/libx265.dll ./release/lib/libx265.dll | |
docker cp ${{ matrix.PLATFORM }}:${{ env.SRC_PATH }}/libpng16.dll ./release/lib/libpng16.dll | |
docker cp ${{ matrix.PLATFORM }}:${{ env.SRC_PATH }}/zlib1.dll ./release/lib/zlib1.dll | |
- name: Clean up the Docker container (Windows and Linux) | |
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'windows') | |
run: docker container rm ${{ matrix.PLATFORM }} | |
- name: Configure and Build on OSX | |
if: contains(matrix.os, 'mac') | |
run: | | |
brew update | |
brew install llvm | |
brew link --force --overwrite llvm | |
brew install make | |
brew link --force --overwrite make | |
# Build project | |
npm install | |
npm run configure | |
npm run build | |
# Run tests | |
npm run test | |
# Copy .node in the release folder | |
cp ./src/build/Release/converter.node ./release/lib/converter.${{ matrix.PLATFORM }}.node | |
- name: Create tarball of the release folder | |
run: | | |
cd ./release | |
tar -czf ${{ matrix.platform }}.tar.gz * | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: release | |
path: ./release/${{ matrix.platform }}.tar.gz |