Skip to content

Set Java distribution for CI pipeline #1362

Set Java distribution for CI pipeline

Set Java distribution for CI pipeline #1362

Workflow file for this run

name: Pipeline
on: [push, pull_request]
jobs:
build:
name: "Build, Test and Publish"
runs-on: ubuntu-latest
env:
TERM: xterm-256color
GPG_KEY_ID: 6D76AD03 # Run `gpg -K` to get this, take last eight characters
OSSRH_USERNAME: kaml-github-actions
GRADLE_OPTS: "-Dorg.gradle.internal.launcher.welcomeMessageEnabled=false"
permissions:
contents: write # Required to be able to publish releases, see https://docs.github.com/en/rest/reference/permissions-required-for-github-apps#permission-on-contents
steps:
- name: Check out code
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Validate Gradle wrapper
uses: gradle/[email protected]
- name: Set up JDK
uses: actions/[email protected]
with:
java-version: 18
distribution: temurin
- name: Cache Gradle
id: cache-gradle
uses: actions/[email protected]
with:
path: ~/.gradle/wrapper/dists
key: gradle-wrapper-${{ hashFiles('gradle/wrapper/*') }}
- name: Cache packages
id: cache-packages
uses: actions/[email protected]
with:
path: ~/.gradle/caches
key: gradle-packages-${{ runner.os }}-${{ hashFiles('**/*.gradle.kts', 'gradle/wrapper/*') }}
restore-keys: gradle-packages-${{ runner.os }}
- name: Build
run: ./gradlew assemble
- name: Check
run: ./gradlew check
- name: Generate code coverage report
run: ./gradlew jacocoTestReport
- name: Upload coverage to codecov.io
uses: codecov/[email protected]
- name: Assemble release
run: ./gradlew assembleRelease
env:
GPG_KEY_RING: ${{ secrets.GPG_KEY_RING }} # Run `gpg --export-secret-keys "<key user name goes here>" | base64` to get this
GPG_KEY_PASSPHRASE: ${{ secrets.GPG_KEY_PASSPHRASE }}
if: github.repository == 'charleskorn/kaml' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push'
- name: Publish snapshot
run: ./gradlew publishSnapshot
env:
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_KEY_RING: ${{ secrets.GPG_KEY_RING }} # Run `gpg --export-secret-keys "<key user name goes here>" | base64` to get this
GPG_KEY_PASSPHRASE: ${{ secrets.GPG_KEY_PASSPHRASE }}
if: github.repository == 'charleskorn/kaml' && github.ref == 'refs/heads/main' && github.event_name == 'push'
- name: Publish release
run: ./gradlew publishRelease
env:
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_KEY_RING: ${{ secrets.GPG_KEY_RING }} # Run `gpg --export-secret-keys "<key user name goes here>" | base64` to get this
GPG_KEY_PASSPHRASE: ${{ secrets.GPG_KEY_PASSPHRASE }}
if: github.repository == 'charleskorn/kaml' && startsWith(github.ref, 'refs/tags/') && github.event_name == 'push'
- name: Create GitHub release
uses: softprops/[email protected]
with:
files: build/release/*
fail_on_unmatched_files: true
draft: true # Update draft release with matching tag, if there is one.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: github.repository == 'charleskorn/kaml' && startsWith(github.ref, 'refs/tags/') && github.event_name == 'push'
- name: Clean up dependencies before caching
if: steps.cache-packages.outputs.cache-hit != 'true'
run: |
rm -rf ~/.gradle/caches/gradle-cache/caches/modules-2/modules-2.lock
rm -rf ~/.gradle/caches/gradle-cache/caches/*/plugin-resolution/
rm -rf ~/.gradle/caches/gradle-cache/caches/*/scripts/
rm -rf ~/.gradle/caches/gradle-cache/caches/*/scripts-remapped/
rm -rf ~/.gradle/caches/gradle-cache/caches/*/fileHashes/
rm -rf ~/.gradle/caches/gradle-cache/caches/*/fileContent/*.lock
rm -rf ~/.gradle/caches/gradle-cache/caches/*/javaCompile/*.lock
rm -rf ~/.gradle/caches/gradle-cache/caches/*/executionHistory/*.lock
rm -rf ~/.gradle/caches/gradle-cache/caches/*/generated-gradle-jars/*.lock
rm -rf ~/.gradle/caches/gradle-cache/caches/jars-*/*.lock
rm -rf ~/.gradle/caches/gradle-cache/caches/transforms-1/transforms-1.lock
rm -rf ~/.gradle/caches/gradle-cache/caches/journal-1/file-access.bin
rm -rf ~/.gradle/caches/gradle-cache/caches/journal-1/*.lock
rm -rf ~/.gradle/caches/gradle-cache/daemon/*/*.lock
rm -rf ~/.gradle/caches/gradle-cache/daemon/*/*.log
rm -rf ~/.gradle/caches/gradle-cache/kotlin-profile/*