Skip to content

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:
target:
- aarch64-unknown-linux-gnu
- x86_64-unknown-linux-gnu
- aarch64-apple-darwin
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
include:
- target: aarch64-unknown-linux-gnu
os: ubuntu-20.04
buildfile: 'libminify_html_java.so'
resfile: 'linux-aarch64.nativelib'
- target: x86_64-unknown-linux-gnu
os: ubuntu-20.04
buildfile: 'libminify_html_java.so'
resfile: 'linux-x64.nativelib'
- target: aarch64-apple-darwin
os: macos-11.0
buildfile: 'libminify_html_java.dylib'
resfile: 'mac-aarch64.nativelib'
- target: x86_64-apple-darwin
os: macos-11.0
buildfile: 'libminify_html_java.dylib'
resfile: 'mac-x64.nativelib'
- target: x86_64-pc-windows-msvc
os: windows-2019
buildfile: 'minify_html_java.dll'
resfile: 'win-x64.nativelib'
steps:
- uses: actions/checkout@v1
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Set up cross compiler
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
run: sudo apt install -y gcc-aarch64-linux-gnu
- name: Build Java native library
working-directory: ./minify-html-java
shell: bash
run: |
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc
cargo build --release --target ${{ matrix.target }}
# upload-artifact does not rename the file, so when we download if we don't rename all files will have the same name.
mv -v ../target/${{ matrix.target }}/release/${{ matrix.buildfile }} ${{ matrix.resfile }}
- name: Upload built library
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.resfile }}
path: minify-html-java/${{ matrix.resfile }}
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
- uses: actions/download-artifact@v4
with:
path: 'minify-html-java/src/main/resources/'
merge-multiple: true
- 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" | gpg --allow-secret-key-import --import
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