From c3116abc48fcfa5952a8a8f1b755966c0eddfcf9 Mon Sep 17 00:00:00 2001 From: Adrian Trapletti Date: Sat, 24 Feb 2024 16:32:08 +0100 Subject: [PATCH] Add Release Workflow (#3) * Cosmetics * Get rid of @implNote as it creates issues with javadoc * Make changes in order to be able to deploy to Maven Central from local * Rename * Use artifact id * Remove GPG keyname * Move Java version to environment variable * Add release workflow * Not needed * Hard code as this seems to work --- .github/workflows/{ci.yml => build.yml} | 2 +- .github/workflows/release.yml | 58 +++++++++ .idea/compiler.xml | 2 +- pom.xml | 112 +++++++++++++++++- .../java/com/ustermetrics/ecos4j/Problem.java | 4 +- .../java/com/ustermetrics/ecos4j/Solver.java | 2 +- 6 files changed, 173 insertions(+), 7 deletions(-) rename .github/workflows/{ci.yml => build.yml} (98%) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/build.yml similarity index 98% rename from .github/workflows/ci.yml rename to .github/workflows/build.yml index f354c33..5630ca0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: CI +name: Build on: push: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3f63405 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +name: Release + +on: + push: + tags: + - 'v*' + +env: + ECOS_VERSION: v2.0.10 + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: '21' + distribution: 'temurin' + cache: maven + - name: Cache ECOS shared library + id: cache-ecos + uses: actions/cache@v3 + env: + cache-name: cache-ecos + with: + path: ./libecos.so + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.ECOS_VERSION }} + - if: ${{ steps.cache-ecos.outputs.cache-hit != 'true' }} + name: Download ECOS shared library + run: curl -L -O https://github.com/atraplet/ecos/releases/download/$ECOS_VERSION/libecos.so + - name: Build with Maven + env: + LD_LIBRARY_PATH: ./ + run: mvn -B clean package --file pom.xml + + release: + runs-on: ubuntu-latest + needs: [ build ] + steps: + - uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: '21' + distribution: 'temurin' + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + - name: Publish to Maven Central + run: mvn -B clean deploy -P release --file pom.xml + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + - name: Create Release + uses: ncipollo/release-action@v1 diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 85de200..6643710 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -3,7 +3,7 @@ - + diff --git a/pom.xml b/pom.xml index c6d9dab..64d0da0 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.ustermetrics ecos4j - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT 21 @@ -15,8 +15,46 @@ ${java.version} UTF-8 UTF-8 + atraplet/${project.artifactId} + ${project.groupId}:${project.artifactId} + ECOS Solver for Java + https://github.com/${git.repository} + + + + GNU General Public License, Version 3 + https://www.gnu.org/licenses/gpl-3.0.txt + + + + + + Adrian Trapletti + a.trapletti@ustermetrics.com + Uster Metrics GmbH + https://www.ustermetrics.com + + + + + scm:git:https://github.com/${git.repository}.git + scm:git:https://github.com/${git.repository}.git + https://github.com/${git.repository}/tree/master + + + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + + com.google.guava @@ -62,7 +100,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.2.3 + 3.2.5 --enable-native-access=com.ustermetrics.ecos4j --enable-preview @@ -71,4 +109,74 @@ + + + release + + + + org.apache.maven.plugins + maven-source-plugin + 3.3.0 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.6.3 + + + attach-javadocs + + jar + + + + + --enable-preview + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.1.0 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + true + + ossrh + https://s01.oss.sonatype.org/ + true + + + + + + + diff --git a/src/main/java/com/ustermetrics/ecos4j/Problem.java b/src/main/java/com/ustermetrics/ecos4j/Problem.java index 6344398..da84b16 100644 --- a/src/main/java/com/ustermetrics/ecos4j/Problem.java +++ b/src/main/java/com/ustermetrics/ecos4j/Problem.java @@ -30,8 +30,8 @@ * where x are the primal variables, s are slack variables, c, G, h, A, and b are the problem data, and K is the * convex cone. The cone K is the Cartesian product of the positive orthant cone, the second order cone, and the * exponential cone. - * - * @implNote In order to control the lifecycle of native memory, {@link Problem} implements the {@link AutoCloseable} + *

+ * In order to control the lifecycle of native memory, {@link Problem} implements the {@link AutoCloseable} * interface and should be used with the try-with-resources statement. */ public class Problem implements AutoCloseable { diff --git a/src/main/java/com/ustermetrics/ecos4j/Solver.java b/src/main/java/com/ustermetrics/ecos4j/Solver.java index d81178d..6949a09 100644 --- a/src/main/java/com/ustermetrics/ecos4j/Solver.java +++ b/src/main/java/com/ustermetrics/ecos4j/Solver.java @@ -105,7 +105,7 @@ int status() { } static Status valueOf(int status) { - for (var c : values()) { + for (val c : values()) { if (c.status() == status) { return c; }