-
Notifications
You must be signed in to change notification settings - Fork 12
218 lines (183 loc) · 6.66 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
name: Release
on:
workflow_dispatch:
release:
types: [created]
env:
CARGO_TERM_COLOR: always
TOOLCHAIN: nightly
CARGO_MAKE_TOOLCHAIN: nightly
# https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
CARGO_CACHE_PATH: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
jobs:
build-wasm:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.TOOLCHAIN }}
targets: wasm32-unknown-unknown
- uses: taiki-e/install-action@v2
with:
tool: wasm-pack
- uses: taiki-e/install-action@v2
with:
tool: wasm-bindgen
- name: Build wasm for nodesjs
working-directory: ./crates/wasm
run: ./scripts/build.sh nodejs
- name: Build wasm for web
working-directory: ./crates/wasm
run: ./scripts/build.sh web
- uses: actions/upload-artifact@v4
with:
retention-days: 5
name: liveview-native-core-wasm-web
path: ./crates/wasm/liveview-native-core-wasm-web.tgz
- uses: actions/upload-artifact@v4
with:
retention-days: 5
name: liveview-native-core-wasm-nodejs
path: ./crates/wasm/liveview-native-core-wasm-nodejs.tgz
build-xcframework:
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.TOOLCHAIN }}
components: rust-src
targets: aarch64-apple-ios-sim
aarch64-apple-ios
x86_64-apple-ios
aarch64-apple-darwin
x86_64-apple-darwin
- uses: maxim-lobanov/[email protected]
with:
xcode-version: latest-stable
- name: Cache
uses: actions/cache@v4
with:
path: ${{ env.CARGO_CACHE_PATH }}
key: cargo-${{ github.workflow }}-${{ github.job }}-${{runner.os}}-${{runner.arch}}-${{ hashFiles('**/Cargo.toml') }}
- uses: taiki-e/install-action@v2
with:
tool: cargo-make
- name: Build XCFramework
run: |
cargo make --profile release uniffi-xcframework
ditto -c -k --sequesterRsrc --keepParent target/uniffi/swift/liveview_native_core.xcframework/ target/uniffi/swift/liveview_native_core.xcframework.zip
- uses: actions/upload-artifact@v4
with:
retention-days: 5
name: liveview_native_core.xcframework.zip
path: ./target/uniffi/swift/liveview_native_core.xcframework.zip
release-documentation:
runs-on: macos-15
continue-on-error: true
permissions:
contents: write
needs:
- build-xcframework
steps:
- uses: actions/checkout@v4
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.TOOLCHAIN }}
- uses: actions/download-artifact@v4
with:
name: liveview_native_core.xcframework.zip
path: ./target/uniffi/swift/
- name: Unzip xcframework
working-directory: ./target/uniffi/swift/
run: unzip liveview_native_core.xcframework.zip
- uses: taiki-e/install-action@v2
with:
tool: cargo-make
- name: Build XCFramework
run: |
mkdir -p ./docs/swift
cargo make --profile release uniffi-swift-doc-web
- name: Add index.html
run: |
echo '<meta http-equiv="refresh" content="0; url=docs/swift/documentation/liveviewnativecore/">
<a href="docs/swift/documentation/liveviewnativecore/">Redirect</a>' > index.html
- name: Checkout new gh-pages
if: github.event_name == 'release'
run: |
git checkout -b gh-pages
git add ./docs/ index.html
git commit -m 'Update gh-pages'
git push origin gh-pages --force
tag-release:
runs-on: macos-15
permissions:
contents: write
needs:
- build-xcframework
- build-wasm
steps:
- uses: actions/checkout@v4
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.TOOLCHAIN }}
- uses: taiki-e/install-action@v2
with:
tool: cargo-make
- name: Build XCFramework
run: |
cargo make --profile release uniffi-swift-package
- uses: actions/download-artifact@v4
with:
name: liveview_native_core.xcframework.zip
path: ./target/uniffi/swift/
- uses: actions/download-artifact@v4
with:
name: liveview-native-core-wasm-web
path: ./crates/wasm/
- uses: actions/download-artifact@v4
with:
name: liveview-native-core-wasm-nodejs
path: ./crates/wasm/
- run: ls ./crates/wasm/ ./crates/wasm/*
- name: Update version and checksum of xcframework in Package.swift
run: |
ls -lah ./target/uniffi/swift/
checksum=$(swift package compute-checksum ./target/uniffi/swift/liveview_native_core.xcframework.zip)
version=${{ github.event.release.tag_name }}
sed -i "" -E "s/(let releaseTag = \")[^\"]+(\")/\1$version\2/g" Package.swift
sed -i "" -E "s/(let releaseChecksum = \")[^\"]+(\")/\1$checksum\2/g" Package.swift
sed -i "" -E "s/let useLocalFramework = true/let useLocalFramework = false/g" Package.swift
git add Package.swift
git add -f ./crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore/*.swift
git diff --staged
- name: Commit, tag and push swift package
if: github.event_name == 'release'
run: |
git add Package.swift
git add ./crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore/*.swift
git commit -m "Update Package.swift and add generated LiveViewNativeCore.swift to tracking"
git tag -fa ${{ github.event.release.tag_name }} -m "Swift Package Release ${{ github.event.release.tag_name }}"
git push origin ${{ github.event.release.tag_name }} --force
- name: Release
uses: softprops/action-gh-release@v2
if: github.event_name == 'release'
with:
files: |
./target/uniffi/swift/liveview_native_core.xcframework.zip
./crates/wasm/liveview-native-core-wasm-web.tgz
./crates/wasm/liveview-native-core-wasm-nodejs.tgz
draft: false
prerelease: true
tag_name: ${{ github.event.release.tag_name }}