mirror of
https://github.com/FlareSolverr/FlareSolverr.git
synced 2025-06-08 04:25:25 +00:00
Build Windows and Linux binaries. resolves #18
This commit is contained in:
parent
d038944089
commit
27ad58b2c6
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
@ -15,6 +15,17 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0 # get all commits, branches and tags (required for the changelog)
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '14'
|
||||
|
||||
- name: Build artifacts
|
||||
run: |
|
||||
npm install
|
||||
npm run build
|
||||
npm run package
|
||||
|
||||
- name: Build changelog
|
||||
id: github_changelog
|
||||
run: |
|
||||
@ -35,3 +46,10 @@ jobs:
|
||||
body: ${{ steps.github_changelog.outputs.changelog }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
- name: Upload release artifacts
|
||||
uses: alexellis/upload-assets@0.2.2
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||
with:
|
||||
asset_paths: '["./bin/*.zip"]'
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -121,3 +121,6 @@ dist
|
||||
|
||||
# Project Development
|
||||
testing/
|
||||
|
||||
# Binaries
|
||||
bin/
|
||||
|
78
build-binaries.js
Normal file
78
build-binaries.js
Normal file
@ -0,0 +1,78 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const {execSync} = require('child_process')
|
||||
const archiver = require('archiver')
|
||||
const puppeteer = require('puppeteer')
|
||||
const version = 'v' + require('./package.json').version;
|
||||
|
||||
(async () => {
|
||||
const builds = [
|
||||
{
|
||||
platform: 'linux',
|
||||
version: 756035,
|
||||
chromeFolder: 'chrome-linux',
|
||||
fsExec: 'flaresolverr-linux',
|
||||
fsZipExec: 'flaresolverr',
|
||||
fsZipName: 'linux-x64'
|
||||
},
|
||||
{
|
||||
platform: 'win64',
|
||||
version: 756035,
|
||||
chromeFolder: 'chrome-win',
|
||||
fsExec: 'flaresolverr-win.exe',
|
||||
fsZipExec: 'flaresolverr.exe',
|
||||
fsZipName: 'windows-x64'
|
||||
}
|
||||
// TODO: this is working but changes are required in session.ts to find chrome path
|
||||
// {
|
||||
// platform: 'mac',
|
||||
// version: 756035,
|
||||
// chromeFolder: 'chrome-mac',
|
||||
// fsExec: 'flaresolverr-macos',
|
||||
// fsZipExec: 'flaresolverr',
|
||||
// fsZipName: 'macos'
|
||||
// }
|
||||
]
|
||||
|
||||
// generate executables
|
||||
console.log('Generating executables...')
|
||||
if (fs.existsSync('bin')) {
|
||||
fs.rmdirSync('bin', {recursive: true})
|
||||
}
|
||||
execSync('pkg -t node14-win-x64,node14-linux-x64 --out-path bin .')
|
||||
// execSync('pkg -t node14-win-x64,node14-mac-x64,node14-linux-x64 --out-path bin .')
|
||||
|
||||
// download Chrome and zip together
|
||||
for (const os of builds) {
|
||||
console.log('Building ' + os.fsZipName + ' artifact')
|
||||
|
||||
// download chrome
|
||||
console.log('Downloading Chrome...')
|
||||
const f = puppeteer.createBrowserFetcher({
|
||||
platform: os.platform,
|
||||
path: path.join(__dirname, 'bin', 'puppeteer')
|
||||
})
|
||||
await f.download(os.version)
|
||||
|
||||
// compress in zip
|
||||
console.log('Compressing zip file...')
|
||||
const zipName = 'bin/flaresolverr-' + version + '-' + os.fsZipName + '.zip'
|
||||
const output = fs.createWriteStream(zipName)
|
||||
const archive = archiver('zip')
|
||||
|
||||
output.on('close', function () {
|
||||
console.log('File ' + zipName + ' created. Size: ' + archive.pointer() + ' bytes')
|
||||
})
|
||||
|
||||
archive.on('error', function (err) {
|
||||
throw err
|
||||
})
|
||||
|
||||
archive.pipe(output)
|
||||
|
||||
archive.file('bin/' + os.fsExec, { name: 'flaresolverr/' + os.fsZipExec })
|
||||
archive.directory('bin/puppeteer/' + os.platform + '-' + os.version + '/' + os.chromeFolder, 'flaresolverr/chrome')
|
||||
|
||||
archive.finalize()
|
||||
}
|
||||
})()
|
789
package-lock.json
generated
789
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@ -5,7 +5,8 @@
|
||||
"scripts": {
|
||||
"start": "node ./dist/index.js",
|
||||
"build": "tsc",
|
||||
"dev": "nodemon -e ts --exec ts-node src/index.ts"
|
||||
"dev": "nodemon -e ts --exec ts-node src/index.ts",
|
||||
"package": "node build-binaries.js"
|
||||
},
|
||||
"author": "Diego Heras (ngosang)",
|
||||
"contributors": [
|
||||
@ -19,6 +20,14 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/ngosang/FlareSolverr"
|
||||
},
|
||||
"pkg": {
|
||||
"assets": [
|
||||
"node_modules/puppeteer-extra-plugin-stealth/**/*.*"
|
||||
]
|
||||
},
|
||||
"bin": {
|
||||
"flaresolverr": "dist/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"await-timeout": "^1.1.1",
|
||||
"console-log-level": "^1.4.1",
|
||||
@ -34,6 +43,7 @@
|
||||
"@types/node": "^14.0.23",
|
||||
"@types/puppeteer": "^3.0.1",
|
||||
"@types/uuid": "^8.0.0",
|
||||
"archiver": "^5.2.0",
|
||||
"eslint": "^7.5.0",
|
||||
"eslint-config-airbnb-base": "^14.2.0",
|
||||
"eslint-config-standard": "^14.1.1",
|
||||
@ -42,6 +52,7 @@
|
||||
"eslint-plugin-promise": "^4.2.1",
|
||||
"eslint-plugin-standard": "^4.0.1",
|
||||
"nodemon": "^2.0.4",
|
||||
"pkg": "^4.4.9",
|
||||
"ts-node": "^8.10.2",
|
||||
"typescript": "^3.9.7"
|
||||
}
|
||||
|
@ -76,6 +76,12 @@ export default {
|
||||
puppeteerOptions.userDataDir = prepareBrowserProfile(id)
|
||||
}
|
||||
|
||||
// if we are running inside executable binary, change chrome path
|
||||
if (typeof (process as any).pkg !== 'undefined') {
|
||||
const exe = process.platform === "win32" ? 'chrome.exe' : 'chrome';
|
||||
puppeteerOptions.executablePath = path.join(path.dirname(process.execPath), 'chrome', exe)
|
||||
}
|
||||
|
||||
log.debug('Launching headless browser...')
|
||||
|
||||
// TODO: maybe access env variable?
|
||||
|
Loading…
x
Reference in New Issue
Block a user