-
Notifications
You must be signed in to change notification settings - Fork 19
178 lines (156 loc) · 6.42 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
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-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
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-win) ||
(matrix.os == 'macos-latest' && inputs.target-mac)
)
run: echo "This workflow will run because the inputs are relevant to this machine."
- uses: actions/checkout@v4
if: steps.shouldrun.conclusion == 'success'
- uses: actions/setup-java@v4
if: steps.shouldrun.conclusion == 'success'
with:
distribution: temurin
java-version: 11
- 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 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
#################### 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 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