-
Notifications
You must be signed in to change notification settings - Fork 1
138 lines (114 loc) · 4.4 KB
/
update-framework.yml
File metadata and controls
138 lines (114 loc) · 4.4 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
name: Update Framework
on:
repository_dispatch:
types: [update-build]
jobs:
update_framework:
runs-on: macos-latest
steps:
- name: Checkout CEL iOS Repository
uses: actions/checkout@v4
with:
path: ios
- name: Checkout CEL Rust Repository
uses: actions/checkout@v4
with:
repository: superwall/superscript
token: ${{ secrets.GITHUB_TOKEN }}
path: rust
- name: Extract Version Number from Cargo.toml
id: extract_version
run: |
version=$(grep '^version =' rust/Cargo.toml | sed -E 's/version = "(.*)"/\1/')
echo "VERSION_NUMBER=$version" >> $GITHUB_ENV
- name: Check if Version Has Changed
id: version_check
run: |
current_version=$(git tag --sort=-v:refname | grep '^v' | head -n 1 | sed 's/^v//')
echo "Current version: $current_version"
echo "New version: ${{ env.VERSION_NUMBER }}"
if [ "$current_version" = "${{ env.VERSION_NUMBER }}" ]; then
echo "Version has not changed, exiting."
exit 0
fi
- name: Cache Rust toolchain
uses: actions/cache@v3
with:
path: |
~/.cargo
~/.rustup
key: ${{ runner.os }}-rust-toolchain-${{ hashFiles('**/rust-toolchain') }}
- name: Cache Cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Cargo build
uses: actions/cache@v3
with:
path: rust/target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Install Rust (if not cached)
run: |
if [ ! -x "$(command -v rustup)" ]; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
fi
source $HOME/.cargo/env
rustup toolchain install nightly
rustup component add rust-src --toolchain nightly
shell: bash
- name: Build iOS Framework
run: |
chmod +x ./build_ios.sh
./build_ios.sh
working-directory: rust
- name: Replace XCFramework
run: |
rm -rf ios/Frameworks/libcel.xcframework
mv rust/target/xcframeworks/libcel.xcframework ios/Frameworks/
- name: Replace Swift File
run: |
rm -rf ios/Sources/Superscript/cel.swift
mv rust/target/ios/cel.swift ios/Sources/Superscript/
- name: Update Podspec Version
run: |
sed -i '' "s/s.version = \".*\"/s.version = \"${{ env.VERSION_NUMBER }}\"/" ios/Superscript.podspec
- name: Commit and Push Changes
run: |
cd ios
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
# Make sure we have the latest remote main and tags
git fetch origin main --tags
# Rebase our local changes onto the latest remote main
git pull --rebase --autostash origin main
git add .
git commit -m "Update framework" || echo "No changes to commit"
# Safety: remote main may have advanced again between commit and push
git pull --rebase --autostash origin main
git push origin main
- name: Tag the New Version
run: |
git tag -a "${{ env.VERSION_NUMBER }}" -m "Release version ${{ env.VERSION_NUMBER }}"
git push origin "${{ env.VERSION_NUMBER }}"
working-directory: ios
- name: Publish to CocoaPod register
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
pod trunk push Superscript.podspec --allow-warnings
working-directory: ios
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION_NUMBER }}
release_name: ${{ env.VERSION_NUMBER }}
body: "This is an automatically generated release. Please see the [original Rust release](https://github.com/superwall/superscript/releases/tag/${{ env.VERSION_NUMBER }}) for any version changes."
draft: false
prerelease: false