From 1ad2e0c0e8d83ab3952d6417e6e3b028fe2d3f9c Mon Sep 17 00:00:00 2001 From: Roland Grunberg Date: Thu, 28 Apr 2022 00:02:30 -0400 Subject: [PATCH] Package and publish platform specific extensions. - Create platform specific vsix files for linux-x64, darwin-x64 & win32-x64 - Add 'build_server_with_binary' gulpfile task Signed-off-by: Roland Grunberg --- Jenkinsfile | 35 ++++++++++++++++++++++------------- gulpfile.js | 18 ++++++++++++++++++ package.json | 2 +- 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d51294a1..a8a30baa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -56,11 +56,6 @@ node('rhel8'){ sh "sed -i -e 's|${downloadLocation}/releases/download/latest|${downloadLocation}/releases/download/${packageJson.version}|g' package.json" } - stage 'package binary hashes' - sh "mkdir ./server" - unstash name: 'checksums' - sh "cp lemminx-*.sha256 ./server" - stage 'install vscode-xml build requirements' installBuildRequirements() @@ -68,9 +63,23 @@ node('rhel8'){ buildVscodeExtension() unstash 'server_distro' def files = findFiles(glob: '**/org.eclipse.lemminx*-uber.jar') + sh "mkdir ./server" sh "mv ${files[0].path} ./server" stage "Package vscode-xml" + sh "mkdir ../staging" + unstash 'binaries' + unstash 'checksums' + sh "mv lemminx-* ../staging" + def platformToTarget = [ "linux" : "linux-x64", "win32" : "win32-x64", "osx-x86_64" : "darwin-x64" ] + for(entry in platformToTarget){ + def platform = entry.key + def target = entry.value + sh "unzip -d ./server ../staging/lemminx-${platform}.zip" + sh "cp ../staging/lemminx-${platform}.sha256 ./server" + sh "vsce package --target ${target} -o vscode-xml-${target}-${packageJson.version}-${env.BUILD_NUMBER}.vsix" + sh "rm ./server/lemminx-*" + } sh "vsce package -o vscode-xml-${packageJson.version}-${env.BUILD_NUMBER}.vsix" //stage 'Test vscode-xml for staging' @@ -78,11 +87,9 @@ node('rhel8'){ // sh "npm test --silent" //} - stage 'Upload to /vscode-xml/staging' - def vsix = findFiles(glob: '**.vsix') - unstash 'binaries' - archiveArtifacts artifacts: 'lemminx-*.zip,*.sha256,*.vsix' - stash name:'vsix', includes:vsix[0].path + stage 'Archive artifacts' + archiveArtifacts artifacts: '*.vsix' + stash name:'vsix', includes:'*.vsix' } node('rhel8'){ @@ -96,7 +103,11 @@ node('rhel8'){ def vsix = findFiles(glob: '**.vsix') // VS Code Marketplace withCredentials([[$class: 'StringBinding', credentialsId: 'vscode_java_marketplace', variable: 'TOKEN']]) { - sh 'vsce publish -p ${TOKEN} --packagePath' + " ${vsix[0].path}" + def platformVsixes = findFiles(glob: '**.vsix', excludes: vsix[0].path) + for(platformVsix in platformVsixes){ + sh 'vsce publish -p ${TOKEN}' + " --packagePath ${platformVsix.path}" + } + sh 'vsce publish -p ${TOKEN} --target win32-ia32 win32-arm64 linux-arm64 linux-armhf alpine-x64 alpine-arm64 darwin-arm64 --packagePath' + " ${vsix[0].path}" } // Open-vsx Marketplace @@ -105,7 +116,5 @@ node('rhel8'){ sh 'ovsx publish -p ${OVSX_TOKEN}' + " ${vsix[0].path}" } - stage "Upload to /vscode-xml/stable" - // copy this stable build to Akamai-mirrored /static/ URL, so staging can be cleaned out more easily }// if publishToMarketPlace } diff --git a/gulpfile.js b/gulpfile.js index 2cb6d5ba..160bdb46 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,6 +3,8 @@ const gulp = require('gulp'); const gulp_tslint = require('gulp-tslint'); const cp = require('child_process'); const server_dir = '../lemminx'; +const fse = require('fs-extra'); +const glob = require('glob'); gulp.task('tslint', () => { return gulp.src(['**/*.ts', '!**/*.d.ts', '!node_modules/**']) @@ -17,6 +19,22 @@ gulp.task('build_server', function(done) { done(); }); +gulp.task('build_server_with_binary', function(done) { + cp.execSync(mvnw()+ " clean verify -DskipTests -Dnative", {cwd:server_dir, stdio:[0,1,2]} ); + gulp.src([server_dir +'/org.eclipse.lemminx/target/org.eclipse.lemminx-uber.jar', server_dir +'/org.eclipse.lemminx/target/lemminx-*']) + .pipe(gulp.dest('./server')) + .on('end', function () { + glob.Glob('./server/lemminx-*.txt', (_er, txtfiles) => { + fse.removeSync(txtfiles[0]); + glob.Glob('./server/lemminx-*-*', (_err, binfiles) => { + fse.moveSync(binfiles[0], './server/lemminx-' + (isWin() ? 'win32.exe' : (isMac() ? 'osx-x86_64' : 'linux')), { overwrite: true }); + }); + }); + }); + done(); +}); + + function isWin() { return /^win/.test(process.platform); } diff --git a/package.json b/package.json index 31443bce..1776895e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } }, "engines": { - "vscode": "^1.52.0" + "vscode": "^1.61.0" }, "activationEvents": [ "onLanguage:xml",