Skip to content

Commit

Permalink
[Build] Add workflows for automatic releases
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaiR committed Jul 10, 2021
1 parent 34e282e commit 1544682
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Build
uses: eskatos/gradle-command-action@v1
with:
arguments: build
arguments: buildAll
build-natives:
env:
FREETYPE_URL: https://download.savannah.gnu.org/releases/freetype/freetype-2.10.4.tar.gz
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/publish_to_maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Publish to Maven
on: workflow_dispatch
jobs:
publish-modules:
strategy:
matrix:
module: [imgui-app, imgui-lwjgl3, imgui-binding]
name: Publish Module (${{ matrix.module }})
runs-on: ubuntu-latest
env:
NEXUS_UPD_ID: ${{ secrets.RELEASE_NEXUS_UPD_ID }}
NEXUS_UPD_PASS: ${{ secrets.RELEASE_NEXUS_UPD_PASS }}
SIGNING_KEY_ID: ${{ secrets.RELEASE_SIGNING_KEY_ID }}
SIGNING_KEY: ${{ secrets.RELEASE_SIGNING_KEY }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Java 8
uses: actions/setup-java@v1
with:
java-version: 8

- name: Publish
uses: eskatos/gradle-command-action@v1
with:
arguments: ${{ format(':{0}:publishMavenJavaPublicationToMavenCentralRepository', matrix.module) }}

publish-natives:
strategy:
matrix:
type: [win, linux, mac]
freetype: [true, false]
name: Publish Native (type=${{ matrix.type }}, freetype=${{ matrix.freetype }})
runs-on: ubuntu-latest
env:
NEXUS_UPD_ID: ${{ secrets.RELEASE_NEXUS_UPD_ID }}
NEXUS_UPD_PASS: ${{ secrets.RELEASE_NEXUS_UPD_PASS }}
SIGNING_KEY_ID: ${{ secrets.RELEASE_SIGNING_KEY_ID }}
SIGNING_KEY: ${{ secrets.RELEASE_SIGNING_KEY }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Java 8
uses: actions/setup-java@v1
with:
java-version: 8

- name: Publish
uses: eskatos/gradle-command-action@v1
with:
arguments: ${{ format(':imgui-binding-natives:publishMavenJavaPublicationToMavenCentralRepository -PdeployType={0} -Pfreetype={1}', matrix.type, matrix.freetype) }}
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Up Version
uses: eskatos/gradle-command-action@v1
with:
arguments: ${{ format('upVersion -Pnext={0}', github.event.inputs.version) }}

- name: Commit Version
uses: EndBug/add-and-commit@v7
with:
default_author: github_actions
message: ${{ format('v{0}', github.event.inputs.version) }}

- name: Push Tag
uses: mathieudutour/github-tag-action@v5.5
id: tag_version
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ github.event.inputs.version }}

- name: Build All
uses: eskatos/gradle-command-action@v1
with:
arguments: buildAll

- name: Generate changelog
id: changelog
uses: metcalfc/changelog-generator@v1.0.0
with:
myToken: ${{ secrets.GITHUB_TOKEN }}

- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: ${{ steps.tag_version.outputs.changelog }} ${{ steps.changelog.outputs.changelog }}
tag_name: ${{ steps.tag_version.outputs.new_tag }}
draft: true
prerelease: false
files: |
imgui-app/build/libs/*.jar
imgui-binding/build/libs/*.jar
imgui-lwjgl3/build/libs/*.jar
bin/imgui-java64.dll
bin/libimgui-java64.dylib
bin/libimgui-java64.so
17 changes: 17 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import tool.UpVersion

allprojects {
group 'imgui-java'
version property('version')
repositories {
mavenCentral()
}
}

tasks.register('upVersion', UpVersion)

tasks.register('buildAll') { t ->
t.group = 'build'
t.description = 'Build all project sources.'

t.dependsOn ':imgui-app:shadowJar'

['app', 'binding', 'lwjgl3'].each { module ->
['build', 'sourcesJar', 'javadocJar'].each { task ->
t.dependsOn ":imgui-$module:$task"
}
}
}
33 changes: 33 additions & 0 deletions buildSrc/src/main/groovy/tool/UpVersion.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package tool

import groovy.transform.CompileStatic
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskAction

@CompileStatic
class UpVersion extends DefaultTask {
@Internal
String group = 'build'
@Internal
String description = 'Up project version to the next one.'

private final String currentVersion = project.findProperty('version')
private final String nextVersion = project.findProperty('next')

@TaskAction
void up() {
if (!currentVersion) {
throw new IllegalArgumentException('No property was found: "version"')
}
if (!nextVersion) {
throw new IllegalArgumentException('No property was found: "next"')
}

def propsFile = project.file('gradle.properties')
propsFile.text = propsFile.text.replace("version=$currentVersion", "version=$nextVersion")

def readmeFile = project.file('README.md')
readmeFile.text = readmeFile.text.replace(currentVersion, nextVersion)
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 1 addition & 0 deletions imgui-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jar {

shadowJar {
with jar
archiveClassifier.set(null)
}

apply from: "$rootDir/publish.gradle"
Expand Down
30 changes: 17 additions & 13 deletions imgui-binding-natives/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,25 @@ def packageDesc = 'Native binaries for imgui-java binding for Linux'
def fromDir = '../bin'
def libName = 'libimgui-java64.so'

if (System.getProperty('deployWin')) {
packageName = 'imgui-java-natives-windows'
packageDesc = 'Native binaries for imgui-java binding for Windows'
libName = 'imgui-java64.dll'
} else if (System.getProperty('deployLinux')) {
packageName = 'imgui-java-natives-linux'
packageDesc = 'Native binaries for imgui-java binding for Linux'
libName = 'libimgui-java64.so'
} else if (System.getProperty('deployMac')) {
packageName = 'imgui-java-natives-macos'
packageDesc = 'Native binaries for imgui-java binding for MacOS'
libName = 'libimgui-java64.dylib'
switch (findProperty('deployType')) {
case 'win':
packageName = 'imgui-java-natives-windows'
packageDesc = 'Native binaries for imgui-java binding for Windows'
libName = 'imgui-java64.dll'
break
case 'linux':
packageName = 'imgui-java-natives-linux'
packageDesc = 'Native binaries for imgui-java binding for Linux'
libName = 'libimgui-java64.so'
break
case 'mac':
packageName = 'imgui-java-natives-macos'
packageDesc = 'Native binaries for imgui-java binding for MacOS'
libName = 'libimgui-java64.dylib'
break
}

if (System.getProperty('freetype')) {
if (findProperty('freetype') == 'true') {
packageName += '-ft'
packageDesc += ' with Freetype support'
fromDir += '/freetype'
Expand Down
12 changes: 2 additions & 10 deletions imgui-binding/src/main/java/imgui/extension/imguizmo/ImGuizmo.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,8 @@ public static void setId(final int id) {
*/

/**
* Checks if we're over the current operation
*
* One of:
* <table summary="">
* <tr>
* <td>{@link imgui.extension.imguizmo.flag.Operation#ROTATE}</td>
* <td>{@link imgui.extension.imguizmo.flag.Operation#SCALE}</td>
* <td>{@link imgui.extension.imguizmo.flag.Operation#TRANSLATE}</td>
* </tr>
* </table>
* Checks if we're over the current operation.
* One of {@link imgui.extension.imguizmo.flag.Operation}.
*
* @param operation target
*/
Expand Down
7 changes: 5 additions & 2 deletions publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ ext.configurePublishing = { packageName, packageDesc ->
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = findProperty('nexusUpdId') ?: ''
password = findProperty('nexusUpdPass') ?: ''
username = System.getenv('NEXUS_UPD_ID')
password = System.getenv('NEXUS_UPD_PASS')
}
}
}
Expand Down Expand Up @@ -59,6 +59,9 @@ ext.configurePublishing = { packageName, packageDesc ->
}
}
signing {
def signingKeyId = System.getenv('SIGNING_KEY_ID')
def signingKey = System.getenv('SIGNING_KEY')
useInMemoryPgpKeys(signingKeyId, signingKey, '')
sign publishing.publications.mavenJava
}
}

0 comments on commit 1544682

Please sign in to comment.