Merge pull request #100 from bgilbert/release #107
This file contains hidden or 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: | |
| pre-commit: | |
| name: Rerun pre-commit checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.14 | |
| - name: Install dependencies | |
| run: python -m pip install pre-commit | |
| - name: Cache pre-commit environments | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pre-commit | |
| key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} | |
| - name: Run pre-commit hooks | |
| run: pre-commit run -a --show-diff-on-failure --color=always | |
| build: | |
| name: Build | |
| needs: pre-commit | |
| runs-on: ${{ matrix.os }} | |
| outputs: | |
| dist-base: ${{ steps.dist.outputs.dist-base }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest] | |
| java: [22, 25] | |
| include: | |
| - os: ubuntu-latest | |
| java: 22 | |
| dist: dist | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@v5 | |
| - name: Install Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: oracle | |
| java-version: ${{ matrix.java }} | |
| cache: maven | |
| - name: Install dependencies (Linux) | |
| if: startsWith(matrix.os, 'ubuntu-') | |
| run: | | |
| sudo add-apt-repository "ppa:openslide/openslide" | |
| sudo apt-get install libopenslide1 | |
| - name: Install dependencies (macOS) | |
| if: matrix.os == 'macos-latest' | |
| 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@v5 | |
| 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@v5 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v6 | |
| 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 }}/"* |