Skip to content

Commit 1544682

Browse files
committed
[Build] Add workflows for automatic releases
1 parent 34e282e commit 1544682

File tree

10 files changed

+190
-27
lines changed

10 files changed

+190
-27
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Build
2020
uses: eskatos/gradle-command-action@v1
2121
with:
22-
arguments: build
22+
arguments: buildAll
2323
build-natives:
2424
env:
2525
FREETYPE_URL: https://download.savannah.gnu.org/releases/freetype/freetype-2.10.4.tar.gz
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Publish to Maven
2+
on: workflow_dispatch
3+
jobs:
4+
publish-modules:
5+
strategy:
6+
matrix:
7+
module: [imgui-app, imgui-lwjgl3, imgui-binding]
8+
name: Publish Module (${{ matrix.module }})
9+
runs-on: ubuntu-latest
10+
env:
11+
NEXUS_UPD_ID: ${{ secrets.RELEASE_NEXUS_UPD_ID }}
12+
NEXUS_UPD_PASS: ${{ secrets.RELEASE_NEXUS_UPD_PASS }}
13+
SIGNING_KEY_ID: ${{ secrets.RELEASE_SIGNING_KEY_ID }}
14+
SIGNING_KEY: ${{ secrets.RELEASE_SIGNING_KEY }}
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@v2
18+
19+
- name: Set up Java 8
20+
uses: actions/setup-java@v1
21+
with:
22+
java-version: 8
23+
24+
- name: Publish
25+
uses: eskatos/gradle-command-action@v1
26+
with:
27+
arguments: ${{ format(':{0}:publishMavenJavaPublicationToMavenCentralRepository', matrix.module) }}
28+
29+
publish-natives:
30+
strategy:
31+
matrix:
32+
type: [win, linux, mac]
33+
freetype: [true, false]
34+
name: Publish Native (type=${{ matrix.type }}, freetype=${{ matrix.freetype }})
35+
runs-on: ubuntu-latest
36+
env:
37+
NEXUS_UPD_ID: ${{ secrets.RELEASE_NEXUS_UPD_ID }}
38+
NEXUS_UPD_PASS: ${{ secrets.RELEASE_NEXUS_UPD_PASS }}
39+
SIGNING_KEY_ID: ${{ secrets.RELEASE_SIGNING_KEY_ID }}
40+
SIGNING_KEY: ${{ secrets.RELEASE_SIGNING_KEY }}
41+
steps:
42+
- name: Checkout Repository
43+
uses: actions/checkout@v2
44+
45+
- name: Set up Java 8
46+
uses: actions/setup-java@v1
47+
with:
48+
java-version: 8
49+
50+
- name: Publish
51+
uses: eskatos/gradle-command-action@v1
52+
with:
53+
arguments: ${{ format(':imgui-binding-natives:publishMavenJavaPublicationToMavenCentralRepository -PdeployType={0} -Pfreetype={1}', matrix.type, matrix.freetype) }}

