-
Notifications
You must be signed in to change notification settings - Fork 2
248 lines (245 loc) · 8.91 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
247
248
name: Publish
on:
push:
tags: ["*"]
concurrency:
cancel-in-progress: true
group: ${{github.workflow}}-${{github.ref_name}}
jobs:
build-libs:
runs-on: ${{matrix.os}}
name: Build ${{matrix.platform}}-${{matrix.arch}} library
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
platform: linux
arch: x64
lib: libktreesitter.so
cmake_args: >-
-DCMAKE_BUILD_TYPE=RelWithDebugInfo
- os: ubuntu-latest
platform: linux
arch: aarch64
lib: libktreesitter.so
cmake_args: >-
-DCMAKE_BUILD_TYPE=RelWithDebugInfo
-DCMAKE_SYSTEM_PROCESSOR=aarch64
-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc
-DCMAKE_FIND_ROOT_PATH=/usr/aarch64-linux-gnu
- os: windows-latest
platform: windows
arch: x64
lib: ktreesitter.dll
- os: macos-latest
platform: macos
arch: x64
lib: libktreesitter.dylib
cmake_args: >-
-DCMAKE_BUILD_TYPE=RelWithDebugInfo
-DCMAKE_OSX_ARCHITECTURES=x86_64
- os: macos-latest
platform: macos
arch: aarch64
lib: libktreesitter.dylib
cmake_args: >-
-DCMAKE_OSX_ARCHITECTURES=arm64
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
architecture: ${{matrix.arch}}
- name: Set up cross compilation
run: sudo apt-get install -qy {binutils,gcc}-aarch64-linux-gnu
if: runner.os == 'Linux' && matrix.arch == 'aarch64'
- name: Configure CMake
working-directory: ktreesitter
run: >-
cmake -B .cmake/build ${{matrix.cmake_args}}
-DCMAKE_INSTALL_LIBDIR=lib/${{matrix.platform}}/${{matrix.arch}}
-DCMAKE_INSTALL_BINDIR=lib/${{matrix.platform}}/${{matrix.arch}}
- name: Build JNI library
working-directory: ktreesitter
run: |-
cmake --build .cmake/build --config Release
cmake --install .cmake/build --config Release --prefix .cmake/build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ktreesitter-lib-${{matrix.platform}}-${{matrix.arch}}
path: ktreesitter/.cmake/build/lib/**
retention-days: 2
build-jars:
runs-on: ${{matrix.os}}
name: Build ${{matrix.platform}} packages
needs: [build-libs]
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
platform: common
targets: >-
generateGrammarFiles
:ktreesitter:publishKotlinMultiplatformPublicationToLocalRepository
- os: ubuntu-latest
platform: JVM
targets: >-
:ktreesitter:publishJvmPublicationToLocalRepository
- os: ubuntu-latest
platform: Android
targets: >-
:ktreesitter:publishAndroidReleasePublicationToLocalRepository
- os: ubuntu-latest
platform: Linux
targets: >-
generateGrammarFiles
:ktreesitter:publishLinuxX64PublicationToLocalRepository
:ktreesitter:publishLinuxArm64PublicationToLocalRepository
- os: windows-latest
platform: Windows
targets: >-
generateGrammarFiles
:ktreesitter:publishMingwX64PublicationToLocalRepository
- os: macos-latest
platform: macOS/iOS
targets: >-
generateGrammarFiles
:ktreesitter:publishMacosX64PublicationToLocalRepository
:ktreesitter:publishMacosArm64PublicationToLocalRepository
:ktreesitter:publishIosArm64PublicationToLocalRepository
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: gradle
cache-dependency-path: |
gradle/libs.versions.toml
gradle/wrapper/gradle-wrapper.properties
- name: Set up cross compilation
run: sudo apt-get install -qy {binutils,gcc}-aarch64-linux-gnu
if: matrix.platform == 'Linux' || matrix.platform == 'common'
- name: Restore Kotlin/Native prebuilt
uses: actions/cache/restore@v4
with:
path: ${{runner.tool_cache}}/konan/kotlin-native-prebuilt-*
key: konan-${{runner.os}}-prebuilt-1.9
- name: Restore Kotlin/Native dependencies
uses: actions/cache/restore@v4
if: matrix.platform != 'JVM' && matrix.platform != 'Android'
with:
path: ${{runner.tool_cache}}/konan/dependencies
key: konan-${{runner.os}}-dependencies
- name: Download library artifacts
uses: actions/download-artifact@v4
if: matrix.platform == 'JVM'
with:
path: ktreesitter/src/jvmMain/resources/lib
pattern: ktreesitter-lib-*
merge-multiple: true
- name: Set up Ninja
if: matrix.platform == 'Android'
run: |-
sudo apt-get update
sudo apt-get install -y ninja-build
- name: Build packages
run: ./gradlew --no-daemon ${{matrix.targets}}
env:
SIGNING_KEY: ${{secrets.SIGNING_KEY}}
SIGNING_PASSWORD: ${{secrets.SIGNING_PASSWORD}}
KONAN_DATA_DIR: ${{runner.tool_cache}}/konan
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ktreesitter-jars-${{matrix.platform == 'macOS/iOS' && 'macOS-iOS' || matrix.platform}}
path: |
ktreesitter/build/repo/**
!ktreesitter/build/repo/**/maven-metadata.*
retention-days: 2
publish-library:
runs-on: ubuntu-latest
name: Publish packages on Maven Central
needs: [build-jars]
permissions:
contents: write
environment:
name: maven-central
url: https://central.sonatype.com/artifact/io.github.tree-sitter/ktreesitter
env:
SONATYPE_API: https://central.sonatype.com/api/v1/publisher
SONATYPE_AUTH: "Authorization: Bearer ${{secrets.SONATYPE_TOKEN}}"
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ktreesitter
pattern: ktreesitter-jars-*
merge-multiple: true
- name: Upload bundle
run: |-
url="$SONATYPE_API/upload?name=ktreesitter-${GITHUB_REF_NAME}.zip&publishingType=USER_MANAGED"
(cd ktreesitter && zip -qr ../ktreesitter.zip *)
printf >> "$GITHUB_ENV" 'DEPLOYMENT_ID=%s\n' $(curl -Ssf [email protected] -H "$SONATYPE_AUTH" "$url")
- name: Verify status
timeout-minutes: 5
run: |-
url="$SONATYPE_API/status?id=$DEPLOYMENT_ID"
while [[ ${state:=PENDING} == PENDING ]] || [[ $state == VALIDATING ]]; do
state=$(curl -Ssf -XPOST -H "$SONATYPE_AUTH" "$url" | jq -r .deploymentState)
done
if [[ $state == FAILED ]]; then
printf '::error title=Publication failed::Check https://central.sonatype.com/publishing/deployments\n'
exit 1
fi
- name: Publish deployment
run: curl -fi -XPOST -H "$SONATYPE_AUTH" "$SONATYPE_API/deployment/$DEPLOYMENT_ID"
- name: Create release
run: gh release create $GITHUB_REF_NAME --generate-notes
env:
GH_TOKEN: ${{github.token}}
GH_REPO: ${{github.repository}}
publish-plugin:
runs-on: ubuntu-latest
name: Publish plugin on Gradle Portal
needs: [build-jars]
environment:
name: gradle-plugin-portal
url: https://plugins.gradle.org/plugin/io.github.tree-sitter.ktreesitter-plugin
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: gradle
cache-dependency-path: |
gradle/libs.versions.toml
gradle/wrapper/gradle-wrapper.properties
- name: Restore Kotlin/Native prebuilt
uses: actions/cache/restore@v4
with:
path: ${{runner.tool_cache}}/konan/kotlin-native-prebuilt-*
key: konan-${{runner.os}}-prebuilt-1.9
- name: Publish Gradle plugin
run: ./gradlew --no-daemon :ktreesitter-plugin:publishPlugins
env:
KONAN_DATA_DIR: ${{runner.tool_cache}}/konan
GRADLE_PUBLISH_KEY: ${{secrets.GRADLE_PUBLISH_KEY}}
GRADLE_PUBLISH_SECRET: ${{secrets.GRADLE_PUBLISH_SECRET}}