Skip to content

Commit 2b7e607

Browse files
rgrunberangelozerr
authored andcommitted
Add support to download binaries from GitHub Releases.
- 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]>
1 parent f504361 commit 2b7e607

File tree

4 files changed

+15
-28
lines changed

4 files changed

+15
-28
lines changed

Jenkinsfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,16 @@ node('rhel8'){
5050

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

6059
stage 'package binary hashes'
6160
sh "mkdir ./server"
6261
unstash name: 'checksums'
63-
sh "mv lemminx-*.sha256 ./server"
62+
sh "cp lemminx-*.sha256 ./server"
6463

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

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

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

109109
stage "Upload to /vscode-xml/stable"
110110
// copy this stable build to Akamai-mirrored /static/ URL, so staging can be cleaned out more easily
111-
sh "rsync -Pzrlt --rsh=ssh --protocol=28 ${vsix[0].path} ${UPLOAD_LOCATION}/static/vscode-xml/stable/"
112111
}// if publishToMarketPlace
113112
}

NativeImage.jenkins

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pipeline {
2727
sh "git clone https://github.com/eclipse/lemminx.git"
2828
}
2929
}
30-
sh "cd lemminx && JAVA_HOME=\$GRAALVM_PATH ./mvnw clean package -B -Dnative -DskipTests -Dgraalvm.static='--static -H:+StaticExecutableWithDynamicLibC' && cd .."
30+
sh "cd lemminx && JAVA_HOME=\$GRAALVM_PATH ./mvnw clean package -B -Dnative -DskipTests -Dgraalvm.static='-H:+StaticExecutableWithDynamicLibC' && cd .."
3131
sh "rm lemminx/org.eclipse.lemminx/target/*.build_artifacts.txt"
3232
sh "cp lemminx/org.eclipse.lemminx/target/lemminx-linux* lemminx-linux"
3333
stash name: 'lemminx-linux', includes: 'lemminx-linux'
@@ -143,27 +143,13 @@ pipeline {
143143
if (publishToMarketPlace.equals('true')) {
144144
uploadFolderName = 'stable'
145145
}
146-
sh "mkdir ${vscodeXmlVersion}-${env.BUILD_NUMBER}"
147-
sh """
148-
cp lemminx-linux.zip ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-linux.zip
149-
cp lemminx-linux.sha256 ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-linux.sha256
150-
cp lemminx-win32.zip ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-win32.zip
151-
cp lemminx-win32.sha256 ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-win32.sha256
152-
cp lemminx-osx-x86_64.zip ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-osx-x86_64.zip
153-
cp lemminx-osx-x86_64.sha256 ${vscodeXmlVersion}-${env.BUILD_NUMBER}/lemminx-osx-x86_64.sha256
154-
"""
155146
if (!publishToMarketPlace.equals('true')){
156147
sh """
157148
ln --symbolic ${vscodeXmlVersion}-${env.BUILD_NUMBER} LATEST
158149
rsync -Pzrlt --rsh=ssh --protocol=28 LATEST ${params.UPLOAD_LOCATION}/vscode/snapshots/lemminx-binary
159150
"""
160151
}
161-
// Upload the uniquely named folder to JBossTools
162-
sh """
163-
rsync -Pzrlt --rsh=ssh --protocol=28 ${vscodeXmlVersion}-${env.BUILD_NUMBER} ${params.UPLOAD_LOCATION}/vscode/${uploadFolderName}/lemminx-binary
164-
rm -rf ${vscodeXmlVersion}-${env.BUILD_NUMBER}
165-
rm -f LATEST
166-
"""
152+
stash name: 'binaries', includes: 'lemminx-*.zip'
167153
}
168154
}
169155
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"version": "0.19.1"
2020
},
2121
"binaryServerDownloadUrl": {
22-
"linux": "https://download.jboss.org/jbosstools/vscode/snapshots/lemminx-binary/LATEST/lemminx-linux.zip",
23-
"osx-x86_64": "https://download.jboss.org/jbosstools/vscode/snapshots/lemminx-binary/LATEST/lemminx-osx-x86_64.zip",
24-
"win32": "https://download.jboss.org/jbosstools/vscode/snapshots/lemminx-binary/LATEST/lemminx-win32.zip"
22+
"linux": "https://github.com/redhat-developer/vscode-xml/releases/download/latest/lemminx-linux.zip",
23+
"osx-x86_64": "https://github.com/redhat-developer/vscode-xml/releases/download/latest/lemminx-osx-x86_64.zip",
24+
"win32": "https://github.com/redhat-developer/vscode-xml/releases/download/latest/lemminx-win32.zip"
2525
},
2626
"capabilities": {
2727
"untrustedWorkspaces": {

src/server/binary/binaryServerStarter.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,16 @@ async function downloadBinary(): Promise<string> {
8989
let webClient: http.ClientRequest = null;
9090
const handleResponse = (response: http.IncomingMessage) => {
9191
const statusCode = response.statusCode;
92-
if (statusCode === 303) {
92+
if (statusCode === 302 || statusCode === 303) {
9393
webClient = httpHttpsGet(response.headers.location, handleResponse)
9494
.on('error', (e) => {
9595
reject(`Server binary download failed: ${e.message}`);
9696
});
9797
} else if (statusCode === 200) {
9898
showProgressForDownload(response, webClient);
99-
if (/^application\/zip$/.test(response.headers['content-type'])) {
99+
const serverBinaryUrl = getServerBinaryDownloadUrl();
100+
if (/^application\/zip$/.test(response.headers['content-type'])
101+
|| serverBinaryUrl.endsWith('.zip')) { // some servers do not set content-type correctly
100102
acceptZipDownloadResponse(response).then(resolve, reject);
101103
} else {
102104
// Not a ZIP, assume its a binary

0 commit comments

Comments
 (0)