Skip to content

Commit 0d6fe63

Browse files
authored
Merge pull request #69 from sourceplusplus/release-flow
auto-release workflow
2 parents 45120ff + 72f86af commit 0d6fe63

File tree

2 files changed

+43
-7
lines changed

2 files changed

+43
-7
lines changed

.github/workflows/build.yml

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,21 @@ jobs:
2929
graalvm-version: 21.3.0
3030
native-image: true
3131

32-
- name: Build native spp-cli
32+
- name: Export Properties
33+
id: properties
34+
shell: bash
35+
run: |
36+
PROPERTIES="$(./gradlew properties --console=plain -q)"
37+
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
38+
echo "::set-output name=version::$VERSION"
39+
echo "SPP_CLI_VERSION=$VERSION" >> $GITHUB_ENV
40+
echo "SPP_RELEASE_VERSION=${VERSION/-SNAPSHOT/}" >> $GITHUB_ENV
41+
42+
- name: Build native spp-cli (Release)
43+
if: github.ref == 'refs/heads/master'
44+
run: gradle assemble nativeImage -Dbuild.profile=release -PcliVersion=$SPP_RELEASE_VERSION
45+
46+
- name: Build native spp-cli (Snapshot)
3347
run: gradle assemble nativeImage -Dbuild.profile=release
3448

3549
- name: "[CLI] Get version"
@@ -65,7 +79,22 @@ jobs:
6579
graalvm-version: 21.3.0
6680
native-image: true
6781

68-
- name: Build native spp-cli.exe
82+
- name: Export Properties
83+
id: properties
84+
shell: bash
85+
run: |
86+
PROPERTIES="$(./gradlew properties --console=plain -q)"
87+
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
88+
echo "::set-output name=version::$VERSION"
89+
echo "SPP_CLI_VERSION=$VERSION" >> $GITHUB_ENV
90+
echo "SPP_RELEASE_VERSION=${VERSION/-SNAPSHOT/}" >> $GITHUB_ENV
91+
92+
- name: Build native spp-cli.exe (Release)
93+
if: github.ref == 'refs/heads/master'
94+
run: ./gradlew assemble nativeImage '-Dbuild.profile=release' '-PcliVersion=$SPP_RELEASE_VERSION'
95+
shell: powershell
96+
97+
- name: Build native spp-cli.exe (Snapshot)
6998
run: ./gradlew assemble nativeImage '-Dbuild.profile=release'
7099
shell: powershell
71100

@@ -114,8 +143,14 @@ jobs:
114143
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
115144
echo "::set-output name=version::$VERSION"
116145
echo "SPP_CLI_VERSION=$VERSION" >> $GITHUB_ENV
146+
echo "SPP_RELEASE_VERSION=${VERSION/-SNAPSHOT/}" >> $GITHUB_ENV
147+
148+
- name: Build native spp-cli (Release)
149+
if: github.ref == 'refs/heads/master'
150+
run: ./gradlew assembleUp nativeImage -Dbuild.profile=release -PcliVersion=$SPP_RELEASE_VERSION
117151

118-
- run: ./gradlew assembleUp nativeImage -Dbuild.profile=release
152+
- name: Build native spp-cli (Snapshot)
153+
run: ./gradlew assembleUp nativeImage -Dbuild.profile=release
119154

120155
- name: Docker IPs
121156
run: docker inspect --format='{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)

build.gradle.kts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,19 @@ val vertxVersion: String by project
2222
val slf4jVersion: String by project
2323

2424
group = cliGroup
25-
version = projectVersion
25+
version = project.properties["cliVersion"] as String? ?: projectVersion
2626

2727
repositories {
2828
mavenCentral()
29-
maven(url = "https://jitpack.io") { name = "jitpack" }
29+
maven(url = "https://jitpack.io")
30+
maven(url = "https://pkg.sourceplus.plus/sourceplusplus/protocol")
3031
}
3132

3233
dependencies {
3334
implementation("com.apollographql.apollo3:apollo-runtime:$apolloVersion")
3435
api("com.apollographql.apollo3:apollo-api:$apolloVersion")
3536

36-
implementation("com.github.sourceplusplus.protocol:protocol:$projectVersion")
37+
implementation("plus.sourceplus:protocol:$projectVersion")
3738

3839
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3")
3940
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1")
@@ -82,7 +83,7 @@ configurations {
8283

8384
nativeImage {
8485
dependsOn("shadowJar")
85-
setClasspath(File(project.buildDir, "libs/spp-cli-$projectVersion.jar"))
86+
setClasspath(File(project.buildDir, "libs/spp-cli-${project.version}.jar"))
8687
runtimeClasspath = configurations.getByName("empty")
8788
if (System.getenv("GRAALVM_HOME") != null) {
8889
graalVmHome = System.getenv("GRAALVM_HOME")

0 commit comments

Comments
 (0)