Skip to content

Commit 6fb1614

Browse files
rgrunberdatho7561
authored andcommitted
Add support for pre-releases.
- Add prepare_pre_release gulp task - Make better use of existing Jenkins parameters for FORK, publishPreRelease, publishToMarketPlace & publishToOVSX - Remove unnecessary lsp4mp cloning logic Signed-off-by: Roland Grunberg <[email protected]>
1 parent ea518cf commit 6fb1614

File tree

2 files changed

+60
-23
lines changed

2 files changed

+60
-23
lines changed

Jenkinsfile

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
node('rhel8'){
44
stage('Checkout repos') {
55
deleteDir()
6-
def hasLsp4mpDir = fileExists 'lsp4mp'
7-
if (!hasLsp4mpDir){
8-
sh 'mkdir lsp4mp'
9-
}
10-
dir ('lsp4mp') {
11-
git url: 'https://github.com/eclipse/lsp4mp.git'
12-
}
136
def hasServerDir = fileExists 'quarkus-ls'
147
if (!hasServerDir){
158
sh 'mkdir quarkus-ls'
@@ -22,7 +15,7 @@ node('rhel8'){
2215
sh 'mkdir vscode-quarkus'
2316
}
2417
dir ('vscode-quarkus') {
25-
git url: 'https://github.com/redhat-developer/vscode-quarkus.git'
18+
git url: "https://github.com/${params.FORK}/vscode-quarkus.git"
2619
}
2720
}
2821

@@ -54,10 +47,20 @@ node('rhel8'){
5447
}
5548
}
5649

50+
env.publishPreReleaseFlag = ""
51+
if('true'.equals(publishPreRelease)){
52+
stage("Prepare for pre-release") {
53+
dir ('vscode-quarkus') {
54+
sh "npx gulp prepare_pre_release"
55+
env.publishPreReleaseFlag = "--pre-release"
56+
}
57+
}
58+
}
59+
5760
stage('Package') {
5861
dir ('vscode-quarkus') {
5962
def packageJson = readJSON file: 'package.json'
60-
sh "vsce package -o ../vscode-quarkus-${packageJson.version}-${env.BUILD_NUMBER}.vsix"
63+
sh "vsce package ${env.publishPreReleaseFlag} -o ../vscode-quarkus-${packageJson.version}-${env.BUILD_NUMBER}.vsix"
6164
sh "npm pack && mv vscode-quarkus-${packageJson.version}.tgz ../vscode-quarkus-${packageJson.version}-${env.BUILD_NUMBER}.tgz"
6265
}
6366
}
@@ -73,32 +76,41 @@ node('rhel8'){
7376
}
7477
}
7578

76-
if('true'.equals(publishToMarketPlace)){
77-
timeout(time:5, unit:'DAYS') {
78-
input message:'Approve deployment?', submitter: 'fbricon,rgrunber,azerr,davthomp'
79+
if('true'.equals(publishToMarketPlace) || 'true'.equals(publishToOVSX) || 'true'.equals(publishPreRelease)){
80+
if('true'.equals(publishToMarketPlace) || 'true'.equals(publishToOVSX)){
81+
timeout(time:5, unit:'DAYS') {
82+
input message:'Approve deployment?', submitter: 'fbricon,rgrunber,azerr,davthomp'
83+
}
7984
}
8085

8186
stage("Publish to Marketplaces") {
8287
unstash 'vsix'
8388
unstash 'tgz'
8489
def vsix = findFiles(glob: '**.vsix')
85-
// VS Code Marketplace
86-
withCredentials([[$class: 'StringBinding', credentialsId: 'vscode_java_marketplace', variable: 'TOKEN']]) {
87-
sh 'vsce publish -p ${TOKEN} --packagePath' + " ${vsix[0].path}"
90+
91+
if ('true'.equals(publishToMarketPlace) || 'true'.equals(publishPreRelease)) {
92+
// VS Code Marketplace
93+
withCredentials([[$class: 'StringBinding', credentialsId: 'vscode_java_marketplace', variable: 'TOKEN']]) {
94+
sh 'vsce publish -p ${TOKEN} --packagePath' + " ${vsix[0].path}"
95+
}
8896
}
8997

90-
// open-vsx Marketplace
91-
sh 'npm install -g ovsx'
92-
withCredentials([[$class: 'StringBinding', credentialsId: 'open-vsx-access-token', variable: 'OVSX_TOKEN']]) {
93-
sh 'ovsx publish -p ${OVSX_TOKEN}' + " ${vsix[0].path}"
98+
if ('true'.equals(publishToOVSX)) {
99+
// open-vsx Marketplace
100+
sh 'npm install -g ovsx'
101+
withCredentials([[$class: 'StringBinding', credentialsId: 'open-vsx-access-token', variable: 'OVSX_TOKEN']]) {
102+
sh 'ovsx publish -p ${OVSX_TOKEN}' + " ${vsix[0].path}"
103+
}
94104
}
95105

96106
archiveArtifacts artifacts:"**.vsix,**.tgz"
97107

98-
stage "Promote the build to stable"
99-
sh "sftp -C ${UPLOAD_LOCATION}/stable/vscode-quarkus/ <<< \$'put -p ${vsix[0].path}'"
100-
def tgz = findFiles(glob: '**.tgz')
101-
sh "sftp -C ${UPLOAD_LOCATION}/stable/vscode-quarkus/ <<< \$'put -p ${tgz[0].path}'"
108+
if ('true'.equals(publishToMarketPlace)) {
109+
stage "Promote the build to stable"
110+
sh "sftp -C ${UPLOAD_LOCATION}/stable/vscode-quarkus/ <<< \$'put -p ${vsix[0].path}'"
111+
def tgz = findFiles(glob: '**.tgz')
112+
sh "sftp -C ${UPLOAD_LOCATION}/stable/vscode-quarkus/ <<< \$'put -p ${tgz[0].path}'"
113+
}
102114
}
103115
}
104116
}

gulpfile.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
const gulp = require('gulp');
1515
const rename = require('gulp-rename');
1616
const cp = require('child_process');
17+
const fse = require('fs-extra');
1718

1819
const quarkusServerExtDir = '../quarkus-ls/quarkus.ls.ext/com.redhat.quarkus.ls'
1920
const quarkusServerExt = 'com.redhat.quarkus.ls';
@@ -62,6 +63,23 @@ gulp.task('buildQuteExtension', (done) => {
6263
done();
6364
});
6465

66+
gulp.task('prepare_pre_release', function (done) {
67+
const json = JSON.parse(fse.readFileSync("./package.json").toString());
68+
const stableVersion = json.version.match(/(\d+)\.(\d+)\.(\d+)/);
69+
const major = stableVersion[1];
70+
const minor = stableVersion[2];
71+
const date = new Date();
72+
const month = date.getMonth() + 1;
73+
const day = date.getDate();
74+
const hours = date.getHours();
75+
const patch = `${date.getFullYear()}${prependZero(month)}${prependZero(day)}${prependZero(hours)}`;
76+
const insiderPackageJson = Object.assign(json, {
77+
version: `${major}.${minor}.${patch}`,
78+
});
79+
fse.writeFileSync("./package.json", JSON.stringify(insiderPackageJson, null, 2));
80+
done();
81+
});
82+
6583
gulp.task('build', gulp.series('buildServer', 'buildExtension','buildQuteServer', 'buildQuteExtension'));
6684

6785
function mvnw() {
@@ -71,3 +89,10 @@ function mvnw() {
7189
function isWin() {
7290
return /^win/.test(process.platform);
7391
}
92+
93+
function prependZero(number) {
94+
if (number > 99) {
95+
throw "Unexpected value to prepend with zero";
96+
}
97+
return `${number < 10 ? "0" : ""}${number}`;
98+
}

0 commit comments

Comments
 (0)