diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml deleted file mode 100644 index 53bc3c4b..00000000 --- a/.github/workflows/CD.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: CD - -on: - pull_request_target: - branches: [main] - types: [closed] - -jobs: - release_version: - if: github.event.pull_request.milestone == null && github.event.pull_request.merged == true - runs-on: macOS-latest - steps: - - uses: actions/checkout@v2 - - - name: Publish release - id: publish_release - uses: release-drafter/release-drafter@v5 - with: - publish: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Update podspec - run: fastlane bump_version next_version:${{ steps.publish_release.outputs.tag_name }} - - - name: Commit changes - uses: stefanzweifel/git-auto-commit-action@v4 - with: - branch: 'main' - commit_message: 'Bump version ${{ steps.publish_release.outputs.tag_name }}' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Deploy to Cocoapods - continue-on-error: true - env: - COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} - run: | - set -eo pipefail - pod lib lint --allow-warnings - pod trunk push --allow-warnings - - - name: Tweet the release - uses: ethomson/send-tweet-action@v1 - with: - consumer-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }} - consumer-secret: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} - access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }} - access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} - status: | - 🎉 New release ${{ steps.publish_release.outputs.tag_name }} is out 🚀 - - Check out all the changes here: - ${{ steps.publish_release.outputs.html_url }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 739883a1..86025a93 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,13 +10,28 @@ jobs: runs-on: macos-latest strategy: matrix: - build-config: - - { scheme: 'SkeletonView iOS', destination: 'platform=iOS Simulator,name=iPhone 8', sdk: 'iphonesimulator' } - - { scheme: 'SkeletonView tvOS', destination: 'platform=tvOS Simulator,name=Apple TV', sdk: 'appletvsimulator' } - - { scheme: 'iOS Example', destination: 'platform=iOS Simulator,name=iPhone 8', sdk: 'iphonesimulator' } - - { scheme: 'tvOS Example', destination: 'platform=tvOS Simulator,name=Apple TV', sdk: 'appletvsimulator' } + build-config: + - { + scheme: "SkeletonView iOS", + destination: "platform=iOS Simulator,name=iPhone 15", + sdk: "iphonesimulator", + } + - { + scheme: "SkeletonView tvOS", + destination: "platform=tvOS Simulator,name=Apple TV", + sdk: "appletvsimulator", + } + - { + scheme: "iOS Example", + destination: "platform=iOS Simulator,name=iPhone 15", + sdk: "iphonesimulator", + } + - { + scheme: "tvOS Example", + destination: "platform=tvOS Simulator,name=Apple TV", + sdk: "appletvsimulator", + } steps: - uses: actions/checkout@v2 - name: Build run: xcodebuild clean build -workspace 'SkeletonView.xcworkspace' -scheme '${{ matrix.build-config['scheme'] }}' -sdk '${{ matrix.build-config['sdk'] }}' -destination '${{ matrix.build-config['destination'] }}' - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 101f5772..4531d628 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,47 +1,199 @@ -name: Release -on: [workflow_dispatch] - +name: CD + +on: + workflow_dispatch: + pull_request_target: + branches: [main] + types: [closed] + jobs: + build: + name: Build XCFramework + runs-on: macos-latest + strategy: + matrix: + build-config: + - { + scheme: "SkeletonView iOS", + destination: "generic/platform=iOS", + sdk: "iphoneos", + mach_o_type: "mh_dylib", + archive_path: "build/Release-iphoneos/Dynamic", + } + - { + scheme: "SkeletonView iOS", + destination: "generic/platform=iOS Simulator", + sdk: "iphonesimulator", + mach_o_type: "mh_dylib", + archive_path: "build/Release-iphonesimulator/Dynamic", + } + - { + scheme: "SkeletonView tvOS", + destination: "generic/platform=tvOS", + sdk: "appletvos", + mach_o_type: "mh_dylib", + archive_path: "build/Release-appletvos/Dynamic", + } + - { + scheme: "SkeletonView tvOS", + destination: "generic/platform=tvOS Simulator", + sdk: "appletvsimulator", + mach_o_type: "mh_dylib", + archive_path: "build/Release-appletvsimulator/Dynamic", + } + - { + scheme: "SkeletonView iOS", + destination: "generic/platform=iOS", + sdk: "iphoneos", + mach_o_type: "staticlib", + archive_path: "build/Release-iphoneos/Static", + } + - { + scheme: "SkeletonView iOS", + destination: "generic/platform=iOS Simulator", + sdk: "iphonesimulator", + mach_o_type: "staticlib", + archive_path: "build/Release-iphonesimulator/Static", + } + - { + scheme: "SkeletonView tvOS", + destination: "generic/platform=tvOS", + sdk: "appletvos", + mach_o_type: "staticlib", + archive_path: "build/Release-appletvos/Static", + } + - { + scheme: "SkeletonView tvOS", + destination: "generic/platform=tvOS Simulator", + sdk: "appletvsimulator", + mach_o_type: "staticlib", + archive_path: "build/Release-appletvsimulator/Static", + } + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build framework + run: | + xcodebuild archive \ + -scheme "${{ matrix.build-config.scheme }}" \ + -destination "${{ matrix.build-config.destination }}" \ + -configuration "Release" \ + -sdk "${{ matrix.build-config.sdk }}" \ + -archivePath "${{ matrix.build-config.archive_path }}/SkeletonView.xcarchive" \ + SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES \ + MACH_O_TYPE=${{ matrix.build-config.mach_o_type }} + + - name: Upload archive as artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.build-config.sdk }}-build-${{ matrix.build-config.mach_o_type }} + path: ${{ matrix.build-config.archive_path }} + + create-xcframework: + name: Create XCFramework + needs: build + runs-on: macos-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + path: build/ + + - name: Verify downloaded artifacts + run: ls -R build/ + + - name: Create Static XCFramework + run: | + xcodebuild -create-xcframework \ + -framework build/iphoneos-build-staticlib/SkeletonView.xcarchive/Products/Library/Frameworks/SkeletonView.framework \ + -framework build/iphonesimulator-build-staticlib/SkeletonView.xcarchive/Products/Library/Frameworks/SkeletonView.framework \ + -framework build/appletvos-build-staticlib/SkeletonView.xcarchive/Products/Library/Frameworks/SkeletonView.framework \ + -framework build/appletvsimulator-build-staticlib/SkeletonView.xcarchive/Products/Library/Frameworks/SkeletonView.framework \ + -output build/XCFramework/SkeletonViewStatic.xcframework + + - name: Create Dynamic XCFramework + run: | + xcodebuild -create-xcframework \ + -framework build/iphoneos-build-mh_dylib/SkeletonView.xcarchive/Products/Library/Frameworks/SkeletonView.framework \ + -framework build/iphonesimulator-build-mh_dylib/SkeletonView.xcarchive/Products/Library/Frameworks/SkeletonView.framework \ + -framework build/appletvos-build-mh_dylib/SkeletonView.xcarchive/Products/Library/Frameworks/SkeletonView.framework \ + -framework build/appletvsimulator-build-mh_dylib/SkeletonView.xcarchive/Products/Library/Frameworks/SkeletonView.framework \ + -output build/XCFramework/SkeletonViewDynamic.xcframework + + - name: Compress XCFrameworks + run: | + cd build/XCFramework + zip -r SkeletonViewStatic.xcframework.zip SkeletonViewStatic.xcframework + zip -r SkeletonViewDynamic.xcframework.zip SkeletonViewDynamic.xcframework + + - name: Upload XCFrameworks as Artifacts + uses: actions/upload-artifact@v3 + with: + name: XCFrameworks-Zip + path: build/XCFramework/*.xcframework.zip + release_version: - runs-on: macOS-latest + name: Release Version + needs: create-xcframework + runs-on: macos-latest + steps: - - uses: actions/checkout@v2 - + - uses: actions/checkout@v4 + + - name: Download XCFrameworks ZIP + uses: actions/download-artifact@v3 + with: + name: XCFrameworks-Zip + - name: Publish release id: publish_release - uses: release-drafter/release-drafter@v5 - with: + uses: release-drafter/release-drafter@v6 + with: publish: true env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Update podspec + - name: Publish XCFrameworks + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.publish_release.outputs.tag_name }} + files: | + SkeletonViewDynamic.xcframework.zip + SkeletonViewStatic.xcframework.zip + + - name: Update version in podspec run: fastlane bump_version next_version:${{ steps.publish_release.outputs.tag_name }} - name: Commit changes uses: stefanzweifel/git-auto-commit-action@v4 with: - branch: 'main' - commit_message: 'Bump version ${{ steps.publish_release.outputs.tag_name }}' + branch: "main" + commit_message: "Bump version ${{ steps.publish_release.outputs.tag_name }}" env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Deploy to Cocoapods + - name: Deploy to CocoaPods env: COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} run: | set -eo pipefail pod lib lint --allow-warnings - pod trunk push --allow-warnings - + pod trunk push --allow-warnings + - name: Tweet the release - uses: ethomson/send-tweet-action@v1 + uses: nearform-actions/github-action-notify-twitter@master with: - consumer-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }} - consumer-secret: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} - access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }} - access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} - status: | + message: | 🎉 New release ${{ steps.publish_release.outputs.tag_name }} is out 🚀 Check out all the changes here: - ${{ steps.publish_release.outputs.html_url }} + ${{ steps.publish_release.outputs.html_url }} + twitter-app-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }} + twitter-app-secret: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} + twitter-access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }} + twitter-access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} diff --git a/.github/workflows/validations.yml b/.github/workflows/validations.yml index 624fd917..9766c9d6 100644 --- a/.github/workflows/validations.yml +++ b/.github/workflows/validations.yml @@ -1,34 +1,25 @@ name: Validations -on: +on: pull_request_target: branches: [main] types: [opened, reoneped, edited, synchronized] -# workflow_dispatch: -# inputs: -# commit hash: -# description: "Commit hash" -# required: true -# default: "" - jobs: lint: - runs-on: macos-latest + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Run SwiftLint - run: swiftlint lint --reporter github-actions-logging + - uses: actions/checkout@v1 + - name: GitHub Action for SwiftLint with --strict + uses: norio-nomura/action-swiftlint@3.2.1 - danger: + danger: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Danger - uses: docker://frmeloni/danger-swift-with-swiftlint:1.3.1 + uses: 417-72KI/danger-swiftlint@v5.10 # Look at the `Note for version` with: - args: --failOnErrors --verbose + args: --failOnErrors --verbose env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - diff --git a/Examples/iOS Example/iOS Example.xcodeproj/project.pbxproj b/Examples/iOS Example/iOS Example.xcodeproj/project.pbxproj index 9a815257..0b4ddb39 100644 --- a/Examples/iOS Example/iOS Example.xcodeproj/project.pbxproj +++ b/Examples/iOS Example/iOS Example.xcodeproj/project.pbxproj @@ -327,7 +327,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.5; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -382,7 +382,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.5; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; diff --git a/Package.swift b/Package.swift index 83079270..cd2e3dc9 100644 --- a/Package.swift +++ b/Package.swift @@ -1,12 +1,12 @@ -// swift-tools-version:5.3 +// swift-tools-version:5.10 import PackageDescription let package = Package( name: "SkeletonView", platforms: [ - .iOS(.v9), - .tvOS(.v9) + .iOS(.v12), + .tvOS(.v12) ], products: [ .library( diff --git a/SkeletonView.podspec b/SkeletonView.podspec index bd48f7ca..6a70fb64 100644 --- a/SkeletonView.podspec +++ b/SkeletonView.podspec @@ -10,9 +10,20 @@ Pod::Spec.new do |s| s.license = { :type => "MIT", :file => "LICENSE" } s.author = { "Juanpe Catalán" => "juanpecm@gmail.com" } s.social_media_url = "https://x.com/JuanpeCatalan" - s.ios.deployment_target = "9.0" - s.tvos.deployment_target = "9.0" + s.ios.deployment_target = "12.0" + s.tvos.deployment_target = "12.0" s.swift_version = "5.0" s.source = { :git => "https://github.com/Juanpe/SkeletonView.git", :tag => s.version.to_s } s.source_files = "SkeletonViewCore/Sources/**/*.{swift,h}" + s.vendored_frameworks = "SkeletonView.xcframework" + + # Subspec para o framework estático + s.subspec "Static" do |sp| + sp.vendored_frameworks = "StaticXCFramework.xcframework" + end + + # Subspec para o framework dinâmico + s.subspec "Dynamic" do |sp| + sp.vendored_frameworks = "DynamicXCFramework.xcframework" + end end diff --git a/SkeletonViewCore/Sources/API/AnimationBuilder/SkeletonAnimationBuilder.swift b/SkeletonViewCore/Sources/API/AnimationBuilder/SkeletonAnimationBuilder.swift index 321c9b13..c7a52bd2 100644 --- a/SkeletonViewCore/Sources/API/AnimationBuilder/SkeletonAnimationBuilder.swift +++ b/SkeletonViewCore/Sources/API/AnimationBuilder/SkeletonAnimationBuilder.swift @@ -27,10 +27,15 @@ public class SkeletonAnimationBuilder { let animGroup = CAAnimationGroup() animGroup.animations = [startPointAnim, endPointAnim] animGroup.duration = duration - animGroup.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeIn) animGroup.repeatCount = .infinity animGroup.autoreverses = autoreverses animGroup.isRemovedOnCompletion = false + + if #available(iOS 12.0, *) { + animGroup.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeIn) + } else { + animGroup.timingFunction = CAMediaTimingFunction(controlPoints: 0.42, 0.0, 1.0, 1.0) + } return animGroup } diff --git a/SkeletonViewCore/Sources/API/UIKitExtensions/CALayer+Animations.swift b/SkeletonViewCore/Sources/API/UIKitExtensions/CALayer+Animations.swift index 89d22194..87e518c3 100644 --- a/SkeletonViewCore/Sources/API/UIKitExtensions/CALayer+Animations.swift +++ b/SkeletonViewCore/Sources/API/UIKitExtensions/CALayer+Animations.swift @@ -22,10 +22,15 @@ public extension CALayer { // swiftlint:disable:next force_unwrapping pulseAnimation.toValue = UIColor(cgColor: backgroundColor!).complementaryColor.cgColor pulseAnimation.duration = 1 - pulseAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut) pulseAnimation.autoreverses = true pulseAnimation.repeatCount = .infinity pulseAnimation.isRemovedOnCompletion = false + + if #available(iOS 12.0, *) { + pulseAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut) + } else { + pulseAnimation.timingFunction = CAMediaTimingFunction(controlPoints: 0.42, 0.0, 0.58, 1.0) + } return pulseAnimation }