1
+ name : Build and Release Yttrium Swift Utils
2
+
3
+ on :
4
+ workflow_dispatch :
5
+ inputs :
6
+ version :
7
+ description : ' Version to release (e.g. 0.0.1)'
8
+ required : true
9
+
10
+ env :
11
+ CARGO_TERM_COLOR : always
12
+ VERSION : ${{ github.event.inputs.version || '0.0.1' }}
13
+ TARGET_BRANCH : ${{ github.ref_name }}
14
+
15
+ permissions :
16
+ contents : write
17
+
18
+ jobs :
19
+ release-swift-utils-package :
20
+ runs-on : macos-latest-xlarge
21
+ strategy :
22
+ matrix :
23
+ config :
24
+ - debug
25
+ steps :
26
+ # 1. Checkout
27
+ - name : Checkout
28
+ uses : actions/checkout@v4
29
+ with :
30
+ fetch-depth : 0
31
+
32
+ # 2. Install sccache
33
+ - name : Run sccache-cache
34
+ uses :
mozilla-actions/[email protected]
35
+
36
+ # 3. Install pnpm
37
+ - uses : pnpm/action-setup@v4
38
+ with :
39
+ version : 9
40
+ run_install : false
41
+
42
+ # 4. Install Rust
43
+ - name : Install Rust
44
+ uses : dtolnay/rust-toolchain@stable
45
+
46
+ # 5. Select Xcode
47
+ - name : Select Xcode
48
+ run : sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
49
+
50
+ # 6. Build and Package Utils XCFramework
51
+ - name : Build and Package Utils XCFramework
52
+ run : |
53
+ make build-utils-xcframework
54
+ make generate-package-swift-utils
55
+
56
+ # 7. Calculate Utils XCFramework Checksum (SPM)
57
+ - name : Calculate Utils XCFramework Checksum
58
+ id : checksum
59
+ run : |
60
+ CHECKSUM=$(swift package compute-checksum Output/libyttrium-utils.xcframework.zip)
61
+ echo "checksum=$CHECKSUM" >> $GITHUB_OUTPUT
62
+ echo "Utils XCFramework checksum: $CHECKSUM"
63
+
64
+ # 8. Update Package.swift for Utils Only
65
+ - name : Update Package.swift for Utils Only
66
+ run : |
67
+ chmod +x scripts/update-package-swift-utils.sh
68
+ ./scripts/update-package-swift-utils.sh "$VERSION" "${{ steps.checksum.outputs.checksum }}"
69
+
70
+ # 9. Update Utils Podspec version
71
+ - name : Update Utils Podspec version
72
+ run : |
73
+ sed -i '' "s/spec.version = \".*\"/spec.version = \"$VERSION\"/" YttriumUtilsWrapper.podspec
74
+
75
+ # Update the binary pod URL to the new pod zip
76
+ DOWNLOAD_URL="https://github.com/reown-com/yttrium/releases/download/$VERSION/libyttrium-utils-pod.zip"
77
+ sed -i '' "s|https://github.com/reown-com/yttrium/releases/download/[^/]*/libyttrium-utils-pod.zip|${DOWNLOAD_URL}|g" YttriumUtilsWrapper.podspec
78
+
79
+ # 10. Commit and Push Package.swift, Utils Sources, and Podspec
80
+ - name : Commit and Push Package.swift, Utils Sources, and Podspec
81
+ env :
82
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
83
+ run : |
84
+ git config user.name "github-actions[bot]"
85
+ git config user.email "github-actions[bot]@users.noreply.github.com"
86
+ git add Package.swift platforms/swift/Sources/YttriumUtils/* YttriumUtilsWrapper.podspec
87
+ if git diff --cached --quiet; then
88
+ echo "No changes to commit."
89
+ else
90
+ git commit -m "chore: update Package.swift, utils sources, and podspec for version $VERSION"
91
+ git push origin HEAD:$TARGET_BRANCH
92
+ fi
93
+
94
+ # 11. Create Git Tag for Utils
95
+ - name : Create Git Tag for Utils
96
+ env :
97
+ VERSION : ${{ env.VERSION }}
98
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
99
+ run : |
100
+ git fetch origin $TARGET_BRANCH
101
+ COMMIT_HASH=$(git rev-parse HEAD)
102
+ echo "Tagging commit ${COMMIT_HASH} with version ${VERSION}"
103
+ git tag -a "${VERSION}" -m "Release YttriumUtils version ${VERSION}" "${COMMIT_HASH}"
104
+ git push origin "${VERSION}"
105
+
106
+ # 12. Create a GitHub Release for Utils
107
+ - name : Create Release for Utils
108
+ id : create_release_utils
109
+ uses : actions/create-release@v1
110
+ env :
111
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
112
+ with :
113
+ tag_name : ${{ env.VERSION }}
114
+ release_name : YttriumUtils ${{ env.VERSION }}
115
+ draft : false
116
+ prerelease : true
117
+
118
+ # 13. Upload Utils SPM XCFramework zip to the Release
119
+ - name : Upload Utils SPM zip to Release
120
+ uses : actions/upload-release-asset@v1
121
+ env :
122
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
123
+ with :
124
+ upload_url : ${{ steps.create_release_utils.outputs.upload_url }}
125
+ asset_path : ./Output/libyttrium-utils.xcframework.zip
126
+ asset_name : libyttrium-utils.xcframework.zip
127
+ asset_content_type : application/zip
128
+
129
+ # 14. Upload Utils CocoaPods pod zip to the Release
130
+ - name : Upload Utils pod zip to Release
131
+ uses : actions/upload-release-asset@v1
132
+ env :
133
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
134
+ with :
135
+ upload_url : ${{ steps.create_release_utils.outputs.upload_url }}
136
+ asset_path : ./Output/libyttrium-utils-pod.zip
137
+ asset_name : libyttrium-utils-pod.zip
138
+ asset_content_type : application/zip
139
+
140
+ # 15. Publish Utils CocoaPods
141
+ - name : Publish Utils CocoaPods
142
+ env :
143
+ COCOAPODS_TRUNK_TOKEN : ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
144
+ run : |
145
+ pod trunk push YttriumUtilsWrapper.podspec --allow-warnings
0 commit comments