-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (116 loc) · 4.63 KB
/
release-swift.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
name: Build and Release Yttrium Swift
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g. 0.0.1)'
required: true
env:
CARGO_TERM_COLOR: always
VERSION: ${{ github.event.inputs.version || '0.0.24' }}
TARGET_BRANCH: ${{ github.ref_name }}
permissions:
contents: write # Grant write access to repository contents for this workflow
jobs:
release-swift-package:
runs-on: macos-14
strategy:
matrix:
config:
- debug
steps:
# 1. Checkout the Repository with full history
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history so that we can create and push tags
# 2. Setup ccache (Optional: Improve build speeds)
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
# 3. Setup pnpm (JavaScript Package Manager)
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
# 4. Setup Rust Environment and Dependencies
- name: Setup Rust Environment and Dependencies
env:
VERSION: ${{ env.VERSION }}
run: |
rustup update stable && rustup default stable
git submodule update --init --recursive
make setup-thirdparty
# 5. Select Specific Xcode Version
- name: Select Xcode 15.4
run: |
sudo xcode-select -s /Applications/Xcode_15.4.app
# 6. Build and Package XCFramework
- name: Build and Package XCFramework
run: |
make build-xcframework
make generate-package-swift
# 7. Update Podspec with Version and Download URL
- name: Update Podspec with Version and Download URL
run: |
# Replace the version line in Podspec
sed -i '' "s/^ s\.version *= *.*/ s.version = '${VERSION}'/g" YttriumWrapper.podspec
# Construct the download URL
DOWNLOAD_URL="https://github.com/reown-com/yttrium/releases/download/${VERSION}/libuniffi_yttrium.xcframework.zip"
# Replace the download URL in prepare_command
sed -i '' "s|curl -L -o libuniffi_yttrium.xcframework.zip '.*'|curl -L -o libuniffi_yttrium.xcframework.zip '${DOWNLOAD_URL}'|g" YttriumWrapper.podspec
# 8. Commit and Push Package.swift and Podspec
- name: Commit and Push Package.swift and Podspec
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use default token
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Package.swift platforms/swift/Sources/Yttrium/* YttriumWrapper.podspec
if git diff --cached --quiet; then
echo "No changes to commit."
else
git commit -m "chore: update Package.swift and podspec for version $VERSION"
git push origin HEAD:$TARGET_BRANCH
fi
# 9. Create Git Tag
- name: Create Git Tag
env:
VERSION: ${{ env.VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Ensure we're on the latest commit
git fetch origin $TARGET_BRANCH
# Get the latest commit hash
COMMIT_HASH=$(git rev-parse HEAD)
echo "Tagging commit ${COMMIT_HASH} with version ${VERSION}"
# Create an annotated tag on the latest commit
git tag -a "${VERSION}" -m "Release version ${VERSION}" "${COMMIT_HASH}"
# Push the tag to the repository
git push origin "${VERSION}"
# 10. Create a GitHub Release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: Yttrium ${{ env.VERSION }}
draft: false
prerelease: true
# 11. Upload XCFramework to the Release
- name: Upload XCFramework to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Output/libuniffi_yttrium.xcframework.zip
asset_name: libuniffi_yttrium.xcframework.zip
asset_content_type: application/zip
# 12. Publish to CocoaPods Trunk
- name: Publish to CocoaPods Trunk
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
pod trunk push YttriumWrapper.podspec --allow-warnings