Use gzip for release assets so they can easily be extracted from node
This commit is contained in:
parent
b0fe816441
commit
e7bb57550b
6 changed files with 33 additions and 36 deletions
|
|
@ -31,15 +31,15 @@ branches:
|
|||
|
||||
before_deploy:
|
||||
- move target\release\tree-sitter.exe tree-sitter.exe
|
||||
- 7z a tree-sitter-windows-%PLATFORM%.zip tree-sitter.exe
|
||||
- appveyor PushArtifact tree-sitter-windows-%PLATFORM%.zip
|
||||
- 7z a -tgzip tree-sitter-windows-%PLATFORM%.gz tree-sitter.exe
|
||||
- appveyor PushArtifact tree-sitter-windows-%PLATFORM%.gz
|
||||
|
||||
deploy:
|
||||
description: ''
|
||||
provider: GitHub
|
||||
auth_token:
|
||||
secure: VC9ntV5+inKoNteZyLQksKzWMKXF46P+Jx3JHKVSfF+o1rWtZn2iIHAVsQv5LaUi
|
||||
artifact: /tree-sitter-windows-.*.zip/
|
||||
artifact: /tree-sitter-windows-.*/
|
||||
draft: true
|
||||
force_update: true
|
||||
on:
|
||||
|
|
|
|||
12
.gitignore
vendored
12
.gitignore
vendored
|
|
@ -1,11 +1,17 @@
|
|||
log.html
|
||||
|
||||
.idea
|
||||
*.xcodeproj
|
||||
*.a
|
||||
*.o
|
||||
|
||||
fuzz-results
|
||||
|
||||
test/fixtures/grammars/*
|
||||
!test/fixtures/grammars/.gitkeep
|
||||
|
||||
/target
|
||||
**/*.rs.bk
|
||||
*.rs.bk
|
||||
*.a
|
||||
*.o
|
||||
*.obj
|
||||
*.exp
|
||||
*.lib
|
||||
|
|
|
|||
|
|
@ -22,15 +22,15 @@ branches:
|
|||
- /\d+\.\d+\.\d+/
|
||||
|
||||
before_deploy:
|
||||
- mv target/release/tree-sitter .
|
||||
- tar czf tree-sitter-${TRAVIS_OS_NAME}-x64.tar.gz tree-sitter
|
||||
- cp target/release/tree-sitter .
|
||||
- gzip --suffix "-${TRAVIS_OS_NAME}-x64.gz" tree-sitter
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: "cAd2mQP+Q55v3zedo5ZyOVc3hq3XKMW93lp5LuXV6CYKYbIhkyfym4qfs+C9GJQiIP27cnePYM7B3+OMIFwSPIgXHWWSsuloMtDgYSc/PAwb2dZnJqAyog3BohW/QiGTSnvbVlxPF6P9RMQU6+JP0HJzEJy6QBTa4Und/j0jm24="
|
||||
file_glob: true
|
||||
file: "tree-sitter-*.tar.gz"
|
||||
file: "tree-sitter-*.gz"
|
||||
draft: true
|
||||
overwrite: true
|
||||
skip_cleanup: true
|
||||
|
|
|
|||
3
cli/npm/.gitignore
vendored
3
cli/npm/.gitignore
vendored
|
|
@ -1,4 +1,3 @@
|
|||
tree-sitter
|
||||
tree-sitter.exe
|
||||
*.tar.gz
|
||||
*.zip
|
||||
*.gz
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs');
|
||||
const zlib = require('zlib');
|
||||
const https = require('https');
|
||||
const execFileSync = require('child_process').execFileSync;
|
||||
const packageJSON = require('./package.json');
|
||||
|
||||
// Determine the URL of the file.
|
||||
const isWindows = process.platform === 'win32';
|
||||
const platformName = {
|
||||
'darwin': 'osx',
|
||||
'linux': 'linux',
|
||||
|
|
@ -15,48 +14,41 @@ const platformName = {
|
|||
if (!platformName) {
|
||||
throw new Error(`Cannot install tree-sitter-cli for platform ${process.platform}`);
|
||||
}
|
||||
|
||||
const archName = {
|
||||
'x64': 'x64',
|
||||
'x86': 'x86',
|
||||
'ia32': 'x86'
|
||||
}[process.arch];
|
||||
if (!archName) {
|
||||
throw new Error(`Cannot install tree-sitter-cli for architecture ${process.arch}`);
|
||||
}
|
||||
|
||||
const releaseURL = `https://github.com/tree-sitter/tree-sitter/releases/download/${packageJSON.version}`;
|
||||
const assetExtension = isWindows ? 'zip' : 'tar.gz';
|
||||
const assetName = `tree-sitter-${platformName}-${process.arch}.${assetExtension}`;
|
||||
const assetName = `tree-sitter-${platformName}-${archName}.gz`;
|
||||
const assetURL = `${releaseURL}/${assetName}`;
|
||||
|
||||
// Remove previously-downloaded files.
|
||||
const executableName = isWindows ? 'tree-sitter.exe' : 'tree-sitter';
|
||||
const executableName = process.platform === 'win32' ? 'tree-sitter.exe' : 'tree-sitter';
|
||||
if (fs.existsSync(executableName)) {
|
||||
fs.unlinkSync(executableName);
|
||||
}
|
||||
if (fs.existsSync(assetName)) {
|
||||
fs.unlinkSync(assetName);
|
||||
}
|
||||
|
||||
// Download the compressed file.
|
||||
console.log(`Downloading ${assetURL}`);
|
||||
const file = fs.createWriteStream(assetName);
|
||||
const file = fs.createWriteStream(executableName);
|
||||
get(assetURL, response => {
|
||||
if (response.statusCode > 299) {
|
||||
throw new Error([
|
||||
'Download failed',
|
||||
'',
|
||||
`url: ${url}`,
|
||||
`url: ${assetURL}`,
|
||||
`status: ${response.statusCode}`,
|
||||
`headers: ${JSON.stringify(response.headers, null, 2)}`,
|
||||
'',
|
||||
].join('\n'));
|
||||
}
|
||||
|
||||
response.pipe(file);
|
||||
});
|
||||
|
||||
// Extract the file.
|
||||
file.on('finish', () => {
|
||||
console.log(`Extracting ${assetName}`);
|
||||
if (isWindows) {
|
||||
execFileSync('7z', ['e', assetName]);
|
||||
} else {
|
||||
execFileSync('tar', ['xzf', assetName]);
|
||||
}
|
||||
fs.unlinkSync(assetName);
|
||||
console.log(`Done`);
|
||||
response.pipe(zlib.createGunzip()).pipe(file);
|
||||
});
|
||||
|
||||
// Follow redirects.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
],
|
||||
"main": "lib/api/index.js",
|
||||
"scripts": {
|
||||
"install": "./install.js"
|
||||
"install": "install.js"
|
||||
},
|
||||
"bin": {
|
||||
"tree-sitter": "tree-sitter"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue