Skip to content

Commit cf072d9

Browse files
author
Henry Fraser
committed
Bump patch version on each commit
1 parent 54c8465 commit cf072d9

File tree

6 files changed

+52
-11
lines changed

6 files changed

+52
-11
lines changed

.github/workflows/deploy.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
name: Deploy
22
on:
3-
push:
4-
tags:
5-
- '*'
3+
workflow_run:
4+
workflows: [Tag]
5+
types:
6+
- completed
67

78
jobs:
89
deploy:
910
runs-on: ubuntu-latest
10-
if: github.repository == 'fwcd/kotlin-language-server'
1111
steps:
1212
- uses: actions/checkout@v3
1313
- name: Setup JDK
1414
uses: actions/setup-java@v3
1515
with:
1616
distribution: 'temurin'
1717
java-version: '11'
18+
- name: Get latest tag
19+
uses: actions-ecosystem/action-get-latest-tag@v1
20+
id: get-latest-tag
1821
- name: Setup Gradle
1922
uses: gradle/gradle-build-action@v2
2023
- name: Build distribution
@@ -25,8 +28,8 @@ jobs:
2528
env:
2629
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2730
with:
28-
tag_name: ${{ github.ref }}
29-
release_name: Version ${{ github.ref }}
31+
tag_name: ${{ steps.get-latest-tag.outputs.tag }}
32+
release_name: Version ${{ steps.get-latest-tag.outputs.tag }}
3033
draft: false
3134
prerelease: false
3235
- name: Upload server asset

.github/workflows/tag.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Tag
2+
on:
3+
workflow_run:
4+
workflows: [Build]
5+
types:
6+
- completed
7+
8+
jobs:
9+
tag:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Get latest tag
14+
uses: actions-ecosystem/action-get-latest-tag@v1
15+
id: get-latest-tag
16+
17+
- name: Bump patch tag
18+
uses: actions-ecosystem/action-bump-semver@v1
19+
id: bump-semver
20+
with:
21+
current_version: ${{ steps.get-latest-tag.outputs.tag }}
22+
level: patch
23+
24+
- name: Push new tag
25+
uses: actions-ecosystem/action-push-tag@v1
26+
with:
27+
tag: ${{ steps.bump-semver.outputs.new_version }}

build.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import com.palantir.gradle.gitversion.VersionDetails
12
import io.gitlab.arturbosch.detekt.Detekt
23
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
34

45
plugins {
56
kotlin("jvm")
67
`maven-publish`
78
id("io.gitlab.arturbosch.detekt") version "1.22.0"
9+
id("com.palantir.git-version")
810
}
911

1012
repositories {
@@ -35,6 +37,15 @@ configure(subprojects.filter { it.name != "grammars" }) {
3537
}
3638
}
3739

40+
// follows instructions from: https://github.com/palantir/gradle-git-version
41+
// to get the latest git tag so that we can use it for versioning
42+
val versionDetails: groovy.lang.Closure<VersionDetails> by extra
43+
val details = versionDetails()
44+
45+
allprojects {
46+
version = details.lastTag
47+
}
48+
3849
detekt {
3950
allRules = false // activate all available (even unstable) rules.
4051
buildUponDefaultConfig = true // preconfigure defaults

server/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ plugins {
88
id("com.jaredsburrows.license")
99
}
1010

11-
val projectVersion = "1.3.2"
1211
val debugPort = 8000
1312
val debugArgs = "-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n,quiet=y"
1413
val javaVersion = try {
@@ -17,15 +16,13 @@ val javaVersion = try {
1716
"11"
1817
}
1918

20-
version = projectVersion
21-
2219
val serverMainClassName = "org.javacs.kt.MainKt"
2320
val applicationName = "kotlin-language-server"
2421

2522
application {
2623
mainClass.set(serverMainClassName)
2724
description = "Code completions, diagnostics and more for Kotlin"
28-
applicationDefaultJvmArgs = listOf("-DkotlinLanguageServer.version=$projectVersion")
25+
applicationDefaultJvmArgs = listOf("-DkotlinLanguageServer.version=$version")
2926
applicationDistribution.into("bin") {
3027
fileMode = 755
3128
}
@@ -128,6 +125,9 @@ tasks.withType<Test>() {
128125
}
129126
}
130127

128+
// override the distribution name from server-<version>.zip to server.zip
129+
tasks.distZip.get().archiveFileName.set("${project.name}.zip")
130+
131131
tasks.installDist {
132132
finalizedBy("fixFilePermissions")
133133
}

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pluginManagement {
2323
kotlin("jvm") version "1.8.10" apply false
2424
id("com.github.jk1.tcdeps") version "1.2" apply false
2525
id("com.jaredsburrows.license") version "0.8.42" apply false
26+
id("com.palantir.git-version") version "1.0.0" apply false
2627
}
2728
}
2829

shared/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ repositories {
99
mavenCentral()
1010
}
1111

12-
version = project.version
1312
val javaVersion = try {
1413
project.property("javaVersion").toString()
1514
} catch (_: MissingPropertyException) {

0 commit comments

Comments
 (0)