Skip to content

Commit

Permalink
Update release plugin for sonatype (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr authored May 21, 2024
1 parent af270a3 commit 4347d44
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 69 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ jobs:
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true

- name: Build
run: ./gradlew build
12 changes: 9 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Publish

on:
push:
branches: [ main, hotfix ]
branches: [ main, hotfix , testRelease]
workflow_dispatch:

jobs:
publish:
Expand All @@ -13,15 +14,20 @@ jobs:
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true

- name: Build
run: ./gradlew build

- name: Publish to Sonatype (for snapshots) or to Maven Central and GitHub Repository (for releases)
- name: Publish to Sonatype (for snapshots) or to Maven Central
run: ./gradlew publish closeAndReleaseRepository
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/update-gradle-wrapper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'

- name: Update Gradle Wrapper
uses: gradle-update/update-gradle-wrapper-action@v1
with:
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,30 @@ Goal: "Less Code, Increased Productivity"
Simplistic example: <https://github.com/JabRef/afterburner.fx/tree/main/demo-app>

See also: <http://afterburner.adam-bien.com>

## Release a new version to maven central

Check gpg key and export:

```bash
gpg --list-keys
gpg -K --keyid-format short
gpg --keyring secring.gpg --export-secret-keys > ~/.gnupg/secring.gpg
```

fill out gradle.properties with

```
signing.keyId=<last 8 digits of gpg key (short format) >
signing.password=<gpg key passwrod>
signing.secretKeyRingFile=~/.gnupg/secring.gpg
ossrhUsername=<nexus ossrh username>
ossrhPassword=<nexus ossrh password>
```

When all is set: (Warning: This step cannot be undone!)

```terminal
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
```
54 changes: 16 additions & 38 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
id 'org.openjfx.javafxplugin' version '0.1.0'
id "io.codearte.nexus-staging" version "0.30.0"
id 'java-library'
id 'maven-publish'
id 'signing'
id 'org.openjfx.javafxplugin' version '0.1.0'
id "io.github.gradle-nexus.publish-plugin" version "2.0.0"
}

allprojects {
Expand All @@ -28,13 +28,13 @@ java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

//withJavadocJar()
withJavadocJar()
withSourcesJar()
}

javafx {
version = "20"
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.web', 'javafx.swing' ]
modules = ['javafx.controls', 'javafx.fxml', 'javafx.web', 'javafx.swing']
}

dependencies {
Expand Down Expand Up @@ -86,43 +86,21 @@ publishing {
}
}
}
repositories {
maven {
name = "OSSRH"
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = isReleaseVersion ? releasesRepoUrl : snapshotsRepoUrl
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
// This currently only works for released versions, as github has problems with overwriting snapshots
if (isReleaseVersion) {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/JabRef/afterburner.fx"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
}

signing {
required = isReleaseVersion
useInMemoryPgpKeys(System.getenv("SIGNING_KEY"), System.getenv("SIGNING_PASSWORD"))
sign publishing.publications.mavenJava
}

nexusStaging {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
nexusPublishing {
repositories {
sonatype { //only for users registered in Sonatype after 24 Feb 2021
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}

// Don't publish snapshots to Maven Central
closeAndReleaseRepository.onlyIf { isReleaseVersion }
closeRepository.onlyIf { isReleaseVersion }
releaseRepository.onlyIf { isReleaseVersion }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
14 changes: 7 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -202,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void injectMembers(Object controller, Function<String, Object> injectionC

/**
* Populate the given object.
* For example, set all fields annotated with {@link javax.inject.Inject}.
* For example, set all fields annotated with {@link jakarta.inject.Inject}.
*
* @param instance the object to inject members into
* @param injectionContext a cache of already instantiated and initialized instances
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ static ResourceLocator discover() {
/**
* This method method replaces the standard afterburner dependency
* injection.
*
* @param <T> the type of the presenter
* @param clazz presenter class containing the default constructor.
* @param injectionContext a cache of already instantiated and initialized
* instances.
* @param name The name of the bundle
* @return a fully initialized presenter with injected dependencies.
*/
ResourceBundle getResourceBundle(String name);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/airhacks/afterburner/views/ViewLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private static ExecutorService getExecutorService() {
/**
* Sets the given class as controller.
*
* @implNote We don't use {@link FXMLLoader#setController(Object)} since then the {@code fx:controller} attribute
* We don't use {@link FXMLLoader#setController(Object)} since then the {@code fx:controller} attribute
* is no longer allowed in the fxml file and we loose IDE support.
*/
public ViewLoader controller(Object root) {
Expand Down Expand Up @@ -141,8 +141,8 @@ public ViewLoader inject(Function<String, Object> injectionContext) {

/**
* Sets the root of the object hierarchy. The value passed to this method
* is used as the value of the {@link <fx:root>} tag. This method
* must be called prior to loading the document when using {@link <fx:root>}.
* is used as the value of the {@code <fx:root>} tag. This method
* must be called prior to loading the document when using {@code <fx:root>}.
*
* @param root the object used as the root
*/
Expand Down

0 comments on commit 4347d44

Please sign in to comment.