Publish Java from workflow

This commit is contained in:
Wilson Lin 2020-01-20 14:18:03 +11:00
parent 49408299d2
commit 8b825e8fd8
3 changed files with 120 additions and 14 deletions

View File

@ -42,10 +42,6 @@ jobs:
needs: build
steps:
- uses: actions/checkout@v1
- name: Get version
id: version
shell: bash
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
- name: Set up JDK
uses: actions/setup-java@v1
with:
@ -75,13 +71,31 @@ jobs:
mv $f/* "$f.nativelib"
rmdir "$f"
done
- name: Build and package JAR
- name: Build, package, and publish JAR
working-directory: ./java
run: mvn clean package
- uses: chrislennon/action-aws-cli@v1.1
- name: Upload to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-west-2
run: aws s3 cp ./java/target/hyperbuild-${{ steps.version.outputs.VERSION }}.jar s3://${{ secrets.AWS_S3_BUCKET }}/hyperbuild/bin/${{ steps.version.outputs.VERSION }}.jar
SONATYPE_GPG_PRIVATE_KEY: ${{ secrets.SONATYPE_GPG_PRIVATE_KEY }}
run: |
echo "$SONATYPE_GPG_PRIVATE_KEY" | base64 -d > sonatype-gpg-private-key.asc
gpg --import sonatype-gpg-private-key.asc
mkdir -p "$HOME/.m2"
cat << 'EOF' > "$HOME/.m2/settings.xml"
<settings>
<servers>
<server>
<id>ossrh</id>
<username>wilsonzlin</username>
<password>${{ secrets.SONATYPE_PASSWORD }}</password>
</server>
</servers>
<profiles>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
</settings>
'EOF'
mvn clean deploy

View File

@ -33,6 +33,17 @@
<developerConnection>scm:git:git@github.com:wilsonzlin/hyperbuild.git</developerConnection>
</scm>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<properties>
<java.version>1.7</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -44,11 +55,67 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</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>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -8,6 +8,11 @@ import java.nio.file.StandardCopyOption;
import static java.lang.String.format;
/**
* Class containing only static methods and exception classes. Cannot be instantiated.
* Methods call to native compiled Rust code using JNI.
* When this class is loaded, a static initialiser will attempt to load a prebuilt native library for the running operating system and architecture from the JAR. If it cannot, a {@link RuntimeException} will be thrown.
*/
public class Hyperbuild {
static {
String osName = System.getProperty("os.name").toLowerCase();
@ -41,10 +46,30 @@ public class Hyperbuild {
private Hyperbuild() {
}
public static native int minifyInPlace(ByteBuffer code) throws SyntaxException;
/**
* Minify UTF-8 HTML code contents of a {@link ByteBuffer} instance in place.
* The backing data will be mutated. Returns the length of the minified portion of the ByteBuffer.
* The ByteBuffer must be direct, otherwise {@link IllegalArgumentException} will be thrown.
* If the code fails to be minified, a {@link SyntaxException} will be thrown with a descriptive English message and position in code where the error occurred.
*
* @param code {@link ByteBuffer} containing HTML code to minify
* @return length of the written minified code in the {@link ByteBuffer}
*/
public static native int minifyInPlace(ByteBuffer code);
public static native String minify(String code) throws SyntaxException;
/**
* Minify HTML code represented as a {@link String}.
* The {@link String} will be copied to a UTF-8 byte array in native code, and then copied back into a Java {@link String}.
* If the code fails to be minified, a {@link SyntaxException} will be thrown with a descriptive English message and position in code where the error occurred.
*
* @param code HTML code to minify
* @return minified HTML code
*/
public static native String minify(String code);
/**
* Basic exception class representing minification errors.
*/
public static class SyntaxException extends RuntimeException {
private SyntaxException(String message) {
super(message);