-
Notifications
You must be signed in to change notification settings - Fork 3
246 lines (218 loc) · 9.2 KB
/
publish.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
name: Publish to Maven
on:
workflow_dispatch:
inputs:
repo-gcloud:
type: boolean
description: "Repository: GCloud"
default: true
repo-sonatype:
type: boolean
description: "Repository: Sonatype"
default: false
target-common:
type: boolean
description: "Target: Common"
default: true
target-jvm:
type: boolean
description: "Target: JVM"
default: true
target-js:
type: boolean
description: "Target: JS"
default: true
target-linux:
type: boolean
description: "Target: Linux"
default: true
target-win:
type: boolean
description: "Target: Windows"
default: true
target-mac:
type: boolean
description: "Target: Mac OS"
default: true
target-ios:
type: boolean
description: "Target: iOS"
default: true
target-android:
type: boolean
description: "Target: Android"
default: true
jobs:
build:
runs-on: ${{ matrix.os }}
env:
# See: https://docs.gradle.org/current/userguide/signing_plugin.html#sec:in-memory-keys
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.VARABYTE_SIGNING_KEY }}
strategy:
matrix:
# Note: We use Linux to build the windows target because we can and it's easier than using a windows-latest
# machine (which would require configuring the "Add secret Gradle properties" step below differently using
# Windows paths. It's also faster to grab a Linux machine runner vs. a Windows machine runner, at least in my
# experience.
os: [ubuntu-latest, macos-latest]
steps:
- id: shouldrun
name: Should Run (early exit check)
if: |
(inputs.repo-gcloud || inputs.repo-sonatype) && (
(matrix.os == 'ubuntu-latest' && inputs.target-linux) ||
(matrix.os == 'ubuntu-latest' && inputs.target-common) ||
(matrix.os == 'ubuntu-latest' && inputs.target-jvm) ||
(matrix.os == 'ubuntu-latest' && inputs.target-js) ||
(matrix.os == 'ubuntu-latest' && inputs.target-win) ||
(matrix.os == 'ubuntu-latest' && inputs.target-android) ||
(matrix.os == 'macos-latest' && inputs.target-mac) ||
(matrix.os == 'macos-latest' && inputs.target-ios)
)
run: echo "This workflow will run because the inputs are relevant to this machine."
- uses: actions/checkout@v4
if: steps.shouldrun.conclusion == 'success'
# Java 17 needed for resolving the Android Gradle Plugin
- uses: actions/setup-java@v4
if: steps.shouldrun.conclusion == 'success'
with:
distribution: temurin
java-version: 17
- name: Setup Gradle
if: steps.shouldrun.conclusion == 'success'
uses: gradle/actions/setup-gradle@v3
- name: Add secret Gradle properties
if: steps.shouldrun.conclusion == 'success'
env:
GRADLE_PROPERTIES: ${{ secrets.VARABYTE_GRADLE_PROPERTIES }}
shell: bash
run: |
mkdir -p ~/.gradle/
echo "GRADLE_USER_HOME=${HOME}/.gradle" >> $GITHUB_ENV
echo "${GRADLE_PROPERTIES}" > ~/.gradle/gradle.properties
- name: Cache Kotlin Native compiler
if: steps.shouldrun.conclusion == 'success'
uses: actions/cache@v4
with:
path: ~/.konan
key: kotlin-native-compiler-${{ runner.OS }}
#################### GCLOUD ####################
- name: Publish Common (GCloud)
# Doesn't have to be Linux but it tends to be the fastest image
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-gcloud) &&
(matrix.os == 'ubuntu-latest' && inputs.target-common)
run: |
./gradlew publishKotlinMultiplatformPublicationToGCloudMavenRepository --no-daemon
- name: Publish JVM (GCloud)
# Doesn't have to be Linux but it tends to be the fastest image
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-gcloud) &&
(matrix.os == 'ubuntu-latest' && inputs.target-jvm)
run: |
./gradlew publishJvmPublicationToGCloudMavenRepository --no-daemon
- name: Publish JS (GCloud)
# Doesn't have to be Linux but it tends to be the fastest image
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-gcloud) &&
(matrix.os == 'ubuntu-latest' && inputs.target-js)
run: |
./gradlew publishJsPublicationToGCloudMavenRepository --no-daemon
- name: Publish Linux (GCloud)
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-gcloud) &&
(matrix.os == 'ubuntu-latest' && inputs.target-linux)
run: ./gradlew publishLinuxX64PublicationToGCloudMavenRepository --no-daemon
- name: Publish Mac (GCloud)
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-gcloud) &&
(matrix.os == 'macos-latest' && inputs.target-mac)
run: |
./gradlew publishMacosX64PublicationToGCloudMavenRepository --no-daemon
./gradlew publishMacosArm64PublicationToGCloudMavenRepository --no-daemon
- name: Publish Win (GCloud)
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-gcloud) &&
(matrix.os == 'ubuntu-latest' && inputs.target-win)
run: ./gradlew publishMingwX64PublicationToGCloudMavenRepository --no-daemon
- name: Publish iOS (GCloud)
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-gcloud) &&
(matrix.os == 'macos-latest' && inputs.target-ios)
run: |
./gradlew publishIosX64PublicationToGCloudMavenRepository --no-daemon
./gradlew publishIosArm64PublicationToGCloudMavenRepository --no-daemon
./gradlew publishIosSimulatorArm64PublicationToGCloudMavenRepository --no-daemon
- name: Publish Android (GCloud)
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-gcloud) &&
(matrix.os == 'ubuntu-latest' && inputs.target-android)
run: ./gradlew publishAndroidReleasePublicationToGCloudMavenRepository --no-daemon
#################### SONATYPE ####################
- name: Publish Common (Sonatype)
# Doesn't have to be Linux but it tends to be the fastest image
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-sonatype) &&
(matrix.os == 'ubuntu-latest' && inputs.target-common)
run: |
./gradlew publishKotlinMultiplatformPublicationToSonatypeMavenRepository --no-daemon
- name: Publish JVM (Sonatype)
# Doesn't have to be Linux but it tends to be the fastest image
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-sonatype) &&
(matrix.os == 'ubuntu-latest' && inputs.target-jvm)
run: |
./gradlew publishJvmPublicationToSonatypeMavenRepository --no-daemon
- name: Publish JS (Sonatype)
# Doesn't have to be Linux but it tends to be the fastest image
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-sonatype) &&
(matrix.os == 'ubuntu-latest' && inputs.target-js)
run: |
./gradlew publishJsPublicationToSonatypeMavenRepository --no-daemon
- name: Publish Linux (Sonatype)
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-sonatype) &&
(matrix.os == 'ubuntu-latest' && inputs.target-linux)
run: ./gradlew publishLinuxX64PublicationToSonatypeMavenRepository --no-daemon
- name: Publish Mac (Sonatype)
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-sonatype) &&
(matrix.os == 'macos-latest' && inputs.target-mac)
run: |
./gradlew publishMacosX64PublicationToSonatypeMavenRepository --no-daemon
./gradlew publishMacosArm64PublicationToSonatypeMavenRepository --no-daemon
- name: Publish Win (Sonatype)
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-sonatype) &&
(matrix.os == 'ubuntu-latest' && inputs.target-win)
run: ./gradlew publishMingwX64PublicationToSonatypeMavenRepository --no-daemon
- name: Publish iOS (Sonatype)
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-sonatype) &&
(matrix.os == 'macos-latest' && inputs.target-ios)
run: |
./gradlew publishIosX64PublicationToSonatypeMavenRepository --no-daemon
./gradlew publishIosArm64PublicationToSonatypeMavenRepository --no-daemon
./gradlew publishIosSimulatorArm64PublicationToSonatypeMavenRepository --no-daemon
- name: Publish Android (Sonatype)
if: |
(steps.shouldrun.conclusion == 'success') &&
(inputs.repo-sonatype) &&
(matrix.os == 'ubuntu-latest' && inputs.target-android)
run: ./gradlew publishAndroidReleasePublicationToSonatypeMavenRepository --no-daemon