|
1 | | -on: [workflow_dispatch] |
| 1 | +name: Build and Release ProseSDK |
2 | 2 |
|
3 | | -name: Build |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + core_client_ref: |
| 7 | + description: 'prose-core-client branch/tag to build from' |
| 8 | + required: false |
| 9 | + default: 'master' |
| 10 | + type: string |
| 11 | + |
| 12 | +env: |
| 13 | + CORE_CLIENT_REPO: prose-im/prose-core-client |
| 14 | + WRAPPER_REPO: prose-im/prose-wrapper-swift |
4 | 15 |
|
5 | 16 | jobs: |
6 | | - release-number: |
7 | | - name: Check if release already exists |
8 | | - runs-on: ubuntu-latest |
9 | | - outputs: |
10 | | - ok: ${{ steps.release-number.outputs.ok }} |
| 17 | + build-and-release: |
| 18 | + runs-on: macos-latest |
| 19 | + |
11 | 20 | steps: |
12 | | - - name: Checkout code |
| 21 | + - name: Checkout wrapper repository |
13 | 22 | uses: actions/checkout@v4 |
14 | 23 | with: |
15 | | - submodules: false |
16 | | - |
17 | | - - name: Get prose-core-client submodule SHA and set ok flag if release does not exist. |
18 | | - id: release-number |
19 | | - run: scripts/check-release.sh |
20 | | - env: |
21 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 25 | + path: wrapper |
22 | 26 |
|
23 | | - build: |
24 | | - name: Build Swift Package |
25 | | - needs: |
26 | | - - release-number |
27 | | - if: ${{ needs.release-number.outputs.ok == 'true' }} |
28 | | - runs-on: macos-12 |
29 | | - |
30 | | - steps: |
31 | | - - name: Checkout code |
| 27 | + - name: Checkout core client repository |
32 | 28 | uses: actions/checkout@v4 |
33 | 29 | with: |
34 | | - submodules: true |
| 30 | + repository: ${{ env.CORE_CLIENT_REPO }} |
| 31 | + ref: ${{ github.event.inputs.core_client_ref || 'master' }} |
| 32 | + path: core-client |
35 | 33 |
|
36 | | - - name: Fetch dependencies |
37 | | - run: scripts/fetch-dependencies.sh |
| 34 | + - name: Install system dependencies |
| 35 | + run: | |
| 36 | + # Required by libsignal |
| 37 | + brew install protobuf |
38 | 38 |
|
39 | | - - name: Install Automake |
40 | | - run: brew install automake |
| 39 | + - name: Setup Rust |
| 40 | + run: | |
| 41 | + # Navigate to core-client directory where rust-toolchain.toml exists |
| 42 | + cd core-client |
41 | 43 |
|
42 | | - - name: Install Rust toolchain |
43 | | - uses: actions-rs/toolchain@v1 |
44 | | - with: |
45 | | - toolchain: stable |
| 44 | + # This will automatically install the toolchain specified in rust-toolchain.toml |
| 45 | + # and then add targets to that toolchain |
| 46 | + rustup target add x86_64-apple-darwin aarch64-apple-darwin x86_64-apple-ios aarch64-apple-ios-sim aarch64-apple-ios |
46 | 47 |
|
47 | | - - name: Install Rust targets |
48 | | - run: rustup target add x86_64-apple-darwin aarch64-apple-darwin x86_64-apple-ios aarch64-apple-ios-sim aarch64-apple-ios |
| 48 | + # Install bindgen-cli which is required by aws-lc-sys |
| 49 | + cargo install --force --locked bindgen-cli |
49 | 50 |
|
50 | | - - name: Get libstrophe submodule SHA |
51 | | - id: lstrophesha |
52 | | - run: echo "lstrophesha=$(git rev-parse @:./dependencies/libstrophe)" >> $GITHUB_OUTPUT |
| 51 | + echo "Active toolchain:" |
| 52 | + rustup show active-toolchain |
| 53 | + echo "Installed Apple targets:" |
| 54 | + rustup target list --installed | grep apple |
53 | 55 |
|
54 | | - - name: Cache libstrophe |
55 | | - id: cache-libstrophe |
56 | | - uses: actions/cache@v4 |
57 | | - with: |
58 | | - path: Build/libstrophe |
59 | | - key: libstrophe-${{ steps.lstrophesha.outputs.lstrophesha }} |
| 56 | + - name: Extract version from Cargo.toml |
| 57 | + id: version |
| 58 | + run: | |
| 59 | + VERSION=$(grep -m1 '^version = ' core-client/bindings/prose-sdk-ffi/Cargo.toml | sed 's/version = "\(.*\)"/\1/') |
| 60 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 61 | + echo "Extracted version: $VERSION" |
| 62 | +
|
| 63 | + - name: Check if release already exists |
| 64 | + id: check_release |
| 65 | + run: | |
| 66 | + cd wrapper |
| 67 | + if gh release view "v${{ steps.version.outputs.version }}" > /dev/null 2>&1; then |
| 68 | + echo "exists=true" >> $GITHUB_OUTPUT |
| 69 | + echo "Release v${{ steps.version.outputs.version }} already exists" |
| 70 | + else |
| 71 | + echo "exists=false" >> $GITHUB_OUTPUT |
| 72 | + echo "Release v${{ steps.version.outputs.version }} does not exist" |
| 73 | + fi |
| 74 | + env: |
| 75 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + |
| 77 | + - name: Exit if release exists |
| 78 | + if: steps.check_release.outputs.exists == 'true' |
| 79 | + run: | |
| 80 | + echo "Release v${{ steps.version.outputs.version }} already exists. Exiting." |
| 81 | + exit 0 |
| 82 | +
|
| 83 | + - name: Build XCFramework |
| 84 | + run: | |
| 85 | + cd core-client |
| 86 | + cargo xtask swift build |
| 87 | +
|
| 88 | + - name: Copy built framework to wrapper repo |
| 89 | + run: | |
| 90 | + cp -r core-client/bindings/prose-sdk-ffi/ProseSDK/* wrapper/ |
60 | 91 |
|
61 | | - - name: Build libstrophe |
62 | | - run: scripts/build-libstrophe.sh |
| 92 | + - name: Create release archive |
| 93 | + run: | |
| 94 | + cd wrapper |
| 95 | + zip -r -y "ProseSDK-${{ steps.version.outputs.version }}.zip" ProseCore.xcframework |
63 | 96 |
|
64 | | - - name: Build core client |
65 | | - run: scripts/build-core-client.sh |
| 97 | + - name: Calculate checksum |
| 98 | + id: checksum |
| 99 | + run: | |
| 100 | + cd wrapper |
| 101 | + CHECKSUM=$(swift package compute-checksum "ProseSDK-${{ steps.version.outputs.version }}.zip") |
| 102 | + echo "checksum=$CHECKSUM" >> $GITHUB_OUTPUT |
| 103 | + echo "Checksum: $CHECKSUM" |
| 104 | +
|
| 105 | + - name: Update Package.swift |
| 106 | + run: | |
| 107 | + cd wrapper |
| 108 | + cat > Package.swift << 'EOF' |
| 109 | + // swift-tools-version:5.5 |
| 110 | + // The swift-tools-version declares the minimum version of Swift required to build this package. |
| 111 | + // Swift Package: ProseSDK |
| 112 | + import PackageDescription |
| 113 | +
|
| 114 | + let package = Package( |
| 115 | + name: "ProseSDK", |
| 116 | + platforms: [ |
| 117 | + .iOS(.v13), |
| 118 | + .macOS(.v10_15) |
| 119 | + ], |
| 120 | + products: [ |
| 121 | + .library( |
| 122 | + name: "ProseSDK", |
| 123 | + targets: ["ProseSDK"] |
| 124 | + ) |
| 125 | + ], |
| 126 | + dependencies: [ ], |
| 127 | + targets: [ |
| 128 | + .binaryTarget( |
| 129 | + name: "ProseCore", |
| 130 | + url: "https://github.com/${{ env.WRAPPER_REPO }}/releases/download/v${{ steps.version.outputs.version }}/ProseSDK-${{ steps.version.outputs.version }}.zip", |
| 131 | + checksum: "${{ steps.checksum.outputs.checksum }}" |
| 132 | + ), |
| 133 | + .target( |
| 134 | + name: "ProseSDK", |
| 135 | + dependencies: [ |
| 136 | + .target(name: "ProseCore") |
| 137 | + ] |
| 138 | + ), |
| 139 | + ] |
| 140 | + ) |
| 141 | + EOF |
| 142 | +
|
| 143 | + - name: Commit updated Package.swift and Sources |
| 144 | + run: | |
| 145 | + cd wrapper |
| 146 | + git add Package.swift Sources/ |
| 147 | + if git diff --staged --quiet; then |
| 148 | + echo "No changes to commit" |
| 149 | + else |
| 150 | + git commit -m "Update Package.swift and Sources for v${{ steps.version.outputs.version }}" |
| 151 | + git push |
| 152 | + fi |
| 153 | + env: |
| 154 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
66 | 155 |
|
67 | 156 | - name: Create release |
68 | | - run: scripts/create-github-release.sh |
| 157 | + id: create_release |
| 158 | + run: | |
| 159 | + cd wrapper |
| 160 | + gh release create "v${{ steps.version.outputs.version }}" \ |
| 161 | + "ProseSDK-${{ steps.version.outputs.version }}.zip" \ |
| 162 | + --title "ProseSDK v${{ steps.version.outputs.version }}" \ |
| 163 | + --notes "ProseSDK release v${{ steps.version.outputs.version }}" |
69 | 164 | env: |
70 | 165 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments