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

119 lines
3.2 KiB
YAML
Raw Normal View History

name: Build and publish Java artifact
on:
2021-08-05 22:22:24 -04:00
push:
tags:
- 'v*'
2021-08-05 22:22:24 -04:00
workflow_dispatch:
jobs:
2020-01-18 02:20:00 -05:00
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-11.0, ubuntu-20.04, windows-2019]
include:
2021-04-06 04:50:24 -04:00
- os: macos-11.0
ARCH: macos-x86_64
2020-07-11 11:29:34 -04:00
FILE: 'libminify_html_java.dylib'
- os: ubuntu-20.04
ARCH: linux-x86_64
FILE: 'libminify_html_java.so'
2021-04-06 04:50:24 -04:00
- os: windows-2019
ARCH: windows-x86_64
2020-07-24 03:55:22 -04:00
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: Run prebuild steps
shell: bash
run: bash ./prebuild.sh
- 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 }}
2020-01-18 02:20:00 -05:00
path: ./java/target/rust/release/${{ matrix.FILE }}
2022-06-21 10:43:09 -04:00
package:
runs-on: ubuntu-20.04
2020-01-18 02:20:00 -05:00
needs: build
steps:
- uses: actions/checkout@v1
- name: Set up JDK
uses: actions/setup-java@v1
with:
2020-01-18 08:21:58 -05:00
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: 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: Download Windows built library
uses: actions/download-artifact@v1
with:
name: windows-x86_64
path: java/src/main/resources/windows-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:
2020-01-19 22:18:03 -05:00
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
2020-06-19 04:27:46 -04:00
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
2020-06-18 21:44:54 -04:00
mvn clean deploy
fi