Skip to content

Commit 550cd4c

Browse files
committed
Update GitHub workflows, add auto Maven Central publishing
1 parent 062e305 commit 550cd4c

File tree

7 files changed

+247
-47
lines changed

7 files changed

+247
-47
lines changed

.github/workflows/gradle_task.yml renamed to .github/workflows/run_gradle_task.yml

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,19 @@ run-name: "Gradle Task ${{ inputs.gradle-task }} @ ${{ inputs.runs-on }}"
55

66
on:
77
workflow_dispatch:
8-
8+
inputs:
9+
gradle-task:
10+
description: "The Gradle task to run, including any flags"
11+
required: true
12+
type: string
13+
runs-on:
14+
description: "OSes to run the task on"
15+
required: true
16+
type: string
17+
checkout-ref:
18+
description: "The repository reference to checkout"
19+
required: false
20+
type: string
921
workflow_call:
1022
inputs:
1123
gradle-task:
@@ -16,18 +28,23 @@ on:
1628
description: "OSes to run the task on"
1729
required: true
1830
type: string
31+
checkout-ref:
32+
description: "The repository reference to checkout"
33+
required: false
34+
type: string
1935

2036

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

2642

2743
permissions:
2844
contents: read
2945
checks: write # required by mikepenz/action-junit-report
3046

47+
3148
jobs:
3249

3350
run-task:
@@ -40,27 +57,37 @@ jobs:
4057

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

44-
- name: Setup JDK
63+
- name: Validate Gradle Wrapper
64+
uses: gradle/wrapper-validation-action@v1
65+
66+
- name: Setup JDK 11
4567
uses: actions/setup-java@v3
4668
with:
4769
distribution: temurin
4870
java-version: 11
4971

50-
- name: Cache Gradle TestKit
51-
id: cache-gradle-testkit
52-
uses: actions/cache@v3
72+
- name: Setup JDK 17
73+
uses: actions/setup-java@v3
5374
with:
54-
path: |
55-
${{ runner.temp }}/.gradle-test-kit/caches
56-
key: gradle-testkit-${{ runner.os }}
75+
distribution: temurin
76+
java-version: 17
77+
78+
- name: Setup Android SDK # required for integration tests
79+
uses: android-actions/setup-android@v2
5780

5881
- uses: gradle/gradle-build-action@v2
59-
env:
60-
GRADLE_TESTKIT_DIR: ${{ runner.temp }}/.gradle-test-kit/caches
6182
with:
6283
gradle-home-cache-cleanup: true
63-
arguments: ${{ inputs.gradle-task }} --scan
84+
arguments: ${{ inputs.gradle-task }}
85+
env:
86+
MAVEN_SONATYPE_USERNAME: ${{ secrets.MAVEN_SONATYPE_USERNAME }}
87+
MAVEN_SONATYPE_PASSWORD: ${{ secrets.MAVEN_SONATYPE_PASSWORD }}
88+
MAVEN_SONATYPE_SIGNING_KEY_ID: ${{ secrets.MAVEN_SONATYPE_SIGNING_KEY_ID }}
89+
MAVEN_SONATYPE_SIGNING_KEY: ${{ secrets.MAVEN_SONATYPE_SIGNING_KEY }}
90+
MAVEN_SONATYPE_SIGNING_PASSWORD: ${{ secrets.MAVEN_SONATYPE_SIGNING_PASSWORD }}
6491

