minify-html/.github/workflows/java.yml

104 lines
3.0 KiB
YAML

name: Build and publish Java artifact
on:
create:
tags:
- 'v*'
repository_dispatch:
types: [wf-java]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
ARCH: linux-x86_64
FILE: 'libhyperbuild_java.so'
- os: windows-latest
ARCH: windows-x86_64
FILE: 'hyperbuild_java.dll'
- os: macos-latest
ARCH: macos-x86_64
FILE: 'libhyperbuild_java.dylib'
steps:
- uses: actions/checkout@v1
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.39.0
profile: minimal
default: true
- name: Build Java native library
run: cargo build --release
working-directory: ./java
- name: Upload built library
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.ARCH }}
path: ./java/target/rust/release/${{ matrix.FILE }}
package:
runs-on: ubuntu-latest
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 Windows built library
uses: actions/download-artifact@v1
with:
name: windows-x86_64
path: java/src/main/resources/windows-x86_64
- name: Download Linux built library
uses: actions/download-artifact@v1
with:
name: linux-x86_64
path: java/src/main/resources/linux-x86_64
- name: Download macOS built library
uses: actions/download-artifact@v1
with:
name: macos-x86_64
path: java/src/main/resources/macos-x86_64
- name: Move native library files to correct location
shell: bash
working-directory: ./java/src/main/resources
run: |
for f in *; do
mv $f/* "$f.nativelib"
rmdir "$f"
done
- name: Build, pack, and publish JAR
working-directory: ./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
mvn clean deploy