Skip to content

Merge pull request #80 from bgilbert/brew #69

Merge pull request #80 from bgilbert/brew

Merge pull request #80 from bgilbert/brew #69

Workflow file for this run

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
cache: maven
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo add-apt-repository "ppa:openslide/openslide"
sudo apt-get install libopenslide1
- name: Install dependencies (macOS)
if: matrix.os == 'macos-14'
run: |
brew update
brew install 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: |
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: mvn -Dmaven.compiler.failOnWarning=true
- name: Smoke test
run: |
OPENSLIDE_DEBUG=synthetic java --enable-native-access=ALL-UNNAMED \
-cp target/openslide-java-*.jar org.openslide.TestCLI ""
- name: Dist
id: dist
if: matrix.dist
run: |
dist="openslide-java-dist-$GITHUB_RUN_NUMBER-$(echo $GITHUB_SHA | cut -c-10)"
echo "dist-base=$dist" >> $GITHUB_OUTPUT
mkdir -p "artifacts/$dist"
mv target/openslide-java-*.jar "artifacts/${dist}"
- 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 }}/"*