diff --git a/.github/workflows/macos.yaml b/.github/workflows/macos.yaml index 404bea5..9950ef1 100644 --- a/.github/workflows/macos.yaml +++ b/.github/workflows/macos.yaml @@ -12,7 +12,7 @@ on: jobs: build: - runs-on: macos-latest + runs-on: macos-11 strategy: matrix: @@ -27,7 +27,11 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' + + - run: brew install boost mpv + - run: npm install + - run: npm run collect:dylibs - run: npm run dist:mac - run: npm test - name: Download a Build Artifact diff --git a/.gitignore b/.gitignore index c1bb5ba..0adff52 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,5 @@ public/*.node public/mpv/* # Temporary !public/mpv/*.dll -!public/mpv/.gitkeep \ No newline at end of file +!public/mpv/.gitkeep +!public/mpv/macos \ No newline at end of file diff --git a/public/mpv/macos/mpvjs.node b/public/mpv/macos/mpvjs.node new file mode 100755 index 0000000..71d2866 Binary files /dev/null and b/public/mpv/macos/mpvjs.node differ diff --git a/scripts/externals/mpv/mpvjs.js b/scripts/externals/mpv/mpvjs.js index e49a563..bcc7ea6 100644 --- a/scripts/externals/mpv/mpvjs.js +++ b/scripts/externals/mpv/mpvjs.js @@ -5,17 +5,18 @@ * We need to place it to public/mpv/mpvjs.node */ -const { createWriteStream, renameSync, unlinkSync } = require('fs') +const { createWriteStream, renameSync, unlinkSync, copyFileSync } = require('fs') const { join } = require('path') const https = require('https') const { URL } = require('url') const targz = require('targz') const rimraf = require('rimraf') +const { platform } = require('os') const LATEST_RELEASE_VERSION = 'v0.3.0' -const BASE_URL = `https://github.com/Kagami/mpv.js/releases/download` +const BASE_URL = 'https://github.com/Kagami/mpv.js/releases/download' const BINARY_NAME = 'mpvjs.node' @@ -75,17 +76,24 @@ function saveFile (response) { response.on('end', decompress) } -https.get(url, function (response) { - // Following redirect - if (response.statusCode > 300 && response.statusCode < 400 && response.headers.location) { - const { hostname } = new URL(response.headers.location) +if (platform === 'darwin') { + copyFileSync( + join(TARGET_DIR, 'macos', BINARY_NAME), + join(TARGET_DIR, BINARY_NAME) + ) +} else { + https.get(url, function (response) { + // Following redirect + if (response.statusCode > 300 && response.statusCode < 400 && response.headers.location) { + const { hostname } = new URL(response.headers.location) - if (hostname) { - https.get(response.headers.location, saveFile) + if (hostname) { + https.get(response.headers.location, saveFile) + } else { + throw new Error('Error while redirecting.') + } } else { - throw new Error('Error while redirecting.') + saveFile(response) } - } else { - saveFile(response) - } -}) + }) +}