Fixed publish dokka to GitHub pages (#116) #328
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: 'Build' | |
on: | |
pull_request: | |
push: | |
branches: | |
- 'master' | |
workflow_dispatch: | |
env: | |
GRADLE_OPTS: -Dorg.gradle.daemon=true -Dorg.gradle.parallel=true -Dorg.gradle.welcome=never | |
PGP_SEC: ${{ secrets.PGP_SEC }} | |
PGP_PASSWORD: ${{ secrets.PGP_PASSWORD }} | |
SONATYPE_USER: ${{ secrets.SONATYPE_USER }} | |
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} | |
jobs: | |
build: | |
name: 'Build (Java ${{ matrix.java-version }})' | |
runs-on: macos-latest | |
strategy: | |
# We need multiple builds to run even if the 1st one is failing, because | |
# test failures may be Java-specific (or the tests themselves flaky). | |
# | |
# Java 8 is incompatible with `org.ajoberstar.reckon.settings`. | |
fail-fast: false | |
matrix: | |
java-version: [ '11', '17' ] | |
# A possible workaround for <https://github.com/dorny/test-reporter/issues/168>. | |
permissions: | |
checks: write | |
contents: write | |
pull-requests: write | |
statuses: write | |
# Explicitly granted, necessary for the `publish` step. | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Fetch Git tags, so that semantic version can be calculated. | |
# Alternatively, run `git fetch --prune --unshallow --tags` as the | |
# next step, see | |
# https://github.com/actions/checkout/issues/206#issuecomment-607496604. | |
fetch-depth: 0 | |
- name: 'Set up Java ${{ matrix.java-version }}' | |
uses: actions/setup-java@v4 | |
with: | |
distribution: zulu | |
java-version: ${{ matrix.java-version }} | |
java-package: jdk+fx | |
- name: 'Cache ~/.konan' | |
id: cache-konan | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.konan | |
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle.kts', '**/gradle-wrapper.properties') }}-build-java${{ matrix.java-version }} | |
restore-keys: | | |
${{ runner.os }}-konan-${{ hashFiles('**/*.gradle.kts', '**/gradle-wrapper.properties') }}- | |
${{ runner.os }}-konan- | |
- name: 'Run unit tests' | |
id: test | |
uses: gradle/gradle-build-action@v3 | |
with: | |
gradle-version: wrapper | |
# Neither `check` nor `allTests` targets result in JUnit XML reports | |
# being generated for a KMP project, even if `Test`/`KotlinTest` tasks | |
# are configured properly, see https://youtrack.jetbrains.com/issue/KT-32608. | |
# | |
# The only workaround is to manually invoke all `xyzTest` targets. | |
# | |
# The `build` target should be invoked in a separate step, otherwise, | |
# all `*Test` targets are considered its dependencies and skipped. | |
arguments: | | |
jvmTest | |
mingwX64Test | |
linuxX64Test | |
macosX64Test | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# This step needs a Git repository, so it's impossible to extract it | |
# into a separate job (or, otherwise, we'd need to upload the content | |
# of the whole `.git` folder as an artifact). | |
- name: 'JUnit Tests (dorny/test-reporter)' | |
uses: dorny/test-reporter@v1 | |
if: ${{ always() }} | |
with: | |
name: 'JUnit Tests (dorny/test-reporter, Java ${{ matrix.java-version }})' | |
# Comma-separated values. | |
path: "**/build/test-results/*/TEST-*.xml" | |
reporter: java-junit | |
# Ignore the "Resource not accessible by integration" error when a PR | |
# originates from a non-collaborator. This is | |
# <https://github.com/dorny/test-reporter/issues/168> which may be | |
# potentially fixed with <https://github.com/dorny/test-reporter/pull/174>. | |
continue-on-error: true | |
- name: 'Upload test results' | |
uses: actions/upload-artifact@v4 | |
if: ${{ always() }} | |
with: | |
name: xml-test-reports-java${{ matrix.java-version }} | |
path: | | |
**/build/test-results/*/TEST-*.xml | |
retention-days: 1 | |
- name: 'Execute Gradle build' | |
id: build | |
uses: gradle/gradle-build-action@v3 | |
with: | |
gradle-version: wrapper | |
arguments: | | |
build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 'Publish a snapshot (Java 17 only)' | |
id: publish | |
if: ${{ github.event_name == 'push' && github.ref_type == 'branch' && github.ref == 'refs/heads/master' && matrix.java-version == 17 }} | |
uses: gradle/gradle-build-action@v3 | |
with: | |
gradle-version: wrapper | |
arguments: | | |
publish | |
-Preckon.stage=snapshot | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
report: | |
name: 'Publish JUnit test results (Java ${{ matrix.java-version }})' | |
if: ${{ always() }} | |
needs: build | |
runs-on: macos-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
java-version: [ '11', '17' ] | |
permissions: | |
checks: write | |
pull-requests: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
if: ${{ always() }} | |
with: | |
name: xml-test-reports-java${{ matrix.java-version }} | |
# Uses Docker, that's why Linux-only. | |
- name: 'JUnit Tests (EnricoMi/publish-unit-test-result-action)' | |
uses: EnricoMi/publish-unit-test-result-action/macos@v2 | |
with: | |
check_name: 'JUnit Tests (EnricoMi/publish-unit-test-result-action, Java ${{ matrix.java-version }})' | |
files: | | |
**/build/test-results/*/TEST-*.xml |