Skip to content

Commit

Permalink
Add Release Workflow (#3)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
atraplet authored Feb 24, 2024
1 parent 6484ccf commit c3116ab
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Build

on:
push:
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

112 changes: 110 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.ustermetrics</groupId>
<artifactId>ecos4j</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.1.0-SNAPSHOT</version>

<properties>
<java.version>21</java.version>
Expand All @@ -15,8 +15,46 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<git.repository>atraplet/${project.artifactId}</git.repository>
</properties>

<name>${project.groupId}:${project.artifactId}</name>
<description>ECOS Solver for Java</description>
<url>https://github.com/${git.repository}</url>

<licenses>
<license>
<name>GNU General Public License, Version 3</name>
<url>https://www.gnu.org/licenses/gpl-3.0.txt</url>
</license>
</licenses>

<developers>
<developer>
<name>Adrian Trapletti</name>
<email>a.trapletti@ustermetrics.com</email>
<organization>Uster Metrics GmbH</organization>
<organizationUrl>https://www.ustermetrics.com</organizationUrl>
</developer>
</developers>

<scm>
<connection>scm:git:https://github.com/${git.repository}.git</connection>
<developerConnection>scm:git:https://github.com/${git.repository}.git</developerConnection>
<url>https://github.com/${git.repository}/tree/master</url>
</scm>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down Expand Up @@ -62,7 +100,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.3</version>
<version>3.2.5</version>
<configuration>
<argLine>--enable-native-access=com.ustermetrics.ecos4j --enable-preview</argLine>
</configuration>
Expand All @@ -71,4 +109,74 @@
</pluginManagement>
</build>

<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<additionalOptions>--enable-preview</additionalOptions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
4 changes: 2 additions & 2 deletions src/main/java/com/ustermetrics/ecos4j/Problem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}
* <p>
* In order to control the lifecycle of native memory, {@link Problem} implements the {@link AutoCloseable}
* interface and should be used with the <i>try-with-resources</i> statement.
*/
public class Problem implements AutoCloseable {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ustermetrics/ecos4j/Solver.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c3116ab

Please sign in to comment.