Skip to content

Commit

Permalink
chore(ios): add release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
adwinross committed Mar 10, 2025
1 parent 4e75993 commit 52d4dc7
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 51 deletions.
68 changes: 46 additions & 22 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,56 @@ on:
pull_request:
paths:
- 'ios/**'
push:
branches:
- 'main'
- 'ios-release'
paths:
- 'ios/**'
tags:
- 'ios-*'

jobs:
ios_lint_and_tests:
# ios_lint_and_tests:
# runs-on: macos-latest
# permissions:
# contents: read
# pull-requests: read
# steps:
# - name: Checkout Repository
# uses: actions/checkout@v4

# - name: Run SwiftLint
# uses: cirruslabs/swiftlint-action@fdc2695c66b8807e7b1571d08097a99cf1fde41b
# with:
# version: latest
# directory: ios

# - name: Clean Derived Data
# run: |
# rm -rf ~/Library/Developer/Xcode/DerivedData

# - name: Run Unit Tests
# run: |
# xcodebuild test \
# -project ios/MeasureSDK.xcodeproj \
# -scheme MeasureSDK \
# -sdk iphonesimulator \
# -destination 'platform=iOS Simulator,name=iPhone 15 Pro' \
# ONLY_ACTIVE_ARCH=YES

publish-ios:
runs-on: macos-latest
# needs: [ ios_lint_and_tests ]
# if: startsWith(github.ref, 'refs/tags/ios-')
if: github.ref == 'refs/heads/ios-release'
permissions:
contents: read
pull-requests: read
packages: write
timeout-minutes: 30
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Run SwiftLint
uses: cirruslabs/swiftlint-action@fdc2695c66b8807e7b1571d08097a99cf1fde41b
with:
version: latest
directory: ios

- name: Clean Derived Data
run: |
rm -rf ~/Library/Developer/Xcode/DerivedData
- name: Run Unit Tests
- name: Lint CocoaPods
run: |
xcodebuild test \
-project ios/MeasureSDK.xcodeproj \
-scheme MeasureSDK \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 15 Pro' \
ONLY_ACTIVE_ARCH=YES
cd ..
pwd
pod spec lint MeasureSDK.podspec
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ node_modules

# vscode multi-root workspace
*.code-workspace

# ios
.build/
.swiftpm/
Package.resolved
18 changes: 18 additions & 0 deletions MeasureSDK.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Pod::Spec.new do |spec|
spec.name = "MeasureSDK"
spec.version = "0.0.1"
spec.summary = "Open source tool to monitor mobile apps"
spec.homepage = "https://github.com/measure-sh/measure.git"
spec.license = { :type => "MIT", :file => "LICENSE" }
spec.author = "measure.sh"
spec.platform = :ios, "12.0"
spec.swift_version = "5.10"
spec.static_framework = true
spec.source = { :git => "https://github.com/measure-sh/measure.git",
:branch => "ios-release" }
spec.source_files = "ios/Sources/MeasureSDK/Swift/**/*.{swift}", "ios/Sources/MeasureSDK/Objc/**/*.{h,m}"
spec.public_header_files = "ios/Sources/MeasureSDK/Objc/include/**/*.h"
spec.resources = ["ios/Sources/MeasureSDK/Swift/XCDataModel/MeasureModel.xcdatamodeld", "ios/Sources/MeasureSDK/Swift/Resources/PrivacyInfo.xcprivacy"]
spec.frameworks = "Foundation", "UIKit", "CoreData"
spec.dependency "PLCrashReporter"
end
19 changes: 9 additions & 10 deletions ios/Package.swift → Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,26 @@ let package = Package(
.package(url: "https://github.com/microsoft/plcrashreporter.git", from: "1.11.2")
],
targets: [
.target(
name: "MeasureSDKObjc",
dependencies: [],
path: "Sources/MeasureSDK/Objc",
publicHeadersPath: "include"
),
.target(
name: "MeasureSDK",
dependencies: [
"MeasureSDKObjc",
.product(name: "CrashReporter", package: "plcrashreporter")
],
path: "Sources/MeasureSDK/Swift"
path: "ios/Sources/MeasureSDK/Swift",
resources: [
.process("XCDataModel/MeasureModel.xcdatamodeld"),
.copy("Resources/PrivacyInfo.xcprivacy")
]
),
.testTarget(
name: "MeasureSDKTests",
dependencies: ["MeasureSDK"]
dependencies: ["MeasureSDK"],
path: "ios/Tests/MeasureSDKTests"
),
.testTarget(
name: "MeasureUITests",
dependencies: ["MeasureSDK"]
dependencies: ["MeasureSDK"],
path: "ios/Tests/MeasureUITests"
),
]
)
18 changes: 0 additions & 18 deletions ios/MeasureSDK.podspec

