-
Notifications
You must be signed in to change notification settings - Fork 41
163 lines (145 loc) · 5.25 KB
/
Copy pathbuild-swift.yml
File metadata and controls
163 lines (145 loc) · 5.25 KB
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
name: Build Swift Package
on:
pull_request:
push:
branches:
- "rc"
- "hotfix-rc"
- "main"
workflow_dispatch:
jobs:
version:
name: Get Version
runs-on: ubuntu-24.04
permissions:
contents: read
outputs:
package_version: ${{ steps.retrieve-version.outputs.package_version }}
steps:
- name: Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Get Package Version
id: retrieve-version
run: |
VERSION=$(grep -o '^version = ".*"' Cargo.toml | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")
echo "package_version=$VERSION" >> $GITHUB_OUTPUT
build:
name: Build
runs-on: macos-14
needs: version
permissions:
contents: read
env:
_VERSION: ${{ needs.version.outputs.package_version }}
outputs:
short-sha: ${{ steps.build.outputs.short-sha }}
steps:
- name: Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
toolchain: stable
- name: Cache cargo registry
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
with:
key: sdk-swift-cargo
- name: Rustup target
run: |
rustup target install aarch64-apple-ios-sim
rustup target install aarch64-apple-ios
rustup target install x86_64-apple-ios
- name: Build
shell: bash
working-directory: crates/bitwarden-uniffi/swift
id: build
run: |
./build.sh
# SHA Short
echo "short-sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Test build demo app
working-directory: crates/bitwarden-uniffi/swift/iOS
run: |
xcodebuild clean build \
-project App.xcodeproj \
-scheme App \
-destination generic/platform=iOS \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO
- name: Zip BitwardenFFI.xcframework
run: |
mkdir artifacts
cp -rf crates/bitwarden-uniffi/swift/BitwardenFFI.xcframework artifacts
- name: Upload BitwardenFFI.xcframework artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: BitwardenFFI-${{ env._VERSION }}-${{ steps.build.outputs.short-sha }}.xcframework
path: artifacts
if-no-files-found: error
- name: Upload BitwardenSdk sources
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: BitwardenSdk-${{ env._VERSION }}-${{ steps.build.outputs.short-sha }}-sources
path: crates/bitwarden-uniffi/swift/Sources/BitwardenSdk
if-no-files-found: error
integration-tests:
name: Integration tests
runs-on: macos-14
needs: [version, build]
permissions:
contents: read
env:
_VERSION: ${{ needs.version.outputs.package_version }}
_SHORT_SHA: ${{ needs.build.outputs.short-sha }}
steps:
- name: Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Download BitwardenFFI.xcframework
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: BitwardenFFI-${{ env._VERSION }}-${{ env._SHORT_SHA }}.xcframework
path: crates/bitwarden-uniffi/swift
- name: Download generated BitwardenSdk sources
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: BitwardenSdk-${{ env._VERSION }}-${{ env._SHORT_SHA }}-sources
path: crates/bitwarden-uniffi/swift/Sources/BitwardenSdk
- name: Run integration tests
working-directory: crates/bitwarden-uniffi/swift/integration-tests
run: |
DEVICE_ID=$(xcrun simctl list devices available | awk -F '[()]' '/iPhone/{print $2; exit}')
xcodebuild test \
-scheme IntegrationTests-Package \
-destination "id=$DEVICE_ID" \
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
trigger-swift-release:
name: Trigger Swift release
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
needs: build
permissions:
actions: write
steps:
- name: Trigger Swift release
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'bitwarden',
repo: 'sdk-internal',
workflow_id: 'release-swift.yml',
ref: 'main',
inputs: {
'build-run-id': '${{ github.run_id }}',
'build-run-number': '${{ github.run_number }}',
'sdk-swift-branch-name': 'unstable',
'update-ios-repo': 'true',
}
})