Skip to content

Build and publish Java artifact #144

Build and publish Java artifact

Build and publish Java artifact #144

Workflow file for this run

name: Build and publish Java artifact
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-11.0, ubuntu-20.04, windows-2019]
include:
- os: macos-11.0
ARCH: macos-x86_64
FILE: 'libminify_html_java.dylib'
- os: ubuntu-20.04
ARCH: linux-x86_64
FILE: 'libminify_html_java.so'
- os: windows-2019
ARCH: windows-x86_64
FILE: 'minify_html_java.dll'
steps:
- uses: actions/checkout@v1
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Build Java native library
run: cargo build --release
working-directory: ./minify-html-java
- name: Upload built library
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.ARCH }}
path: ./target/release/${{ matrix.FILE }}
package:
runs-on: ubuntu-20.04
needs: build
steps:
- uses: actions/checkout@v1
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: '1.7'
java-package: jdk
architecture: x64
- name: Download Linux built library
uses: actions/download-artifact@v1
with:
name: linux-x86_64
path: minify-html-java/src/main/resources/linux-x86_64
- name: Download macOS built library
uses: actions/download-artifact@v1
with:
name: macos-x86_64
path: minify-html-java/src/main/resources/macos-x86_64
- name: Download Windows built library
uses: actions/download-artifact@v1
with:
name: windows-x86_64
path: minify-html-java/src/main/resources/windows-x86_64
- name: Move native library files to correct location
shell: bash
working-directory: ./minify-html-java/src/main/resources
run: |
for f in *; do
mv $f/* "$f.nativelib"
rmdir "$f"
done
- name: Build, pack, and publish JAR
working-directory: ./minify-html-java
env:
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
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
mvn clean deploy
fi