Skip to content

Commit fa48f92

Browse files
authored
Remove the version name -SNAPSHOT suffix from release builds (#70)
1 parent afd77a0 commit fa48f92

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

.github/workflows/publish-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- name: Publish release to JetBrains Marketplace
2424
run: ./gradlew :plugin:publishPlugin
2525
env:
26+
IJ_PLUGIN_RELEASE: true
2627
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
2728
CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
2829
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}

.github/workflows/publish-snapshot.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jobs:
2323
- name: Publish snapshot to JetBrains Marketplace
2424
run: ./gradlew :plugin:publishPlugin
2525
env:
26-
IJ_PLUGIN_SNAPSHOT: true
2726
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
2827
CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
2928
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}

plugin/build.gradle.kts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import java.net.URI
1010
import java.text.SimpleDateFormat
1111
import java.util.Date
1212

13-
fun isSnapshotBuild() = System.getenv("IJ_PLUGIN_SNAPSHOT").toBoolean()
13+
fun isReleaseBuild() = System.getenv("IJ_PLUGIN_RELEASE").toBoolean()
1414

1515
plugins {
1616
alias(libs.plugins.kotlin.jvm)
@@ -32,12 +32,17 @@ repositories {
3232

3333
group = "com.apollographql"
3434

35-
// Use the global version defined in the root project + dedicated suffix if building a snapshot from the CI
36-
version = project.findProperty("VERSION_NAME").toString() + getSnapshotVersionSuffix()
35+
version = getVersionName()
3736

38-
fun getSnapshotVersionSuffix(): String {
39-
if (!isSnapshotBuild()) return ""
40-
return ".${SimpleDateFormat("YYYY-MM-dd").format(Date())}." + System.getenv("GITHUB_SHA").take(7)
37+
// Use the global version defined in the root project + dedicated suffix if building a snapshot from the CI.
38+
// For releases, remove the -SNAPSHOT suffix.
39+
fun getVersionName(): String {
40+
val projectVersion = project.findProperty("VERSION_NAME").toString()
41+
return if (isReleaseBuild()) {
42+
projectVersion.removeSuffix("-SNAPSHOT")
43+
} else {
44+
projectVersion + ".${SimpleDateFormat("YYYY-MM-dd").format(Date())}." + System.getenv("GITHUB_SHA").take(7)
45+
}
4146
}
4247

4348
kotlin {
@@ -232,10 +237,10 @@ intellijPlatform {
232237
}.joinToString("\n").run { markdownToHTML(this) }
233238
)
234239
changeNotes.set(
235-
if (isSnapshotBuild()) {
236-
"Weekly snapshot builds contain the latest changes from the <code>main</code> branch."
237-
} else {
240+
if (isReleaseBuild()) {
238241
"See the <a href=\"https://github.com/apollographql/apollo-intellij-plugin/releases/tag/v${project.version}\">release notes</a>."
242+
} else {
243+
"Weekly snapshot builds contain the latest changes from the <code>main</code> branch."
239244
}
240245
)
241246
}
@@ -248,7 +253,7 @@ intellijPlatform {
248253

249254
publishing {
250255
token.set(System.getenv("PUBLISH_TOKEN"))
251-
if (isSnapshotBuild()) {
256+
if (!isReleaseBuild()) {
252257
// Read more: https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html#specifying-a-release-channel
253258
channels.set(listOf("snapshots"))
254259
}

0 commit comments

Comments
 (0)