Skip to content

Commit

Permalink
Add support to download binaries from GitHub Releases.
Browse files Browse the repository at this point in the history
- Migrate LemMinX binary server from download.jboss.org to github.com
- GitHub Release URL returns 302 and does not properly set Content-Type
  so we should handle these cases
- Archive the zipped binaries, checksums and vsix as a temporary measure
  until GH Release API can be used

Signed-off-by: Roland Grunberg <[email protected]>
  • Loading branch information
rgrunber authored and angelozerr committed Mar 28, 2022
1 parent f504361 commit 2b7e607
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
13 changes: 6 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,16 @@ node('rhel8'){

stage 'set the link to download the binary server'
def packageJson = readJSON file: 'package.json'
def binaryUploadFolder = 'snapshots'
def binaryUploadFolder = 'latest'
def downloadLocation = 'https://github.com/redhat-developer/vscode-xml'
if (publishToMarketPlace.equals('true')) {
binaryUploadFolder = 'stable'
sh "sed -i -e 's|${downloadLocation}/releases/download/latest|${downloadLocation}/releases/download/${packageJson.version}|g' package.json"
}
def downloadLocation = 'https://download.jboss.org/jbosstools'
sh "sed -i -e 's|${downloadLocation}/vscode/snapshots/lemminx-binary/LATEST|${downloadLocation}/vscode/${binaryUploadFolder}/lemminx-binary/${packageJson.version}-${env.BUILD_NUMBER}|g' package.json"

stage 'package binary hashes'
sh "mkdir ./server"
unstash name: 'checksums'
sh "mv lemminx-*.sha256 ./server"
sh "cp lemminx-*.sha256 ./server"

stage 'install vscode-xml build requirements'
installBuildRequirements()
Expand All @@ -81,7 +80,8 @@ node('rhel8'){

stage 'Upload to /vscode-xml/staging'
def vsix = findFiles(glob: '**.vsix')
sh "rsync -Pzrlt --rsh=ssh --protocol=28 ${vsix[0].path} ${UPLOAD_LOCATION}/vscode-xml/staging"
unstash 'binaries'
archiveArtifacts artifacts: 'lemminx-*.zip,*.sha256,*.vsix'
stash name:'vsix', includes:vsix[0].path
}

Expand All @@ -108,6 +108,5 @@ node('rhel8'){

stage "Upload to /vscode-xml/stable"
// copy this stable build to Akamai-mirrored /static/ URL, so staging can be cleaned out more easily
sh "rsync -Pzrlt --rsh=ssh --protocol=28 ${vsix[0].path} ${UPLOAD_LOCATION}/static/vscode-xml/stable/"
}// if publishToMarketPlace
}
18 changes: 2 additions & 16 deletions NativeImage.jenkins
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pipeline {
sh "git clone https://github.com/eclipse/lemminx.git"
}
}
sh "cd lemminx && JAVA_HOME=\$GRAALVM_PATH ./mvnw clean package -B -Dnative -DskipTests -Dgraalvm.static='--static -H:+StaticExecutableWithDynamicLibC' && cd .."
sh "cd lemminx && JAVA_HOME=\$GRAALVM_PATH ./mvnw clean package -B -Dnative -DskipTests -Dgraalvm.static='-H:+StaticExecutableWithDynamicLibC' && cd .."
sh "rm lemminx/org.eclipse.lemminx/target/*.build_artifacts.txt"
sh "cp lemminx/org.eclipse.lemminx/target/lemminx-linux* lemminx-linux"
stash name: 'lemminx-linux', includes: 'lemminx-linux'
Expand Down Expand Up @@ -143,27 +143,13 @@ pipeline {
if (publishToMarketPlace.equals('true')) {
uploadFolderName = 'stable'
}
sh "mkdir ${vscodeXmlVersion}-${env.BUILD_NUMBER}"
sh """
cp lemminx-linux.zip ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-linux.zip
cp lemminx-linux.sha256 ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-linux.sha256
cp lemminx-win32.zip ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-win32.zip
cp lemminx-win32.sha256 ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-win32.sha256
cp lemminx-osx-x86_64.zip ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-osx-x86_64.zip
cp lemminx-osx-x86_64.sha256 ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-osx-x86_64.sha256
"""
if (!publishToMarketPlace.equals('true')){
sh """
ln --symbolic ${vscodeXmlVersion}-${env.BUILD_NUMBER} LATEST
rsync -Pzrlt --rsh=ssh --protocol=28 LATEST ${params.UPLOAD_LOCATION}/vscode/snapshots/lemminx-binary
"""
}
// Upload the uniquely named folder to JBossTools
sh """
rsync -Pzrlt --rsh=ssh --protocol=28 ${vscodeXmlVersion}-${env.BUILD_NUMBER} ${params.UPLOAD_LOCATION}/vscode/${uploadFolderName}/lemminx-binary
rm -rf ${vscodeXmlVersion}-${env.BUILD_NUMBER}
rm -f LATEST
"""
stash name: 'binaries', includes: 'lemminx-*.zip'
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"version": "0.19.1"
},
"binaryServerDownloadUrl": {
"linux": "https://download.jboss.org/jbosstools/vscode/snapshots/lemminx-binary/LATEST/lemminx-linux.zip",
"osx-x86_64": "https://download.jboss.org/jbosstools/vscode/snapshots/lemminx-binary/LATEST/lemminx-osx-x86_64.zip",
"win32": "https://download.jboss.org/jbosstools/vscode/snapshots/lemminx-binary/LATEST/lemminx-win32.zip"
"linux": "https://github.com/redhat-developer/vscode-xml/releases/download/latest/lemminx-linux.zip",
"osx-x86_64": "https://github.com/redhat-developer/vscode-xml/releases/download/latest/lemminx-osx-x86_64.zip",
"win32": "https://github.com/redhat-developer/vscode-xml/releases/download/latest/lemminx-win32.zip"
},
"capabilities": {
"untrustedWorkspaces": {
Expand Down
6 changes: 4 additions & 2 deletions src/server/binary/binaryServerStarter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,16 @@ async function downloadBinary(): Promise<string> {
let webClient: http.ClientRequest = null;
const handleResponse = (response: http.IncomingMessage) => {
const statusCode = response.statusCode;
if (statusCode === 303) {
if (statusCode === 302 || statusCode === 303) {
webClient = httpHttpsGet(response.headers.location, handleResponse)
.on('error', (e) => {
reject(`Server binary download failed: ${e.message}`);
});
} else if (statusCode === 200) {
showProgressForDownload(response, webClient);
if (/^application\/zip$/.test(response.headers['content-type'])) {
const serverBinaryUrl = getServerBinaryDownloadUrl();
if (/^application\/zip$/.test(response.headers['content-type'])
|| serverBinaryUrl.endsWith('.zip')) { // some servers do not set content-type correctly
acceptZipDownloadResponse(response).then(resolve, reject);
} else {
// Not a ZIP, assume its a binary
Expand Down

0 comments on commit 2b7e607

Please sign in to comment.