6592
- name: Upload build reports
6693
if: failure()
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Publish Maven
2+
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
checkout-ref:
8+
description: "The repository reference to checkout"
9+
required: false
10+
type: string
11+
workflow_call:
12+
inputs:
13+
checkout-ref:
14+
description: "The repository reference to checkout"
15+
required: false
16+
type: string
17+
18+
19+
concurrency:
20+
group: "Publish Maven: ${{ github.workflow }}"
21+
cancel-in-progress: false
22+
23+
24+
permissions:
25+
contents: write
26+
packages: write
27+
checks: write
28+
29+
30+
jobs:
31+
32+
sonatype-release:
33+
if: github.ref == 'refs/heads/main'
34+
permissions:
35+
contents: read
36+
packages: write
37+
checks: write
38+
uses: ./.github/workflows/run_gradle_task.yml
39+
secrets: inherit
40+
with:
41+
runs-on: macos-latest # only macOS supports building all Kotlin targets
42+
gradle-task: >-
43+
publishAllPublicationsToSonatypeReleaseRepository --stacktrace --no-configuration-cache --no-parallel
44+
checkout-ref: ${{ inputs.checkout-ref || github.event.repository.default_branch }}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish Site
2+
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
checkout-ref:
8+
description: "The repository reference to checkout"
9+
required: false
10+
type: string
11+
workflow_call:
12+
inputs:
13+
checkout-ref:
14+
description: "The repository reference to checkout"
15+
required: false
16+
type: string
17+
18+
19+
concurrency:
20+
group: "Publish Site: ${{ github.workflow }}"
21+
cancel-in-progress: true
22+
23+
24+
jobs:
25+
26+
build:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout the repo
30+
uses: actions/checkout@v3
31+
with:
32+
ref: ${{ inputs.checkout-ref || github.event.repository.default_branch }}
33+
34+
- name: Setup JDK
35+
uses: actions/setup-java@v3
36+
with:
37+
distribution: temurin
38+
java-version: 11
39+
40+
deploy:
41+
needs: build
42+
runs-on: ubuntu-latest
43+
permissions:
44+
pages: write # to deploy to Pages
45+
id-token: write # to verify the deployment originates from an appropriate source
46+
environment:
47+
name: github-pages
48+
url: ${{ steps.deployment.outputs.page_url }}
49+
steps:
50+
- name: Deploy to GitHub Pages
51+
id: deployment
52+
uses: actions/deploy-pages@v1

.github/workflows/run_tests.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Tests
2+
3+
4+
on:
5+
workflow_dispatch:
6+
workflow_call:
7+
8+
9+
concurrency:
10+
group: "Tests: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
11+
cancel-in-progress: true
12+
13+
14+
permissions:
15+
contents: read
16+
checks: write # required by mikepenz/action-junit-report
17+
18+
19+
jobs:
20+
21+
gradle-check:
22+
strategy:
23+
matrix:
24+
include:
25+
- os: macos-latest
26+
task: "check --continue"
27+
- os: ubuntu-latest
28+
task: "check --continue"
29+
- os: windows-latest
30+
task: "check --continue"
31+
fail-fast: false
32+
uses: ./.github/workflows/run_gradle_task.yml
33+
with:
34+
runs-on: ${{ matrix.os }}
35+
gradle-task: >-
36+
${{ matrix.task }} --stacktrace
37+
checkout-ref: ${{ inputs.checkout-ref || github.event.repository.default_branch }}

.github/workflows/tests.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Pull Requests
2+
3+
4+
on:
5+
workflow_dispatch:
6+
pull_request:
7+
merge_group:
8+
9+
10+
concurrency:
11+
group: "Pull Requests: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
12+
cancel-in-progress: true
13+
14+
15+
jobs:
16+
17+
tests:
18+
uses: ./.github/workflows/run_tests.yml
19+
permissions:
20+
contents: read
21+
checks: write
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Releases
2+
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
checkout-ref:
8+
description: "The repository reference to checkout"
9+
required: false
10+
type: string
11+
push:
12+
branches: [ main ]
13+
release:
14+
types: [ created ]
15+
16+
17+
concurrency:
18+
group: "Releases: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
19+
cancel-in-progress: true
20+
21+
22+
jobs:
23+
24+
tests:
25+
uses: ./.github/workflows/run_tests.yml
26+
permissions:
27+
contents: read
28+
checks: write
29+
30+
publish-maven:
31+
needs: tests
32+
if: github.ref == 'refs/heads/main'
33+
uses: ./.github/workflows/run_publish_maven.yml
34+
secrets: inherit
35+
permissions:
36+
contents: write
37+
packages: write
38+
checks: write
39+
with:
40+
checkout-ref: ${{ inputs.checkout-ref || github.event.repository.default_branch }}
41+
42+
publish-site:
43+
needs: tests
44+
# only publish site when releasing
45+
if: github.ref == 'refs/heads/main' && github.event_name == 'release' && github.event.action == 'created'
46+
uses: ./.github/workflows/run_publish_site.yml
47+
permissions:
48+
contents: read
49+
packages: write
50+
checks: write
51+
pages: write
52+
id-token: write
53+
with:
54+
checkout-ref: ${{ inputs.checkout-ref || github.event.repository.default_branch }}

0 commit comments

Comments
 (0)