Skip to content

Commit

Permalink
Add support for pre-releases.
Browse files Browse the repository at this point in the history
- VS Code Engine to 1.63.0
- Upgrade build jobs to use NodeJS 14
- Add prepare_pre_release gulp task

Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
  • Loading branch information
rgrunber committed Jun 28, 2022
1 parent 1ad2e0c commit e964377
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 14 deletions.
40 changes: 27 additions & 13 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env groovy

def installBuildRequirements(){
def nodeHome = tool 'nodejs-12.13.1'
def nodeHome = tool 'nodejs-14.19.1'
env.PATH="${env.PATH}:${nodeHome}/bin"
sh "npm install -g typescript"
sh 'npm install -g "vsce@<2"'
sh 'npm install -g "vsce"'
}

def buildVscodeExtension(){
Expand Down Expand Up @@ -66,6 +66,15 @@ node('rhel8'){
sh "mkdir ./server"
sh "mv ${files[0].path} ./server"

def publishPreReleaseFlag = ""
if(publishPreRelease.equals('true')){
stage "Prepare for pre-release"
sh "npx gulp prepare_pre_release"
packageJson = readJSON file: 'package.json'
publishPreReleaseFlag = "--pre-release"
}


stage "Package vscode-xml"
sh "mkdir ../staging"
unstash 'binaries'
Expand All @@ -77,10 +86,10 @@ node('rhel8'){
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 "vsce package ${publishPreReleaseFlag} --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"
sh "vsce package ${publishPreReleaseFlag} -o vscode-xml-${packageJson.version}-${env.BUILD_NUMBER}.vsix"

//stage 'Test vscode-xml for staging'
//wrap([$class: 'Xvnc']) {
Expand All @@ -93,9 +102,12 @@ node('rhel8'){
}

node('rhel8'){
if(publishToMarketPlace.equals('true')){
timeout(time:2, unit:'DAYS') {
input message:'Approve deployment?', submitter: 'fbricon,rgrunber,azerr,davthomp'
if(publishToMarketPlace.equals('true') || publishPreRelease.equals('true')){

if (publishToMarketPlace.equals('true')) {
timeout(time:2, unit:'DAYS') {
input message:'Approve deployment?', submitter: 'fbricon,rgrunber,azerr,davthomp'
}
}

stage "Publish to Marketplaces"
Expand All @@ -105,15 +117,17 @@ node('rhel8'){
withCredentials([[$class: 'StringBinding', credentialsId: 'vscode_java_marketplace', variable: 'TOKEN']]) {
def platformVsixes = findFiles(glob: '**.vsix', excludes: vsix[0].path)
for(platformVsix in platformVsixes){
sh 'vsce publish -p ${TOKEN}' + " --packagePath ${platformVsix.path}"
sh 'echo 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}"
sh 'echo 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
sh 'npm install -g "ovsx@<0.3.0"'
withCredentials([[$class: 'StringBinding', credentialsId: 'open-vsx-access-token', variable: 'OVSX_TOKEN']]) {
sh 'ovsx publish -p ${OVSX_TOKEN}' + " ${vsix[0].path}"
if (publishToMarketPlace.equals('true')) {
// Open-VSX Marketplace does not support pre-release
sh 'npm install -g "ovsx"'
withCredentials([[$class: 'StringBinding', credentialsId: 'open-vsx-access-token', variable: 'OVSX_TOKEN']]) {
sh 'ovsx publish -p ${OVSX_TOKEN}' + " ${vsix[0].path}"
}
}

}// if publishToMarketPlace
Expand Down
23 changes: 23 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ gulp.task('build_server_with_binary', function(done) {
done();
});

gulp.task('prepare_pre_release', function(done) {
const json = JSON.parse(fse.readFileSync("./package.json").toString());
const stableVersion = json.version.match(/(\d+)\.(\d+)\.(\d+)/);
const major = stableVersion[1];
const minor = stableVersion[2];
const date = new Date();
const month = date.getMonth() + 1;
const day = date.getDate();
const hours = date.getHours();
const patch = `${date.getFullYear()}${prependZero(month)}${prependZero(day)}${prependZero(hours)}`;
const insiderPackageJson = Object.assign(json, {
version: `${major}.${minor}.${patch}`,
});
fse.writeFileSync("./package.json", JSON.stringify(insiderPackageJson, null, 2));
done();
});

function isWin() {
return /^win/.test(process.platform);
Expand All @@ -50,3 +66,10 @@ function isLinux() {
function mvnw() {
return isWin()? "mvnw.cmd": server_dir+"/mvnw";
}

function prependZero(number) {
if (number > 99) {
throw "Unexpected value to prepend with zero";
}
return `${number < 10 ? "0" : ""}${number}`;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}
},
"engines": {
"vscode": "^1.61.0"
"vscode": "^1.63.0"
},
"activationEvents": [
"onLanguage:xml",
Expand Down

0 comments on commit e964377

Please sign in to comment.