Skip to content

Commit a95c9f2

Browse files
authored
RMET-3301 Enable XCFramework use in Cocoa pods (#15)
* chore: set up scripts and actions for cocoa pods publishing * chore: cleanup after review comments * chore: sonar ignore scripts files * chore: more exclusions * chore: try fastlane ignore * chore: sonar ignore * chore: no capital S * chore: changelog and action updates * chore: path fix * chore: no release if none * chore: update gitignore * chore: missing type in action list * chore: fix zipping
1 parent c8aa3a1 commit a95c9f2

File tree

7 files changed

+152
-4
lines changed

7 files changed

+152
-4
lines changed

.github/workflows/release_pod.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Build and Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
versionBumpLevel:
7+
description: 'Version bump level (patch, minor, major, none)'
8+
required: true
9+
type: choice
10+
default: 'patch'
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
- none
16+
17+
jobs:
18+
build-and-release:
19+
runs-on: macos-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Set up XCode
25+
run: sudo xcode-select --switch /Applications/Xcode_14.1.app
26+
27+
- name: Set up Ruby
28+
uses: ruby/setup-ruby@v1
29+
with:
30+
ruby-version: '3.3'
31+
32+
- name: Set up Cocoapods
33+
run: gem install cocoapods
34+
35+
- name: Bump version
36+
run: ruby ./scripts/bump_pod_version.rb ${{ github.event.inputs.versionBumpLevel }}
37+
38+
- name: Build XCFramework
39+
run: ./scripts/build_framework.sh
40+
41+
- name: Get new version
42+
id: version
43+
run: echo "VERSION=$(ruby -e 'puts File.read("./OSBarcodeLib.podspec").match(/spec.version.*=.*\"(\d+\.\d+\.\d+)\"/)[1]')" >> $GITHUB_ENV
44+
45+
- name: Create Release
46+
id: create_release
47+
if: ${{ github.event.inputs.versionBumpLevel != 'none' }}
48+
uses: softprops/action-gh-release@v2
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
with:
52+
tag_name: ${{ env.VERSION }}
53+
name: ${{ env.VERSION }}
54+
draft: false
55+
prerelease: false
56+
files: 'scripts/build/OSBarcodeLib.zip'
57+
58+
- name: Deploy to Cocoapods
59+
env:
60+
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
61+
run: pod trunk push ./OSBarcodeLib.podspec --allow-warnings
62+
63+
- name: Commit changes
64+
if: ${{ github.event.inputs.versionBumpLevel != 'none' }}
65+
run: |
66+
git config --global user.name 'github-actions[bot]'
67+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
68+
git add .
69+
git commit -m "chore: Bump version to ${{ env.VERSION }}"
70+
git pull --rebase
71+
git push origin HEAD:main

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,6 @@ fastlane/test_output
8989

9090
iOSInjectionProject/
9191
.swiftlint.yml
92+
93+
scripts/build/
94+
.DS_Store

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
### Chores
1010
- Update `github_actions.yml` file steps versions (https://outsystemsrd.atlassian.net/browse/RMET-2568).
11+
- Set up the repo to release on CocoaPods (https://outsystemsrd.atlassian.net/browse/RMET-3301).
1112

1213
### Features
1314
- Add zooming out feature (https://outsystemsrd.atlassian.net/browse/RMET-2986).

OSBarcodeLib.podspec

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
Pod::Spec.new do |spec|
3+
spec.name = "OSBarcodeLib"
4+
spec.version = "1.0.0"
5+
spec.summary = "The OSBarcodeLib is a library built using Swift that offers you a barcode scanner for your iOS application."
6+
spec.homepage = "https://github.com/OutSystems/OSBarcodeLib-iOS"
7+
spec.license = { :type => 'MIT', :file => 'LICENSE' }
8+
spec.author = "OutSystems"
9+
spec.ios.deployment_target = '13.0'
10+
spec.swift_version = '5.1'
11+
spec.source = { :http => "https://github.com/OutSystems/OSBarcodeLib-iOS/releases/download/#{spec.version}/OSBarcodeLib.zip", :type => "zip" }
12+
spec.vendored_frameworks = "OSBarcodeLib.xcframework"
13+
end
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
rm -rf build
1+
rm -rf scripts/build
22

3-
cd ..
3+
# cd ..
44

55
xcodebuild archive \
66
-scheme OSBarcodeLib \
@@ -23,4 +23,8 @@ BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
2323
xcodebuild -create-xcframework \
2424
-framework './scripts/build/OSBarcodeLib.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/OSBarcodeLib.framework' \
2525
-framework './scripts/build/OSBarcodeLib.framework-iphoneos.xcarchive/Products/Library/Frameworks/OSBarcodeLib.framework' \
26-
-output './scripts/build/OSBarcodeLib.xcframework'
26+
-output './scripts/build/OSBarcodeLib.xcframework'
27+
28+
cd ./scripts/build
29+
30+
zip -r ./OSBarcodeLib.zip ./OSBarcodeLib.xcframework

scripts/bump_pod_version.rb

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# bump_version.rb
2+
3+
require 'bundler'
4+
5+
# Read version level from ARGV
6+
level = ARGV[0]
7+
8+
# Define the path to your .podspec file
9+
podspec_path = "./OSBarcodeLib.podspec"
10+
11+
# Read the .podspec file
12+
podspec_content = File.read(podspec_path)
13+
14+
# Extract current version
15+
current_version = podspec_content.match(/spec.version\s*=\s*["'](\d+\.\d+\.\d+)["']/)[1]
16+
17+
# Parse the version into major, minor, and patch components
18+
major, minor, patch = current_version.split('.').map(&:to_i)
19+
20+
# Increment the version based on the specified level
21+
case level
22+
when "major"
23+
major += 1
24+
# Reset minor and patch to 0 when major version is incremented
25+
minor = 0
26+
patch = 0
27+
when "minor"
28+
minor += 1
29+
# Reset patch to 0 when minor version is incremented
30+
patch = 0
31+
when "patch"
32+
patch += 1
33+
when "none"
34+
puts "No version bump"
35+
else
36+
raise ArgumentError, "Invalid version bump level: #{level}. Must be one of: major, minor, patch."
37+
end
38+
39+
if level != "none"
40+
# Combine the new version components
41+
new_version = [major, minor, patch].join('.')
42+
43+
# Replace 'Unreleased' in the CHANGELOG.md with the new version
44+
changelog_path = "./CHANGELOG.md"
45+
changelog_content = File.read(changelog_path)
46+
new_changelog_content = changelog_content.gsub(/Unreleased/, new_version)
47+
File.write(changelog_path, new_changelog_content)
48+
49+
# Replace the old version with the new version in the .podspec content
50+
new_podspec_content = podspec_content.gsub(/(spec.version\s*=\s*["'])\d+\.\d+\.\d+(["'])/, "\\1#{new_version}\\2")
51+
52+
# Write the new .podspec content back to the file
53+
File.write(podspec_path, new_podspec_content)
54+
55+
puts "Version updated to #{new_version}"
56+
end

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ sonar.test.inclusions=**/*Test*/**
2525
sonar.test.inclusions=*.swift
2626
sonar.exclusions=**/*.xml,Pods/**/*,Reports/**/*,**/*Test*/**
2727

28-
sonar.coverage.exclusions=**/*ViewModifiers*/**,**/*Coordinator*/**,**/*Permissions*/**,**/*Scanner*/**
28+
sonar.coverage.exclusions=**/*ViewModifiers*/**,**/*Coordinator*/**,**/*Permissions*/**,**/*Scanner*/**,**/*scripts/**/*
2929

3030
sonar.tests=OSBarcodeLibTests
3131

0 commit comments

Comments
 (0)