This file was deleted.

2 changes: 1 addition & 1 deletion ios/PublicApi/MeasureSDK.swiftinterface
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 6.0.3 effective-5.10 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
// swift-module-flags: -target x86_64-apple-ios12-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Onone -enable-experimental-feature OpaqueTypeErasure -enable-bare-slash-regex -module-name MeasureSDK
// swift-module-flags: -target arm64-apple-ios12 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Onone -enable-experimental-feature OpaqueTypeErasure -enable-bare-slash-regex -module-name MeasureSDK
// swift-module-flags-ignorable: -no-verify-emitted-module-interface
import CoreData
import CoreTelephony
Expand Down
69 changes: 69 additions & 0 deletions ios/Scripts/bump_sdk_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

set -e # Exit immediately if a command exits with a non-zero status

# Get the release type from the first argument (major, minor, patch)
RELEASE_TYPE=$1

# File paths
FRAMEWORK_INFO_FILE="../Sources/MeasureSDK/Swift/FrameworkInfo.swift"
PODSPEC_FILE="../MeasureSDK.podspec"

# Function to get the current version from FrameworkInfo.swift
get_current_version() {
grep -oE '[0-9]+\.[0-9]+\.[0-9]+' "$FRAMEWORK_INFO_FILE" | head -1
}

# Function to bump version
bump_version() {
local version=$1
local type=$2
IFS='.' read -r major minor patch <<< "$version"

case "$type" in
major)
major=$((major + 1))
minor=0
patch=0
;;
minor)
minor=$((minor + 1))
patch=0
;;
patch)
patch=$((patch + 1))
;;
*)
echo "Invalid release type: $type"
exit 1
;;
esac

echo "$major.$minor.$patch"
}

# Get current version
CURRENT_VERSION=$(get_current_version)
echo "Current version: $CURRENT_VERSION"

# Get new version
NEW_VERSION=$(bump_version "$CURRENT_VERSION" "$RELEASE_TYPE")
echo "New version: $NEW_VERSION"

# Update version in FrameworkInfo.swift
sed -i '' "s/static let version = \".*\"/static let version = \"$NEW_VERSION\"/" "$FRAMEWORK_INFO_FILE"

# Update version in podspec (Fix: Use a temp file method)
awk -v new_version="$NEW_VERSION" '/spec.version *= *"[0-9]+\.[0-9]+\.[0-9]+"/ { sub(/[0-9]+\.[0-9]+\.[0-9]+/, new_version); }1' "$PODSPEC_FILE" > temp_podspec && mv temp_podspec "$PODSPEC_FILE"

# Verify updates
grep "static let version" "$FRAMEWORK_INFO_FILE"
grep "spec.version" "$PODSPEC_FILE"

# Commit and push changes
# git add "$FRAMEWORK_INFO_FILE" "$PODSPEC_FILE"
# git commit -m "Release version $NEW_VERSION"
# git tag "v$NEW_VERSION"
# git push origin main --tags

echo "✅ Release $NEW_VERSION created successfully!"

0 comments on commit 52d4dc7

Please sign in to comment.