Skip to content

Commit

Permalink
update workflows to better split up workflows and reusable tasks (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
aSemy authored Dec 21, 2023
1 parent 37b6427 commit 8cc9782
Show file tree
Hide file tree
Showing 8 changed files with 240 additions and 142 deletions.
94 changes: 0 additions & 94 deletions .github/workflows/gradle_task.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .github/workflows/publish-maven.yml

This file was deleted.

100 changes: 100 additions & 0 deletions .github/workflows/run_gradle_task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Gradle Task
run-name: "Gradle Task ${{ inputs.gradle-task }} @ ${{ inputs.runs-on }}"

# Reusable Workflow for running a Gradle task

on:
workflow_dispatch:
inputs:
gradle-task:
description: "The Gradle task to run, including any flags"
required: true
type: string
runs-on:
description: "OS to run the task on"
required: true
type: string
checkout-ref:
description: "The repository reference to checkout"
required: false
type: string
workflow_call:
inputs:
gradle-task:
description: "The Gradle task to run, including any flags"
required: true
type: string
runs-on:
description: "OS to run the task on"
required: true
type: string
checkout-ref:
description: "The repository reference to checkout"
required: false
type: string


concurrency:
# note: the Workflow inputs are also included in the concurrency group
group: "Gradle Task: ${{ github.workflow }} ${{ join(inputs.*) }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true


permissions:
contents: read
checks: write # required by mikepenz/action-junit-report


jobs:

run-task:
runs-on: ${{ inputs.runs-on }}
name: "./gradlew ${{ inputs.gradle-task}} @ ${{ inputs.runs-on }}"
timeout-minutes: 60
steps:

### Gradle task ###

- name: Checkout the repo
uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref || github.event.repository.default_branch }}

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11

- uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true
arguments: ${{ inputs.gradle-task }}
env:
"ORG_GRADLE_PROJECT_signing.keyId": ${{ secrets.MAVEN_SONATYPE_SIGNING_KEY_ID }}
"ORG_GRADLE_PROJECT_signing.key": ${{ secrets.MAVEN_SONATYPE_SIGNING_KEY }}
"ORG_GRADLE_PROJECT_signing.password": ${{ secrets.MAVEN_SONATYPE_SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeRepositoryUsername: ${{ secrets.MAVEN_SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypeRepositoryPassword: ${{ secrets.MAVEN_SONATYPE_PASSWORD }}

- name: Upload build reports
if: failure()
uses: actions/upload-artifact@v3
with:
name: build-report-${{ runner.os }}${{ github.action }}
path: |
**/build/reports/
**/*.hprof
**/*.log
if-no-files-found: ignore

- name: Publish Test Reports
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: |
**/build/test-results/**/TEST-*.xml
require_tests: false
42 changes: 42 additions & 0 deletions .github/workflows/run_publish_maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish Maven

on:
workflow_dispatch:
inputs:
checkout-ref:
description: "The repository reference to checkout"
required: false
type: string
workflow_call:
inputs:
checkout-ref:
description: "The repository reference to checkout"
required: false
type: string


concurrency:
group: "Publish Maven: ${{ github.workflow }}"
cancel-in-progress: false


permissions:
contents: write
packages: write
checks: write


jobs:

sonatype-release:
permissions:
contents: read
packages: write
checks: write
uses: ./.github/workflows/run_gradle_task.yml
secrets: inherit
with:
runs-on: macos-latest # only macOS supports building all Kotlin targets
gradle-task: >-
publishAllPublicationsToSonatypeReleaseRepository --stacktrace --no-configuration-cache --no-parallel
checkout-ref: ${{ inputs.checkout-ref || github.event.repository.default_branch }}
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
name: Deploy Site
name: Publish Site

on:
workflow_dispatch:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
inputs:
checkout-ref:
description: "The repository reference to checkout"
required: false
type: string
workflow_call:
inputs:
checkout-ref:
description: "The repository reference to checkout"
required: false
type: string


concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
group: "Publish Site: ${{ github.workflow }}"
cancel-in-progress: true


Expand All @@ -19,6 +27,11 @@ jobs:
steps:
- name: Checkout the repo
uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref || github.event.repository.default_branch }}

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Setup JDK
uses: actions/setup-java@v3
Expand Down Expand Up @@ -48,4 +61,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v2
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
name: Tests

on:
pull_request:
workflow_dispatch:
workflow_call:

concurrency:
group: "Tests on ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
group: "Tests: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true


permissions:
contents: read
checks: write # required by mikepenz/action-junit-report


jobs:

gradle-check:
strategy:
matrix:
os: [ ubuntu-latest, macos-11, windows-latest ]
os: [ ubuntu-latest, macos-latest, windows-latest ]
fail-fast: false
uses: ./.github/workflows/gradle_task.yml
uses: ./.github/workflows/run_gradle_task.yml
with:
runs-on: ${{ matrix.os }}
gradle-task: >-
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/workflow_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Pull Requests


on:
workflow_dispatch:
pull_request:
merge_group:


concurrency:
group: "Pull Requests: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true


jobs:

tests:
uses: ./.github/workflows/run_tests.yml
permissions:
contents: read
checks: write
Loading

0 comments on commit 8cc9782

Please sign in to comment.