-
Notifications
You must be signed in to change notification settings - Fork 3
137 lines (115 loc) · 4.51 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Create a folder for the tarball
run: mkdir -p release/${{ matrix.PLATFORM }}/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/${{ matrix.PLATFORM }}/lib/converter.${{ matrix.PLATFORM }}.node
- name: Copy .dll files from the container (Windows)
if: contains(matrix.os, 'windows')
run: |
docker cp ${{ matrix.PLATFORM }}:/heif-converter/src/build/Release/heif.dll ./release/${{ matrix.PLATFORM }}/lib/heif.dll
docker cp ${{ matrix.PLATFORM }}:/heif-converter/src/build/Release/turbojpeg.dll ./release/${{ matrix.PLATFORM }}/lib/turbojpeg.dll
docker cp ${{ matrix.PLATFORM }}:/heif-converter/src/build/Release/jpeg62.dll ./release/${{ matrix.PLATFORM }}/lib/jpeg62.dll
docker cp ${{ matrix.PLATFORM }}:/heif-converter/src/build/Release/libde265.dll ./release/${{ matrix.PLATFORM }}/lib/libde265.dll
docker cp ${{ matrix.PLATFORM }}:/heif-converter/src/build/Release/libx265.dll ./release/${{ matrix.PLATFORM }}/lib/libx265.dll
docker cp ${{ matrix.PLATFORM }}:/heif-converter/src/build/Release/libpng16.dll ./release/${{ matrix.PLATFORM }}/lib/libpng16.dll
docker cp ${{ matrix.PLATFORM }}:/heif-converter/src/build/Release/zlib1.dll ./release/${{ matrix.PLATFORM }}/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: |
# Install nasm (useful for vcpkg)
brew update
brew install nasm
brew install llvm
brew link --force --overwrite llvm
brew install make
brew link --force --overwrite make
# Install python setup tools
pip3 install setuptools
# Clone vcpkg and install libheif
git clone https://github.com/microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
./vcpkg/vcpkg install libheif
# Build project
npm install --omit-optional
npm run configure
npm run build
# Run tests
npm run test
# Copy .node in the release folder
cp ./src/build/Release/converter.node ./release/${{ matrix.PLATFORM }}/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