.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: 'Version'
7+
required: true
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout Repository
14+
uses: actions/checkout@v2
15+
16+
- name: Up Version
17+
uses: eskatos/gradle-command-action@v1
18+
with:
19+
arguments: ${{ format('upVersion -Pnext={0}', github.event.inputs.version) }}
20+
21+
- name: Commit Version
22+
uses: EndBug/add-and-commit@v7
23+
with:
24+
default_author: github_actions
25+
message: ${{ format('v{0}', github.event.inputs.version) }}
26+
27+
- name: Push Tag
28+
uses: mathieudutour/[email protected]
29+
id: tag_version
30+
with:
31+
github_token: ${{ secrets.GITHUB_TOKEN }}
32+
custom_tag: ${{ github.event.inputs.version }}
33+
34+
- name: Build All
35+
uses: eskatos/gradle-command-action@v1
36+
with:
37+
arguments: buildAll
38+
39+
- name: Generate changelog
40+
id: changelog
41+
uses: metcalfc/[email protected]
42+
with:
43+
myToken: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Release
46+
uses: softprops/action-gh-release@v1
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
with:
50+
body: ${{ steps.tag_version.outputs.changelog }} ${{ steps.changelog.outputs.changelog }}
51+
tag_name: ${{ steps.tag_version.outputs.new_tag }}
52+
draft: true
53+
prerelease: false
54+
files: |
55+
imgui-app/build/libs/*.jar
56+
imgui-binding/build/libs/*.jar
57+
imgui-lwjgl3/build/libs/*.jar
58+
bin/imgui-java64.dll
59+
bin/libimgui-java64.dylib
60+
bin/libimgui-java64.so

build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1+
import tool.UpVersion
2+
13
allprojects {
24
group 'imgui-java'
35
version property('version')
46
repositories {
57
mavenCentral()
68
}
79
}
10+
11+
tasks.register('upVersion', UpVersion)
12+
13+
tasks.register('buildAll') { t ->
14+
t.group = 'build'
15+
t.description = 'Build all project sources.'
16+
17+
t.dependsOn ':imgui-app:shadowJar'
18+
19+
['app', 'binding', 'lwjgl3'].each { module ->
20+
['build', 'sourcesJar', 'javadocJar'].each { task ->
21+
t.dependsOn ":imgui-$module:$task"
22+
}
23+
}
24+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package tool
2+
3+
import groovy.transform.CompileStatic
4+
import org.gradle.api.DefaultTask
5+
import org.gradle.api.tasks.Internal
6+
import org.gradle.api.tasks.TaskAction
7+
8+
@CompileStatic
9+
class UpVersion extends DefaultTask {
10+
@Internal
11+
String group = 'build'
12+
@Internal
13+
String description = 'Up project version to the next one.'
14+
15+
private final String currentVersion = project.findProperty('version')
16+
private final String nextVersion = project.findProperty('next')
17+
18+
@TaskAction
19+
void up() {
20+
if (!currentVersion) {
21+
throw new IllegalArgumentException('No property was found: "version"')
22+
}
23+
if (!nextVersion) {
24+
throw new IllegalArgumentException('No property was found: "next"')
25+
}
26+
27+
def propsFile = project.file('gradle.properties')
28+
propsFile.text = propsFile.text.replace("version=$currentVersion", "version=$nextVersion")
29+
30+
def readmeFile = project.file('README.md')
31+
readmeFile.text = readmeFile.text.replace(currentVersion, nextVersion)
32+
}
33+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

imgui-app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jar {
4343

4444
shadowJar {
4545
with jar
46+
archiveClassifier.set(null)
4647
}
4748

4849
apply from: "$rootDir/publish.gradle"

imgui-binding-natives/build.gradle

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,25 @@ def packageDesc = 'Native binaries for imgui-java binding for Linux'
99
def fromDir = '../bin'
1010
def libName = 'libimgui-java64.so'
1111

12-
if (System.getProperty('deployWin')) {
13-
packageName = 'imgui-java-natives-windows'
14-
packageDesc = 'Native binaries for imgui-java binding for Windows'
15-
libName = 'imgui-java64.dll'
16-
} else if (System.getProperty('deployLinux')) {
17-
packageName = 'imgui-java-natives-linux'
18-
packageDesc = 'Native binaries for imgui-java binding for Linux'
19-
libName = 'libimgui-java64.so'
20-
} else if (System.getProperty('deployMac')) {
21-
packageName = 'imgui-java-natives-macos'
22-
packageDesc = 'Native binaries for imgui-java binding for MacOS'
23-
libName = 'libimgui-java64.dylib'
12+
switch (findProperty('deployType')) {
13+
case 'win':
14+
packageName = 'imgui-java-natives-windows'
15+
packageDesc = 'Native binaries for imgui-java binding for Windows'
16+
libName = 'imgui-java64.dll'
17+
break
18+
case 'linux':
19+
packageName = 'imgui-java-natives-linux'
20+
packageDesc = 'Native binaries for imgui-java binding for Linux'
21+
libName = 'libimgui-java64.so'
22+
break
23+
case 'mac':
24+
packageName = 'imgui-java-natives-macos'
25+
packageDesc = 'Native binaries for imgui-java binding for MacOS'
26+
libName = 'libimgui-java64.dylib'
27+
break
2428
}
2529

26-
if (System.getProperty('freetype')) {
30+
if (findProperty('freetype') == 'true') {
2731
packageName += '-ft'
2832
packageDesc += ' with Freetype support'
2933
fromDir += '/freetype'

imgui-binding/src/main/java/imgui/extension/imguizmo/ImGuizmo.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,8 @@ public static void setId(final int id) {
307307
*/
308308

309309
/**
310-
* Checks if we're over the current operation
311-
*
312-
* One of:
313-
* <table summary="">
314-
* <tr>
315-
* <td>{@link imgui.extension.imguizmo.flag.Operation#ROTATE}</td>
316-
* <td>{@link imgui.extension.imguizmo.flag.Operation#SCALE}</td>
317-
* <td>{@link imgui.extension.imguizmo.flag.Operation#TRANSLATE}</td>
318-
* </tr>
319-
* </table>
310+
* Checks if we're over the current operation.
311+
* One of {@link imgui.extension.imguizmo.flag.Operation}.
320312
*
321313
* @param operation target
322314
*/

publish.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ ext.configurePublishing = { packageName, packageDesc ->
1717
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
1818
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
1919
credentials {
20-
username = findProperty('nexusUpdId') ?: ''
21-
password = findProperty('nexusUpdPass') ?: ''
20+
username = System.getenv('NEXUS_UPD_ID')
21+
password = System.getenv('NEXUS_UPD_PASS')
2222
}
2323
}
2424
}
@@ -59,6 +59,9 @@ ext.configurePublishing = { packageName, packageDesc ->
5959
}
6060
}
6161
signing {
62+
def signingKeyId = System.getenv('SIGNING_KEY_ID')
63+
def signingKey = System.getenv('SIGNING_KEY')
64+
useInMemoryPgpKeys(signingKeyId, signingKey, '')
6265
sign publishing.publications.mavenJava
6366
}
6467
}

0 commit comments

Comments
 (0)