-
Notifications
You must be signed in to change notification settings - Fork 2
109 lines (91 loc) · 4.04 KB
/
update_Applitools_iOS.yml
File metadata and controls
109 lines (91 loc) · 4.04 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
name: Update Applitools_iOS
on:
workflow_dispatch:
permissions:
contents: write
jobs:
update-package:
runs-on: macos-latest
env:
SPM_REPO: applitools/ios-applitools-framework-swift-package
STORAGE_URL: https://sdksstorage.blob.core.windows.net/mobile/ios/nml/framework
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: main
persist-credentials: true
- name: Set up Git identity
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
- name: Download latest framework (release)
run: |
curl -L -o Applitools_latest.xcframework.zip \
"${STORAGE_URL}/release/Applitools_iOS.xcframework.zip"
- name: Extract version from Info.plist
run: |
unzip -q Applitools_latest.xcframework.zip -d xcframework_contents
INFO_PLIST="xcframework_contents/Applitools_iOS.xcframework/ios-arm64/Applitools_iOS.framework/Info.plist"
SHORT_VER=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$INFO_PLIST")
BUNDLE_VER=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "$INFO_PLIST")
VERSION="${SHORT_VER}.${BUNDLE_VER}"
echo "Detected framework version: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Download versioned framework
run: |
curl -L -o Applitools_${VERSION}.xcframework.zip \
"${STORAGE_URL}/${VERSION}/Applitools_iOS.xcframework.zip"
- name: Compute and compare checksums
run: |
RELEASE="Applitools_latest.xcframework.zip"
VERSIONED="Applitools_${VERSION}.xcframework.zip"
CHK_REL=$(swift package compute-checksum "$RELEASE")
CHK_VER=$(swift package compute-checksum "$VERSIONED")
echo "Release checksum: $CHK_REL"
echo "Versioned checksum: $CHK_VER"
if [ "$CHK_REL" != "$CHK_VER" ]; then
echo "::error ::Checksum mismatch between release and versioned archives."
exit 1
fi
echo "CHECKSUM=$CHK_VER" >> $GITHUB_ENV
echo "Checksums match—ready to update if needed."
- name: Determine if update is needed
run: |
CURR=$(grep -Eo 'ios/framework/[0-9]+\.[0-9]+\.[0-9]+' Package.swift \
| head -1 \
| sed 's#.*/##')
echo "Current SPM version: $CURR"
echo "CURRENT_VERSION=$CURR" >> $GITHUB_ENV
if [ "$CURR" = "$VERSION" ]; then
echo "NEED_UPDATE=false" >> $GITHUB_ENV
else
echo "NEED_UPDATE=true" >> $GITHUB_ENV
fi
- name: Dry run - nothing to do
if: env.NEED_UPDATE == 'false'
run: |
echo "Package.swift already at version $VERSION. All checks passed. Exiting dry run."
- name: Update Package.swift (URL & checksum)
if: env.NEED_UPDATE == 'true'
run: |
PACKAGE_FILE="Package.swift"
# 1. Extract the old download URL (anything ending in Applitools_iOS.xcframework.zip)
OLD_URL=$(grep -Eo 'https?://[^"]+/Applitools_iOS\.xcframework\.zip' "$PACKAGE_FILE" | head -1)
echo "Found old URL: $OLD_URL"
# 2. Build the new URL
NEW_URL="${STORAGE_URL}/${VERSION}/Applitools_iOS.xcframework.zip"
echo "New URL: $NEW_URL"
# 3. Replace the old URL with the new one
# Note: we escape the slashes so sed can handle any host/path
sed -E -i '' "s#$(printf '%s' "$OLD_URL" | sed 's/[\/&]/\\&/g')#${NEW_URL}#g" "$PACKAGE_FILE"
# 4. Replace the checksum
sed -E -i '' "s/checksum: *\"[0-9a-f]{64}\"/checksum: \"${CHECKSUM}\"/" "$PACKAGE_FILE"
echo "Package.swift updated to version $VERSION and checksum $CHECKSUM."
- name: Commit, tag & push
if: env.NEED_UPDATE == 'true'
run: |
git add Package.swift
git commit -m "${VERSION}"
git tag "${VERSION}"
git push origin main --tags