-
Notifications
You must be signed in to change notification settings - Fork 1
141 lines (121 loc) · 5.18 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: CI
on: [push, pull_request]
env:
GRADLE_OPTS: "-Dorg.gradle.internal.launcher.welcomeMessageEnabled=false"
defaults:
run:
shell: bash
jobs:
validate-gradle-wrapper:
name: "Validate Gradle wrapper"
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4.1.7
with:
fetch-depth: 0
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v3.4.2
test:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- windows-2022
- macos-11
name: "Test (${{ matrix.os }})"
runs-on: ${{ matrix.os }}
steps:
- name: Check out code
uses: actions/checkout@v4.1.7
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v4.2.1
with:
java-version: 11.0.14+101 # We must use Java 15 or earlier until https://youtrack.jetbrains.com/issue/KT-47039 is fixed.
distribution: adopt
- name: Cache Gradle
id: cache-gradle
uses: actions/cache@v4.0.2
with:
path: ~/.gradle/wrapper/dists
key: gradle-wrapper-${{ hashFiles('gradle/wrapper/*') }}
- name: Cache packages
id: cache-packages
uses: actions/cache@v4.0.2
with:
path: ~/.gradle/caches
key: gradle-packages-${{ runner.os }}-${{ hashFiles('**/*.gradle.kts', 'gradle/wrapper/*') }}
restore-keys: gradle-packages-${{ runner.os }}
- name: Allow modifying macOS certificate trust settings without prompting
if: startsWith(matrix.os, 'macos')
run: sudo security authorizationdb write com.apple.trust-settings.user allow
- name: Build and test
run: ./gradlew --parallel check
- 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/*
publish:
name: "Publish"
runs-on: ubuntu-22.04
if: github.repository == 'charleskorn/okhttp-system-keystore' && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
needs:
- test
- validate-gradle-wrapper
steps:
- name: Check out code
uses: actions/checkout@v4.1.7
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v4.2.1
with:
java-version: 11 # We must use Java 15 or earlier until https://youtrack.jetbrains.com/issue/KT-47039 is fixed.
distribution: adopt
- name: Cache Gradle
id: cache-gradle
uses: actions/cache@v4.0.2
with:
path: ~/.gradle/wrapper/dists
key: gradle-wrapper-${{ hashFiles('gradle/wrapper/*') }}
- name: Cache packages
id: cache-packages
uses: actions/cache@v4.0.2
with:
path: ~/.gradle/caches
key: gradle-packages-${{ runner.os }}-${{ hashFiles('**/*.gradle.kts', 'gradle/wrapper/*') }}
restore-keys: gradle-packages-${{ runner.os }}
- name: Publish snapshot
run: ./gradlew publishSnapshot
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_KEY_PASSPHRASE }}
if: github.repository == 'charleskorn/okhttp-system-keystore' && github.ref == 'refs/heads/main' && github.event_name == 'push'
- name: Publish release
run: ./gradlew publishRelease
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_KEY_PASSPHRASE }}
if: github.repository == 'charleskorn/okhttp-system-keystore' && startsWith(github.ref, 'refs/tags/') && github.event_name == 'push'