-
Notifications
You must be signed in to change notification settings - Fork 3
274 lines (232 loc) · 7.99 KB
/
release.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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
name: Release
on:
workflow_dispatch:
inputs:
bump_version_scheme:
type: choice
description: "Release"
required: true
default: "patch"
options:
- "patch"
- "minor"
- "major"
jobs:
build-ios:
runs-on: macos-14
strategy:
matrix:
arch: ["arm64-ios", "arm64-ios-simulator", "x64-ios-simulator"]
steps:
- name: Checkout Valhalla
uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "14.3.1"
- name: Setup VCPKG
run: |
git clone https://github.com/microsoft/vcpkg && git -C vcpkg checkout 2024.09.23
./vcpkg/bootstrap-vcpkg.sh
export VCPKG_ROOT=`pwd`/vcpkg
- name: Build for iOS & iOS Simulator
run: ./build.sh --ios ${{ matrix.arch }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.arch }}
path: |
build/apple/${{ matrix.arch }}/install
create-xcframework-release:
needs: build-ios
runs-on: macos-14
steps:
- name: Checkout Valhalla
uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "14.3.1"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: build/apple
- name: Move artifacts to correct locations
run: |
for arch in arm64-ios arm64-ios-simulator x64-ios-simulator; do
mkdir -p build/apple/$arch/install
mv build/apple/$arch/* build/apple/$arch/install/ || true
done
- name: Create XCFramework
run: |
./scripts/create_xcframework.sh
- name: Zip the xcframework
run: |
cd build/apple
zip -r valhalla-wrapper.xcframework.zip valhalla-wrapper.xcframework
mv valhalla-wrapper.xcframework.zip ../../
cd ../../
- name: Upload xcframework zip output
uses: actions/upload-artifact@v4
with:
name: valhalla-wrapper.xcframework.zip
path: |
valhalla-wrapper.xcframework.zip
build-android:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
strategy:
matrix:
arch: ["arm64-v8a", "armeabi-v7a", "x86_64", "x86"]
steps:
- name: Checkout Valhalla
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Setup VCPKG
run: |
git clone https://github.com/microsoft/vcpkg && git -C vcpkg checkout 2024.09.23
./vcpkg/bootstrap-vcpkg.sh
export VCPKG_ROOT=`pwd`/vcpkg
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: android
- name: Build with Gradle
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew buildValhallaFor-${{ matrix.arch }}
working-directory: android
- name: Upload JNI Lib
uses: actions/upload-artifact@v4
with:
name: libvalhalla-${{ matrix.arch }}
path: android/valhalla/src/main/jniLibs/${{ matrix.arch }}/libvalhalla-wrapper.so
retention-days: 1
combine-android:
needs: build-android
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: jniLibs
- name: Organize and zip artifacts
run: |
mkdir -p android/valhalla/src/main/jniLibs
for arch in arm64-v8a armeabi-v7a x86 x86_64; do
mkdir -p android/valhalla/src/main/jniLibs/$arch
if [ -f jniLibs/libvalhalla-$arch/libvalhalla-wrapper.so ]; then
cp jniLibs/libvalhalla-$arch/libvalhalla-wrapper.so android/valhalla/src/main/jniLibs/$arch/
fi
done
zip -r valhalla-jniLibs.zip android
- name: Upload zipped JNI Libs
uses: actions/upload-artifact@v4
with:
name: valhalla-jniLibs
path: valhalla-jniLibs.zip
retention-days: 1
draft-release:
runs-on: macos-14
needs: create-xcframework-release
outputs:
version: ${{ steps.version.outputs.version }}
release_id: ${{ steps.release.outputs.id }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- name: Checkout Valhalla
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- name: Configure Git
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Download the xcframework artifact from the build-and-test
uses: actions/download-artifact@v4
with:
name: valhalla-wrapper.xcframework.zip
- name: Get version tag
id: version
run: ./scripts/version_bump.sh ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && 'patch' || inputs.bump_version_scheme }}
- uses: softprops/action-gh-release@v1
id: release
with:
draft: true
generate_release_notes: true
tag_name: ${{ steps.version.outputs.version }}
files: "valhalla-wrapper.xcframework.zip"
- name: Write the xcframework to Package.swift
run: ./scripts/write_xcframework_spm.sh ${{ steps.version.outputs.version }}
# https://github.com/marketplace/actions/git-auto-commit#push-to-protected-branches
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Publish Package.swift and bump version to ${{ steps.version.outputs.version }} [skip ci]"
tagging_message: "${{ steps.version.outputs.version }}"
push_options: --force
- name: Output version
run: |
echo "version=${{ steps.version.outputs.version }}" >> "$GITHUB_OUTPUT"
echo "release_id=${{ steps.release.outputs.id }}" >> "$GITHUB_OUTPUT"
publish-release:
runs-on: ubuntu-latest
needs: draft-release
steps:
- uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.draft-release.outputs.release_id }}
publish-android:
needs: [combine-android, publish-release]
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
# TODO: Remove this once successful.
- name: Verify version
run: cat version.txt
- name: Download JNI Libs
uses: actions/download-artifact@v4
with:
name: valhalla-jniLibs
path: .
- name: Unzip JNI Libs
run: unzip valhalla-jniLibs.zip
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: android
- name: Publish to Maven Central
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
working-directory: android