Commit 44d78b0b authored by Amaury Martiny's avatar Amaury Martiny Committed by Thibaut Sardan

chore: Allow fetching cross-platform parity-ethereum (#501)

* Allow fetching cross-platform

* Update ci

* Fix script
parent 5fd81f1f
Pipeline #35269 failed with stages
in 8 minutes and 19 seconds
......@@ -10,12 +10,11 @@ variables:
CARGOFLAGS: ''
cache:
key: "${CI_JOB_NAME}"
key: '${CI_JOB_NAME}'
paths:
- node_modules/
- packages/*/node_modules/
.branches: &branches
only:
- beta
......@@ -79,6 +78,9 @@ win-build:
script:
- yarn install
- yarn build
# `win-build` is a linux machine, so it downloaded a linux parity-ethereum.
# We download a windows one to make it cross-compile for windows.
- rm packages/fether-electron/static/parity* && yarn fetch-parity --win
- yarn release --win
tags:
- linux-docker
......
......@@ -42,10 +42,11 @@
"yarn": "^1.4.2"
},
"scripts": {
"postinstall": "cd scripts && node ./fetch-latest-parity.js",
"postinstall": "yarn fetch-parity",
"build": "lerna run build",
"preelectron": "yarn build",
"electron": "cd packages/fether-electron && yarn electron",
"fetch-parity": "cd scripts && node ./fetch-latest-parity.js",
"lint-files": "./scripts/lint-files.sh '**/*.js'",
"lint": "yarn lint-files",
"prepackage": "yarn build",
......
......@@ -18,19 +18,28 @@ const exec = promisify(require('child_process').exec);
const fsChmod = promisify(chmod);
const fsWriteFile = promisify(writeFile);
let os;
switch (process.platform) {
case 'win32':
os = 'windows';
break;
case 'darwin':
os = 'darwin';
break;
default:
os = 'linux';
function getOs () {
if (process.argv.includes('--win')) {
return 'windows';
}
if (process.argv.includes('--mac')) {
return 'darwin';
}
if (process.argv.includes('--linux')) {
return 'linux';
}
switch (process.platform) {
case 'win32':
return 'windows';
case 'darwin':
return 'darwin';
default:
return 'linux';
}
}
const ENDPOINT = `https://vanity-service.parity.io/parity-binaries?os=${os}&architecture=x86_64`;
const ENDPOINT = `https://vanity-service.parity.io/parity-binaries?os=${getOs()}&architecture=x86_64`;
const STATIC_DIRECTORY = path.join(
'..',
......@@ -48,6 +57,11 @@ if (foundPath) {
// Bundled Parity was found, we check if the version matches the minimum requirements
getBinaryVersion(foundPath)
.then(version => {
if (!version) {
console.log("Couldn't get bundled Parity Ethereum version.");
return downloadParity();
}
if (!semver.satisfies(version, versionRequirement)) {
console.log(
'Bundled Parity Ethereum %s is older than required version %s',
......@@ -137,14 +151,19 @@ function downloadParity () {
})
.then(getBinaryVersion)
.then(bundledVersion =>
console.log(`Success: bundled Parity Ethereum ${bundledVersion}`)
console.log(
`Success: bundled Parity Ethereum ${bundledVersion ||
"(couldn't get version)"}`
)
)
);
}
function getBinaryVersion (binaryPath) {
return exec(`${binaryPath} --version`).then(({ stdout, stderr }) => {
if (stderr) throw new Error(stderr);
return stdout.match(/v\d+\.\d+\.\d+/)[0];
});
return exec(`${binaryPath} --version`)
.then(({ stdout, stderr }) => {
if (stderr) throw new Error(stderr);
return stdout.match(/v\d+\.\d+\.\d+/)[0];
})
.catch(error => console.warn(error.message));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment