Skip to content

Commit 40fe838

Browse files
Steve RamageSJrX
authored andcommitted
ci: Support for automated releases (Fixes #259)
1 parent ae48818 commit 40fe838

File tree

2 files changed

+51
-11
lines changed

2 files changed

+51
-11
lines changed

build.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,17 @@ if (hasProperty("buildScan")) {
277277
setProperty("termsOfServiceAgree", "yes")
278278
}
279279
}
280+
281+
282+
tasks.register<org.jetbrains.intellij.tasks.PublishPluginTask>("publishPluginStandalone") {
283+
token.set(System.getenv("PUBLISH_TOKEN"))
284+
// pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
285+
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
286+
// https://jetbrains.org/intellij/sdk/docs/tutorials/build_system/deployment.html#specifying-a-release-channel
287+
channels.set(listOf(System.getenv("RELEASE_CHANNEL")?:"dev"))
288+
host.set("https://plugins.jetbrains.com")
289+
toolboxEnterprise.set(false)
290+
291+
// Set the distribution file in gradle build to the archive file of the buildPlugin task
292+
distributionFile.set(project.file("build/distributions/${project.name}-${project.version}.zip"))
293+
}

ci/release.Jenkinsfile

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,24 @@ def buildDate = new Date().format("yyMMdd", TimeZone.getTimeZone('UTC'))
77
cron_string = ""
88

99
// Build nightly on a release branch
10+
if (BRANCH_NAME ==~ /^([0-9][0-9][0-9]\.x)$/) {
11+
cron_string = "H 10 * * *"
12+
}
13+
14+
isReleaseDay = new Date().format("E", TimeZone.getTimeZone('UTC')) == "Wed"
15+
16+
def started_by_timer = currentBuild.getBuildCauses()[0]["shortDescription"].matches("Started by timer")
17+
echo "Started by timer: ${started_by_timer}"
1018

11-
if (BRANCH_NAME ==~ /^([0-9][0-9][0-9].x)$/) {
12-
cron_string = "H 1 * * *"
19+
20+
if (isReleaseDay && started_by_timer) {
21+
releaseChannel = "default"
22+
} else {
23+
releaseChannel = "dev"
1324
}
1425

26+
echo "Release channel $releaseChannel"
27+
1528
def buildPodDefinition(workerPodImage, ciUtilsEnabled, kanikoEnabled) {
1629
// language=yaml
1730
yaml = """
@@ -318,16 +331,22 @@ pipeline {
318331
}
319332
}
320333
steps {
321-
withCredentials([sshUserPrivateKey(credentialsId: 'ci-ssh-key', keyFileVariable: 'KEYFILE')]) {
322-
unstash 'systemd-build-build'
323-
unstash 'ubuntu-units'
334+
withCredentials(
335+
[
336+
sshUserPrivateKey(credentialsId: 'ci-ssh-key', keyFileVariable: 'KEYFILE'),
337+
string(credentialsId: 'systemd-publish-token', variable: 'PUBLISH_TOKEN')
338+
]
339+
) {
340+
withEnv(["RELEASE_CHANNEL=${releaseChannel}"]) {
341+
unstash 'systemd-build-build'
342+
unstash 'ubuntu-units'
324343
sh("""
325344
mkdir -p ./build
326345
./generate-changelog > build/CHANGELOG
327346
./gradlew --no-daemon -I ./build-cache-init.gradle.kts --build-cache build buildPlugin --scan
328347
""")
329348
script {
330-
if (env.BRANCH_NAME ==~ /^([0-9][0-9][0-9].x)$/) {
349+
if (env.BRANCH_NAME ==~ /^([0-9][0-9][0-9]\.x)$/) {
331350
sh("""
332351
echo "Tagging"
333352
mkdir -p ~/.ssh/
@@ -346,14 +365,21 @@ pipeline {
346365
git push origin-ssh --tags
347366
"""
348367
)
349-
} else {
350368
sh("""
351-
echo "No tagging"
352-
""") }
369+
./gradlew --no-daemon -I ./build-cache-init.gradle.kts --build-cache publishPluginStandalone --scan
370+
""")
371+
}
372+
else {
373+
sh("""
374+
echo "No tagging"
375+
""")
353376
}
354377

355-
archiveArtifacts artifacts: 'build/distributions/*.zip'
356-
archiveArtifacts artifacts: 'build/reports/**'
378+
}
379+
380+
archiveArtifacts artifacts: 'build/distributions/*.zip'
381+
archiveArtifacts artifacts: 'build/reports/**'
382+
}
357383
}
358384
}
359385
}

0 commit comments

Comments
 (0)