workflows: add JAR release artifact; drop source tarball #53
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Java | |
on: | |
push: | |
branches: [main] | |
tags: ["*"] | |
pull_request: | |
branches: [main] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
name: Build | |
runs-on: ${{ matrix.os }} | |
outputs: | |
dist-base: ${{ steps.dist.outputs.dist-base }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-14, windows-latest] | |
include: | |
- os: ubuntu-latest | |
dist: dist | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v4 | |
- name: Install Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: oracle | |
java-version: 22 | |
- name: Install dependencies (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get install libopenslide0 ninja-build | |
# Ubuntu 22.04 packages Meson 0.61 | |
pip install --user meson | |
- name: Install dependencies (macOS) | |
if: matrix.os == 'macos-14' | |
run: | | |
brew install meson openslide | |
# allow smoke test to find OpenSlide | |
echo "DYLD_LIBRARY_PATH=/opt/homebrew/lib" >> $GITHUB_ENV | |
- name: Install dependencies (Windows) | |
if: matrix.os == 'windows-latest' | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
pip install meson ninja | |
mkdir -p "c:\\openslide" | |
cd "c:\\openslide" | |
release=$(gh release list -R openslide/openslide-bin -L 1 \ | |
--json tagName --exclude-drafts --exclude-pre-releases | \ | |
jq -r .[0].tagName | \ | |
tr -d v) | |
zipname="openslide-bin-${release}-windows-x64" | |
gh release download -R openslide/openslide-bin "v${release}" \ | |
--pattern "${zipname}.zip" | |
7z x ${zipname}.zip | |
# allow smoke test to find OpenSlide | |
echo "PATH=c:\\openslide\\${zipname}\\bin;$PATH" >> $GITHUB_ENV | |
- name: Build | |
run: | | |
meson setup builddir | |
meson compile -C builddir | |
- name: Smoke test | |
run: | | |
java --enable-native-access=ALL-UNNAMED -cp builddir/openslide.jar \ | |
org.openslide.TestCLI fixtures/small.svs | |
- name: Dist | |
id: dist | |
if: matrix.dist | |
run: | | |
set -o pipefail | |
dist="openslide-java-dist-$GITHUB_RUN_NUMBER-$(echo $GITHUB_SHA | cut -c-10)" | |
echo "dist-base=$dist" >> $GITHUB_OUTPUT | |
mkdir -p "artifacts/$dist" | |
version=$(meson introspect --projectinfo builddir | jq -r .version) | |
mv builddir/openslide.jar \ | |
"artifacts/${dist}/openslide-java-${version}.jar" | |
- name: Archive dist | |
if: matrix.dist | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.dist.outputs.dist-base }} | |
path: artifacts | |
compression-level: 0 | |
release: | |
name: Release | |
if: github.ref_type == 'tag' | |
needs: build | |
runs-on: ubuntu-latest | |
concurrency: release-${{ github.ref }} | |
permissions: | |
contents: write | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: ${{ needs.build.outputs.dist-base }} | |
merge-multiple: true | |
- name: Release to GitHub | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
version=$(echo "${{ github.ref_name }}" | sed "s/^v//") | |
awk -e '/^## / && ok {exit}' \ | |
-e '/^## / {ok=1; next}' \ | |
-e 'ok {print}' \ | |
CHANGELOG.md > changes | |
gh release create --prerelease --verify-tag \ | |
--repo "${{ github.repository }}" \ | |
--title "OpenSlide Java $version" \ | |
--notes-file changes \ | |
"${{ github.ref_name }}" \ | |
"${{ needs.build.outputs.dist-base }}/"* |