From 325ef3e9de9b9b828c3615f05f8652b0b165b9c7 Mon Sep 17 00:00:00 2001 From: Alessio Borraccino Date: Wed, 10 Nov 2021 14:10:38 +0100 Subject: [PATCH] Update release script and docs --- CHANGELOG.adoc | 155 +++++++ CHANGELOG.md | 75 ---- CODE-OF-CONDUCT.md => CODE-OF-CONDUCT.adoc | 70 ++-- CONTRIBUTING.adoc | 106 +++++ DEVELOPING.adoc | 128 ++++++ Data4LifeSDKUtils.podspec | 18 - LICENSE | 2 +- Package.swift | 22 +- README.adoc | 107 +++++ README.md | 48 --- Sources/SDKUtils/SDKUtils.h | 2 +- Sources/SDKUtils/Source/ByteCountable.swift | 2 +- .../SDKUtils/Source/Data+ByteCountable.swift | 2 +- .../SDKUtils/Source/Data+Cryptography.swift | 2 +- Sources/SDKUtils/Source/DataValidator.swift | 2 +- Sources/SDKUtils/Source/MIMEType.swift | 2 +- .../SDKUtilsTests/DataCryptographyTests.swift | 2 +- Tests/SDKUtilsTests/DataValidatorTests.swift | 2 +- Tests/SDKUtilsTests/MIMETypeTests.swift | 2 +- assets/images/badge-license.svg | 1 + assets/images/badge-platform-support.svg | 1 + assets/images/badge-release-latest.svg | 1 + assets/images/badges.adoc | 31 ++ assets/images/d4l-logo.svg | 9 + fastlane/Fastfile | 390 ++++++++++-------- 25 files changed, 810 insertions(+), 372 deletions(-) create mode 100644 CHANGELOG.adoc delete mode 100644 CHANGELOG.md rename CODE-OF-CONDUCT.md => CODE-OF-CONDUCT.adoc (57%) create mode 100644 CONTRIBUTING.adoc create mode 100644 DEVELOPING.adoc delete mode 100644 Data4LifeSDKUtils.podspec create mode 100644 README.adoc delete mode 100644 README.md create mode 100644 assets/images/badge-license.svg create mode 100644 assets/images/badge-platform-support.svg create mode 100644 assets/images/badge-release-latest.svg create mode 100644 assets/images/badges.adoc create mode 100644 assets/images/d4l-logo.svg diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc new file mode 100644 index 0000000..ac70f55 --- /dev/null +++ b/CHANGELOG.adoc @@ -0,0 +1,155 @@ += Changelog +:link-repository: https://github.com/d4l-data4life/d4l-utils-ios +:doctype: article +:toc: macro +:toclevels: 1 +:toc-title: +:icons: font +:imagesdir: assets/images +ifdef::env-github[] +:warning-caption: :warning: +:caution-caption: :fire: +:important-caption: :exclamation: +:note-caption: :paperclip: +:tip-caption: :bulb: +endif::[] + +All notable changes to this project will be documented in this file. + +The format is based on http://keepachangelog.com/en/1.0.0/[Keep a Changelog] +and this project adheres to http://semver.org/spec/v2.0.0.html[Semantic Versioning]. + +Template could be found here: link:https://github.com/d4l-data4life/hc-readme-template/blob/main/TEMPLATE_CHANGELOG.adoc[CHANGELOG] + +[discrete] +==== Versions + +toc::[] + +== link:{link-repository}/releases/latest[Unreleased] + +See link:{link-repository}/compare/v0.7.0...main[changeset] + +=== Added + +=== Changed + +=== Removed + +=== Fixed + +=== Security + +=== Bumped + +=== Deprecated + +=== Migration + + +== link:{link-repository}/releases/tag/v0.7.0[0.7.0] + +=== Bumped + +* Updated to xcode 13.1 + +== link:{link-repository}/releases/tag/0.6.0[0.6.0] + +=== Removed + +* Removes debug symbols from xcframework due to duplicates issues + +== link:{link-repository}/releases/tag/0.5.0[0.5.0] + +=== Removed + +* Removes support for iOS 12 +* Removes CryptoSwift dependency + +== link:{link-repository}/releases/tag/0.4.0[0.4.0] + +=== Changed + +* Now distributing XCFramework instead of fat one +* Discontinued Carthage in favor of Swift PM as decentralized +* Adds separate Cryptoswift xcframework + +== link:{link-repository}/releases/tag/0.3.1[0.3.1] + +=== Changed + +* Pod spec updated to public repo + +== link:{link-repository}/releases/tag/0.3.0[0.3.0] + +=== Changed + +* Open sourced + +== link:{link-repository}/releases/tag/0.2.3[0.2.3] + +=== Added + +* Readded Carthage support using carthage CryptoSwift instead of the swiftPM version + +== link:{link-repository}/releases/tag/0.2.2[0.2.2] + +=== Added + +* Switch CryptoSwift repository to own fork to create dynamic library + +== link:{link-repository}/releases/tag/0.2.1[0.2.1] + +=== Added + +* Makes Swift Package dynamic + +== link:{link-repository}/releases/tag/0.2.0[0.2.0] + +=== Added + +* Adds Support for Swift PM +* Adds CryptoSwift as package dependency instead +* Removes Carthage need for building framework + +== link:{link-repository}/releases/tag/0.1.6[0.1.6] + +=== Added + +* Fixes framework embedding issue for app store + +== link:{link-repository}/releases/tag/0.1.5[0.1.5] + +=== Added + +* Adds Cocoapods support + +== link:{link-repository}/releases/tag/0.1.4[0.1.4] + +=== Added + +* Adds Data SHA1 algorithm + +== link:{link-repository}/releases/tag/0.1.3[0.1.3] +=== Fixed +* Fixes Data Validator SDK Limit + +== link:{link-repository}/releases/tag/0.1.2[0.1.2] + +=== Added + +* Adds Data Validator public properties + +== link:{link-repository}/releases/tag/0.1.1[0.1.1] + +=== Added + +* Adds Data Validator + +== link:{link-repository}/releases/tag/0.1.0[0.1.0] + +=== Added + +* First version of SDK Utils library + + diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 43f1ca2..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,75 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) -and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). - -## [Unreleased] -- Updated to xcode 13.1 - -## [0.6.0] - 2021-04-13 -- Removes debug symbols from xcframework due to duplicates issues - -## [0.5.0] - 2021-04-13 -- Removes support for iOS 12 -- Removes CryptoSwift dependency - -## [0.4.0] - 2021-03-16 -### Changed -- Now distributing XCFramework instead of fat one -- Discontinued Carthage in favor of Swift PM as decentralized -- Adds separate Cryptoswift xcframework - -## [0.3.1] - 2020-03-24 -### Changed -- Pod spec updated to public repo - -## [0.3.0] - 2020-12-01 -### Changed -- Open sourced - -## [0.2.3] - 11-04-2020 -### Added -- Readded Carthage support using carthage CryptoSwift instead of the swiftPM version - -## [0.2.2] - 10-02-2020 -### Added -- Switch CryptoSwift repository to own fork to create dynamic library - -## [0.2.1] - 10-02-2020 -### Added -- Makes Swift Package dynamic - -## [0.2.0] - 09-28-2020 -### Added -- Adds Support for Swift PM -- Adds CryptoSwift as package dependency instead -- Removes Carthage need for building framework - -## [0.1.6] - 09-03-2020 -### Added -- Fixes framework embedding issue for app store - -## [0.1.5] - 29-01-2020 -### Added -- Adds Cocoapods support - -## [0.1.4] - 22-01-2020 -### Added -- Adds Data SHA1 algorithm - -## [0.1.3] - 21-01-2020 -### Fixed -- Fixes Data Validator SDK Limit - -## [0.1.2] - 21-01-2020 -### Added -- Adds Data Validator public properties - -## [0.1.1] - 16-01-2020 -### Added -- Adds Data Validator - -## [0.1.0] - 16-01-2020 -### Added -- First version of SDK Utils library diff --git a/CODE-OF-CONDUCT.md b/CODE-OF-CONDUCT.adoc similarity index 57% rename from CODE-OF-CONDUCT.md rename to CODE-OF-CONDUCT.adoc index f8f449f..05e3fd3 100644 --- a/CODE-OF-CONDUCT.md +++ b/CODE-OF-CONDUCT.adoc @@ -1,6 +1,25 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge += Contributor Covenant Code of Conduct +:link-repository: https://github.com/d4l-data4life/d4l-utils-ios +:doctype: article +:toc: macro +:toclevels: 2 +:toc-title: +:icons: font +:imagesdir: assets/images +ifdef::env-github[] +:warning-caption: :warning: +:caution-caption: :fire: +:important-caption: :exclamation: +:note-caption: :paperclip: +:tip-caption: :bulb: +endif::[] + +[discrete] +==== Table Of Contents + +toc::[] + +== Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and @@ -9,29 +28,29 @@ size, disability, ethnicity, gender identity and expression, level of experience nationality, personal appearance, race, religion, or sexual identity and orientation. -## Our Standards +== Our Standards Examples of behavior that contributes to creating a positive environment include: -- Using welcoming and inclusive language -- Being respectful of differing viewpoints and experiences -- Gracefully accepting constructive criticism -- Focusing on what is best for the community -- Showing empathy towards other community members +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members Examples of unacceptable behavior by participants include: -- The use of sexualized language or imagery and unwelcome sexual attention or - advances -- Trolling, insulting/derogatory comments, and personal or political attacks -- Public or private harassment -- Publishing others' private information, such as a physical or electronic - address, without explicit permission -- Other conduct which could reasonably be considered inappropriate in a - professional setting +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting -## Our Responsibilities +== Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in @@ -43,7 +62,7 @@ that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. -## Scope +== Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of @@ -52,10 +71,10 @@ address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. -## Enforcement +== Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at mobile@data4life.care. All +reported by contacting the project team at mailto:mobile@data4life.care[mobile@data4life.care]. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. @@ -65,10 +84,7 @@ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at [https://contributor-covenant.org/version/1/4][version] +== Attribution -[homepage]: https://contributor-covenant.org -[version]: https://contributor-covenant.org/version/1/4/ +This Code of Conduct is adapted from the link:https://contributor-covenant.org[Contributor Covenant], version 1.4, +available at link:https://contributor-covenant.org/version/1/4/[https://contributor-covenant.org/version/1/4] diff --git a/CONTRIBUTING.adoc b/CONTRIBUTING.adoc new file mode 100644 index 0000000..bcb5bd7 --- /dev/null +++ b/CONTRIBUTING.adoc @@ -0,0 +1,106 @@ += Contributing +:link-repository: https://github.com/d4l-data4life/d4l-utils-ios +:doctype: article +:toc: macro +:toclevels: 2 +:toc-title: +:icons: font +:imagesdir: assets/images +ifdef::env-github[] +:warning-caption: :warning: +:caution-caption: :fire: +:important-caption: :exclamation: +:note-caption: :paperclip: +:tip-caption: :bulb: +endif::[] + +When contributing to this project, this document should help you get started. + +[discrete] +==== Table Of Contents + +toc::[] + +== Code Of Conduct + +This project adheres to the Contributor Covenant link:CODE-OF-CONDUCT.adoc[Code Of Conduct]. By participating, you are expected to uphold this code. + +== Issues + +We use GitHub issues to track bugs and enhancements. + +Issues are very valuable to this project, please feel free to open link:{link-repository}/issues[issues] for: + +* _**Questions**_ help us to improve the user experience +* _**Ideas**_ are a great source for contributions +* _**Problems**_ show where this project is lacking + +If you are reporting a problem, please help to us by providing as much information as possible. Ideally, that includes a description or small sample project how to reproduce the problem. + +It’s also a good practice to search for existing or related issues before submitting your own. Thank you! + +== Contribute Code + +=== Pull Requests + +link:{link-repository}/pulls[Pull requests] are a great way to improve the project. But please, discuss your contribution with us before making changes. + +If you contribute, you have: + +* signed Contributor License Agreement, see <<_licensing>> +* made clear which problem you're trying to solve +* followed our link:CODE-OF-CONDUCT.adoc[Code of conduct] +* followed our link:DEVELOPING.adoc[Development process] + +==== Create Pull Request + +Please use our title pattern: `[{ticket id}] {type of change} {short description}`: + +* Optional: Add `ticket id` in brackets if you have any, otherwise leave it out. +* `type of change`: +- *Add* for new features or functionality +- *Change* for changes in existing features or functionality +- *Remove* | for removed features or functionality +- *Fix* for any bug fixes +- *Security* in case of vulnerabilities +- *Bump* for dependency updates +* `short description` of your change + +Example: + +* Add awesome hashing algorithm +* [SDK-156] Change thumbnail generation + +Pull requests must fill the provided template. Put N/A when a paragraph cannot be filled. + +*Labels* should be used (enhancement,bugfix, help wanted etc...) to categorise your contribution. + +Important:: Work in progress pull-requests should be created as a draft. + +==== Code Review + +At least 1 member of the link:https://github.com/orgs/d4l-data4life/teams/phdc-core[PHDC Core Team] will review +your contribution and validate if these criteria are met: + +* [ ] Functional and fitting in the project +* [ ] Code style and naming conventions followed +* [ ] Test written and passing +* [ ] Continuous Integration build passing +* [ ] Cross platform testing done for all supported platforms +* [ ] Documentation updated +* [ ] Changelog updated + +[#_licensing] +== Licensing + +Due to the private link:LICENSE[License] this repository is published under, external contributors need to sign a +Contributor License Agreement. Please get in contact with mailto:mobile@data4life.care[mobile@data4life.care] before contributing to the project. + +== Components Using Other Licenses + +Contributing code and introducing dependencies into the repository from other projects that use one of the following licenses is allowed. + +* link:https://opensource.org/licenses/MIT[MIT] +* link:https://opensource.org/licenses/Apache-2.0[Apache 2.0] + +Any other contribution needs to be signed off by the project owners. diff --git a/DEVELOPING.adoc b/DEVELOPING.adoc new file mode 100644 index 0000000..53a7e89 --- /dev/null +++ b/DEVELOPING.adoc @@ -0,0 +1,128 @@ += Developing +:link-repository: https://github.com/d4l-data4life/d4l-utils-ios +:doctype: article +:toc: macro +:toclevels: 2 +:toc-title: +:icons: font +:imagesdir: assets/images +ifdef::env-github[] +:warning-caption: :warning: +:caution-caption: :fire: +:important-caption: :exclamation: +:note-caption: :paperclip: +:tip-caption: :bulb: +endif::[] + +Guide for our development process, project setup and how to write code. + +[discrete] +==== Table Of Contents + +toc::[] + +== Prerequisites + +* XCode 12.5 +* iOS 13.0 +* Swift 5.4+ +* Bundler +* AWS cli tool + +== Install + +=== Install Gems using bundler + +Install bundler by following instructions at the link:https://bundler.io/[official page]. +When done, run: + +[source, bash] +---- +bundle install +---- + + +=== Install AWS Cli tool + +Install the aws cli tool by following instructions at the link:https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html[official page]. + +Configure it by entering: + +[source, bash] +---- +aws configure +---- + +and entering following data + +[source, bash] +---- +AWS Access Key ID: xxxxx +AWS Secret Access Key: xxxxx +Default region name: eu-central-1 +Default output format: json] +---- + +NOTE: Access key ID and secret are secretly stored and must be asked for. + + +== Build + +Just open XCode and build the Data4LifeSDKUtils Scheme. + +== Release + +A release branches of from `main` branch with following pattern: + +* `release/{major}.{minor}.{patch})/prepare-{major}.{minor}.{patch}` + +=== Steps + +* Update link:CHANGELOG.adoc[CHANGELOG] +* Run prepare release script (eg. `bundle exec fastlane ios prepare_release version:"1.0.0" api_token:"xxxxxxx"`) +* On github, publish the release manually by setting the new tag (eg. `v1.0.0`) + +NOTE: Prepare release script will fail if there is no new version defined in the changelog + +=== Prepare release script steps + +The script executes the following commands: + +* Update new versions in the README.adoc and project files (including badges) +* Do sanity checks (Proper version number in changelog etc.) +* Build framework and upload it to S3 +* Update Package swift info (url and checksum) +* Commit and push changes (if prompted to do so) +* Create GitHub release draft with all of the information from link:CHANGELOG.adoc[CHANGELOG] + +[source, bash] +---- +bundle exec fastlane ios prepare_release version:"1.0.0" api_token:"xxxxxxx" +---- + +== Development Process + +=== Features + +Every change has to branch of from `main` and use this branch naming convention: + +* `feature/{type_of_change}-{short_description}` or with ticket id `feature/{ticket_id}/{type_of_change}-{short_description}` + +`main` must be always in releasable state. + +==== Type Of Change + +- *add* for new features or functionality +- *change* for changes in existing features or functionality +- *remove* | for removed features or functionality +- *fix* for any bug fixes +- *bump* for dependency updates +- *security* in case of vulnerabilities + +Examples: + +- `feature/SDK-456/add-awesome-hashing-algorithm` +- `feature/add-awesome-hashing-algorithm` +- `feature/remove-not-so-awesome-algorithm` +- `feature/fix-algorithm-corner-case` +- `feature/bump-lib-to-1.3.0` \ No newline at end of file diff --git a/Data4LifeSDKUtils.podspec b/Data4LifeSDKUtils.podspec deleted file mode 100644 index 1499db2..0000000 --- a/Data4LifeSDKUtils.podspec +++ /dev/null @@ -1,18 +0,0 @@ -Pod::Spec.new do |s| - s.name = "Data4LifeSDKUtils" - s.version = "0.6.0" - s.summary = "Generic utilities functions used in the D4L SDK libraries" - s.homepage = "https://github.com/d4l-data4life/d4l-utils-ios.git" - s.license = { :type => 'LICENSE', :file => 'Data4LifeSDKUtils.xcframework/LICENSE' } - s.author = { "D4L data4life gGmbH" => "contact@data4life.care" } - - s.source = { :http => 'https://github.com/d4l-data4life/d4l-utils-ios/releases/download/' + s.version.to_s + '/Data4LifeSDKUtils-xcframework-' + s.version.to_s + '.zip' } - s.swift_version = '5.3' - s.platform = :ios, '13.0' - s.requires_arc = true - s.cocoapods_version = '>= 1.10.0' - - s.preserve_paths = 'Data4LifeSDKUtils.xcframework' - s.vendored_frameworks = 'Data4LifeSDKUtils.xcframework' - -end diff --git a/LICENSE b/LICENSE index ac7d596..763c514 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020 D4L data4life gGmbH +Copyright (c) 2021 D4L data4life gGmbH All rights reserved. D4L owns all legal rights, title and interest in and to the Software Development Kit ("SDK"), diff --git a/Package.swift b/Package.swift index 62c785c..57caa48 100644 --- a/Package.swift +++ b/Package.swift @@ -3,8 +3,6 @@ import PackageDescription -let frameworkBuilder = FrameworkUrlBuilder(version: "0.6.0") - let package = Package( name: "Data4LifeSDKUtils", platforms: [.iOS(.v13)], @@ -17,7 +15,7 @@ let package = Package( targets: [ .binaryTarget( name: "Data4LifeSDKUtils", - url: frameworkBuilder.url, + url: "https://d4l-ios-artifact-repository.s3.eu-central-1.amazonaws.com/d4l-data4life/d4l-utils-ios/Data4LifeSDKUtils-xcframework-v0.7.0.zip", checksum: "e4951af015f653f54d66654158765197a729249e75aa6f238397b23efa3213aa" ), .testTarget( @@ -42,21 +40,3 @@ let package = Package( ]), ] ) - -struct FrameworkUrlBuilder { - let version: String - let frameworkDomain: String = "https://github.com/d4l-data4life/d4l-utils-ios/releases/download/" -} - -extension FrameworkUrlBuilder { - var path: String { - "\(version)/" - } - var frameworkArchiveName: String { - "Data4LifeSDKUtils-xcframework-\(version).zip" - } - - var url: String { - "\(frameworkDomain)\(path)\(frameworkArchiveName)" - } -} diff --git a/README.adoc b/README.adoc new file mode 100644 index 0000000..36b191d --- /dev/null +++ b/README.adoc @@ -0,0 +1,107 @@ += Data4Life Crypto iOS SDK +:library_version: 0.7.0 +:doctype: article +:!showtitle: +:toc: macro +:toclevels: 2 +:toc-title: +:icons: font +:imagesdir: assets/images +:link-repository: https://github.com/d4l-data4life/d4l-utils-ios +ifdef::env-github[] +:warning-caption: :warning: +:caution-caption: :fire: +:important-caption: :exclamation: +:note-caption: :paperclip: +:tip-caption: :bulb: +endif::[] + +++++ +
+

+ +

+

+

Data4Life Crypto iOS

+

+

+ Swift framework for handling all of the crypto operation for the Data4Life iOS frameworks. +

+

+ Explore the docs » +

+

+ Report Bug + · + Request Feature +

+

+ + Latest version + + + Build Status + + + Platform + + + License + +

+
+++++ + +[discrete] +=== Table Of Contents +toc::[] + +== About The Project + +Swift framework for handling all of the crypto operation for the Data4Life iOS frameworks. + +== Installation + +=== Swift Package Manager + +To install with Swift package manager, select your project’s Swift Packages tab, and add our repository url, either as ssh or https url: + +[source, terminal] +---- +https://github.com/d4l-data4life/d4l-utils-ios.git +---- + +OR + +[source, terminal] +---- +git@github.com:d4l-data4life/d4l-utils-ios.git +---- + +In the next step, select the latest version, and then import the `Data4LifeSDKUtils` framework in your target. + +== Changelog + +See link:CHANGELOG.adoc[changelog] + +== Versioning + +We use http://semver.org/[Semantic Versioning] as a guideline for our versioning. + +Releases use this format: `{major}.{minor}.{patch}` + +* Breaking changes bump `{major}` and reset `{minor}` & `{patch}` +* Backward compatible changes bump `{minor}` and reset `{patch}` +* Bug fixes bump `{patch}` + +== Contributing + +You want to help or share a proposal? You have a specific problem? Read the following: + +* link:CODE-OF-CONDUCT.adoc[Code of conduct] for details on our code of conduct. +* link:CONTRIBUTING.adoc[Contributing] for details about how to report bugs and propose features. +* link:DEVELOPING.adoc[Developing] for details about our development process and how to build and test the project. + +== Copyright and License + +Copyright (c) 2021 D4L data4life gGmbH / All rights reserved. Please refer to our link:LICENSE[License] for further details. diff --git a/README.md b/README.md deleted file mode 100644 index 2111f41..0000000 --- a/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# d4l-util-ios -Utilities library for iOS SDK projects - -[![CocoaPods Compatible](https://img.shields.io/badge/pod-v0.6.0-blue.svg)](https://github.com/CocoaPods/CocoaPods) -[![Swift Package Manager compatible](https://img.shields.io/badge/SPM-compatible-brightgreen.svg?style=flat&colorA=28a745&&colorB=4E4E4E)](https://github.com/apple/swift-package-manager) -[![License](https://img.shields.io/badge/license-PRIVATE-blue.svg)](https://github.com/d4l-data4life/d4l-utils-ios/blob/main/LICENSE) - -## Usage -### Requirements -* Xcode 12.4+ -* iOS 13.0+ -* Swift 5.3+ - -## Management -SDK is handled by [Fastlane](https://fastlane.tools/) and all of the available functions are available in the [README](fastlane/README.md). - -## Installation - -#### CocoaPods - -To install with [CocoaPods](https://cocoapods.org/) add the following line to the podfile. - -```ruby -pod 'Data4LifeSDKUtils', '~> 0.6.0' -``` - -#### Swift Package Manager - -To install with [Swift Package Manager](https://swift.org/package-manager/) add this package as a dependency in `Package.swift`: - -```swift -.package(url: "https://github.com/d4l-data4life/d4l-utils-ios.git", .upToNextMinor(from: "0.5.0")) -``` - -## Building - -### Install Fastlane and other dependencies using Bundler - -```sh -bundle install -``` -*Note*: Check [official page](https://bundler.io/) for info on how to install Bundler. - -#### Build framework -*Note*: Use fastlane to build the utils xcframework. -```sh -fastlane ios build_xcframework -``` diff --git a/Sources/SDKUtils/SDKUtils.h b/Sources/SDKUtils/SDKUtils.h index 83159d1..c1fce96 100644 --- a/Sources/SDKUtils/SDKUtils.h +++ b/Sources/SDKUtils/SDKUtils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2020 D4L data4life gGmbH +// Copyright (c) 2021 D4L data4life gGmbH // All rights reserved. // // D4L owns all legal rights, title and interest in and to the Software Development Kit ("SDK"), diff --git a/Sources/SDKUtils/Source/ByteCountable.swift b/Sources/SDKUtils/Source/ByteCountable.swift index 4d4ddc8..04cbb80 100644 --- a/Sources/SDKUtils/Source/ByteCountable.swift +++ b/Sources/SDKUtils/Source/ByteCountable.swift @@ -1,4 +1,4 @@ -// Copyright (c) 2020 D4L data4life gGmbH +// Copyright (c) 2021 D4L data4life gGmbH // All rights reserved. // // D4L owns all legal rights, title and interest in and to the Software Development Kit ("SDK"), diff --git a/Sources/SDKUtils/Source/Data+ByteCountable.swift b/Sources/SDKUtils/Source/Data+ByteCountable.swift index 56e038e..0c59e92 100644 --- a/Sources/SDKUtils/Source/Data+ByteCountable.swift +++ b/Sources/SDKUtils/Source/Data+ByteCountable.swift @@ -1,4 +1,4 @@ -// Copyright (c) 2020 D4L data4life gGmbH +// Copyright (c) 2021 D4L data4life gGmbH // All rights reserved. // // D4L owns all legal rights, title and interest in and to the Software Development Kit ("SDK"), diff --git a/Sources/SDKUtils/Source/Data+Cryptography.swift b/Sources/SDKUtils/Source/Data+Cryptography.swift index 37aec25..55e5b96 100644 --- a/Sources/SDKUtils/Source/Data+Cryptography.swift +++ b/Sources/SDKUtils/Source/Data+Cryptography.swift @@ -1,4 +1,4 @@ -// Copyright (c) 2020 D4L data4life gGmbH +// Copyright (c) 2021 D4L data4life gGmbH // All rights reserved. // // D4L owns all legal rights, title and interest in and to the Software Development Kit ("SDK"), diff --git a/Sources/SDKUtils/Source/DataValidator.swift b/Sources/SDKUtils/Source/DataValidator.swift index b0d1f23..e018c6d 100644 --- a/Sources/SDKUtils/Source/DataValidator.swift +++ b/Sources/SDKUtils/Source/DataValidator.swift @@ -1,4 +1,4 @@ -// Copyright (c) 2020 D4L data4life gGmbH +// Copyright (c) 2021 D4L data4life gGmbH // All rights reserved. // // D4L owns all legal rights, title and interest in and to the Software Development Kit ("SDK"), diff --git a/Sources/SDKUtils/Source/MIMEType.swift b/Sources/SDKUtils/Source/MIMEType.swift index 6e49505..9de5df2 100644 --- a/Sources/SDKUtils/Source/MIMEType.swift +++ b/Sources/SDKUtils/Source/MIMEType.swift @@ -1,4 +1,4 @@ -// Copyright (c) 2020 D4L data4life gGmbH +// Copyright (c) 2021 D4L data4life gGmbH // All rights reserved. // // D4L owns all legal rights, title and interest in and to the Software Development Kit ("SDK"), diff --git a/Tests/SDKUtilsTests/DataCryptographyTests.swift b/Tests/SDKUtilsTests/DataCryptographyTests.swift index b9b2263..8d96b0e 100644 --- a/Tests/SDKUtilsTests/DataCryptographyTests.swift +++ b/Tests/SDKUtilsTests/DataCryptographyTests.swift @@ -1,4 +1,4 @@ -// Copyright (c) 2020 D4L data4life gGmbH +// Copyright (c) 2021 D4L data4life gGmbH // All rights reserved. // // D4L owns all legal rights, title and interest in and to the Software Development Kit ("SDK"), diff --git a/Tests/SDKUtilsTests/DataValidatorTests.swift b/Tests/SDKUtilsTests/DataValidatorTests.swift index 7ae9378..d606472 100644 --- a/Tests/SDKUtilsTests/DataValidatorTests.swift +++ b/Tests/SDKUtilsTests/DataValidatorTests.swift @@ -1,4 +1,4 @@ -// Copyright (c) 2020 D4L data4life gGmbH +// Copyright (c) 2021 D4L data4life gGmbH // All rights reserved. // // D4L owns all legal rights, title and interest in and to the Software Development Kit ("SDK"), diff --git a/Tests/SDKUtilsTests/MIMETypeTests.swift b/Tests/SDKUtilsTests/MIMETypeTests.swift index 89fb3cd..a0c62a5 100644 --- a/Tests/SDKUtilsTests/MIMETypeTests.swift +++ b/Tests/SDKUtilsTests/MIMETypeTests.swift @@ -1,4 +1,4 @@ -// Copyright (c) 2020 D4L data4life gGmbH +// Copyright (c) 2021 D4L data4life gGmbH // All rights reserved. // // D4L owns all legal rights, title and interest in and to the Software Development Kit ("SDK"), diff --git a/assets/images/badge-license.svg b/assets/images/badge-license.svg new file mode 100644 index 0000000..eb90cd0 --- /dev/null +++ b/assets/images/badge-license.svg @@ -0,0 +1 @@ +license: PRIVATElicensePRIVATE \ No newline at end of file diff --git a/assets/images/badge-platform-support.svg b/assets/images/badge-platform-support.svg new file mode 100644 index 0000000..4f61ec6 --- /dev/null +++ b/assets/images/badge-platform-support.svg @@ -0,0 +1 @@ +Platform: iOSPlatformiOS \ No newline at end of file diff --git a/assets/images/badge-release-latest.svg b/assets/images/badge-release-latest.svg new file mode 100644 index 0000000..79ecec9 --- /dev/null +++ b/assets/images/badge-release-latest.svg @@ -0,0 +1 @@ +Release: v1.7.0Releasev1.7.0 \ No newline at end of file diff --git a/assets/images/badges.adoc b/assets/images/badges.adoc new file mode 100644 index 0000000..a1b0459 --- /dev/null +++ b/assets/images/badges.adoc @@ -0,0 +1,31 @@ += How to create badges + +We use link:https://shields.io/[Shields.io] to generate our Badges. Please use the following links to document and update currently used badges. +Follow the links and download the svg files and place them in the projects `assets/images` folder. + +== Download badges + +Simply use `curl` to download badges by providing the `url` and `filename` + +[source, bash] +---- +curl link -s -o filename +---- + +== Badge sources + +:link-badge-release: https://img.shields.io/badge/Release-0.1.0-blueviolet.svg +Version image:{link-badge-release}[Latest release]:: +`curl {link-badge-release} -s -o badge-release-latest.svg` + +:link-badge-platform: https://img.shields.io/badge/Platform-Android%20•%20iOS%20•%20JVM%20•%20JS-blue.svg +Platform image:{link-badge-platform}[Platform]:: +`curl {link-badge-platform} -s -o badge-platform-support.svg` + +:link-badge-license: https://img.shields.io/badge/License-PRIVATE-lightgrey.svg +License image:{link-badge-license}[License]:: +`curl {link-badge-license} -s -o badge-license.svg` + +== License + +Shields is licensed under *Creative Commons Zero v1.0 Universal* (2021-02-16) diff --git a/assets/images/d4l-logo.svg b/assets/images/d4l-logo.svg new file mode 100644 index 0000000..fb64f8a --- /dev/null +++ b/assets/images/d4l-logo.svg @@ -0,0 +1,9 @@ + + + 0. Logo/Icon/D4L CovHub + + + + + + diff --git a/fastlane/Fastfile b/fastlane/Fastfile index f0e7519..5ce6478 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -1,204 +1,255 @@ default_platform :ios +repository = "d4l-data4life/d4l-utils-ios" project = "Data4LifeSDKUtils" scheme = "Data4LifeSDKUtils" -repository = "d4l-data4life/d4l-utils-ios" -framework_binary_path = "build/" + project + ".framework.zip" -podspec_path = '../Data4LifeSDKUtils.podspec' -podspecs_repo_name = 'd4l-data4life' -podspecs_repo_url = 'https://github.com/d4l-data4life/d4l-cocoapods-specs.git' -device = "iPhone 13" +name = "Data4LifeSDKUtils" +buildPath = "build/DerivedData" platform :ios do + desc "Run unit tests and upload code coverage" lane :test do scan( - project: "Data4LifeSDKUtils.xcodeproj", - scheme: "Data4LifeSDKUtils", - derived_data_path: "build/DerivedData", - devices: device, + scheme: scheme, + derived_data_path: buildPath, code_coverage: true, clean: true ) end - desc "Package and release framework" + desc "Lint sources using swiftlint and check the license headers" + lane :lint do |options| + autocorrect = options[:autocorrect] == true + lint_headers(autocorrect) + swiftlint( + mode: autocorrect ? :autocorrect : :lint, + config_file: ".swiftlint.yml", + strict: !autocorrect + ) + end + + desc "Check license headers" + lane :lint_headers do |options| + autocorrect = options[:autocorrect] == true + files = Dir.chdir("..") do + files = Dir.glob('{Sources/SDKUtils,Tests/SDKUtilsTests}/**/*.{swift,h,cpp,m}') + end + license = "./LICENSE" + + lint_source_for_license_headers( + license: license, + files: files, + autocorrect: autocorrect, + strict: !autocorrect + ) + end + + desc "Prepare release" desc "#### Options" desc " * **`version`** (required): The new version of the framework" desc " * **`api_token`** (required): Github API token" - desc " * **`allow_dirty_branch`**: Allows the git branch to be dirty before continuing. Defaults to false" - desc " * **`remote`**: The name of the git remote. Defaults to `origin`. (`DEPLOY_REMOTE`)" - desc " * **`allow_branch`**: The name of the branch to build from. Defaults to `main`. (`DEPLOY_BRANCH`)" - desc " * **`skip_git_pull`**: Skips pulling the git remote. Defaults to false" - desc " * **`is_prerelease`**: Marks GitHub release as Pre-release. Defaults to false" - lane :release_framework do | options | - if options[:allow_dirty_branch] != true - ensure_git_status_clean - end - + lane :prepare_release do | options | if !options[:version] - raise "No version specified!".red + UI.user_error!("Please add required parameter version (eg. version:\"1.0.0\"") end if !options[:api_token] - raise "No api_token specified!".red + UI.user_error!("Please add required parameter version (eg. api_token:\"xxxxxxxxx\"") end version = options[:version] - is_prerelease = options[:is_prerelease] ||= false + apiToken = options[:api_token] + remote = "origin" + changelog = parseAndCheckChangelog("../CHANGELOG.adoc", version) + archiveUtilsPath = utilsFrameworkArchivePath(version) + + unless changelog + UI.user_error!("Please add all changes of the version to the CHANGELOG.adoc file") + end + + update_plist_versions(version: version) + update_readme_versions(version: version) + update_badge(version: version) + build_utils(version: version) + + Dir.chdir("..") do + upload_archive_to_s3(repository, archiveUtilsPath) + update_swift_package_file(repository, archiveUtilsPath) + end - remote = options[:remote] ? options[:remote] : (ENV["DEPLOY_REMOTE"] ? ENV["DEPLOY_REMOTE"] : "origin") - allowed_branch = options[:allow_branch] ? options[:allow_branch] : (ENV["DEPLOY_BRANCH"] ? ENV["DEPLOY_BRANCH"] : "release/#{version}") - ensure_git_branch(branch: allowed_branch) + # Ask for confirmation for github + if prompt(text: "#{version} has been prepped for release. If you have any additional changes you would like to make to the README or CHANGELOG, please do those before continuing. Would you like to commit, and push #{version} to #{remote}?".green, boolean: true, ci_input:"y") - if options[:skip_git_pull] != true - sh("git pull #{remote} #{allowed_branch}") - end + # Push all generated/modified files + git_add + git_commit( + path: ".", + message: "Preparing for the #{version} release" + ) - # Parse changelog data - changelog_path = options[:changelog_path] ? options[:changelog_path] : "../CHANGELOG.md" - changelog_data = File.read(changelog_path) - # Try to find all markdown headers and split - changelog_sections = changelog_data.split(/\#{2,3}\s/) - # Look out for new section of the newest version - current_changelog_index = changelog_sections.index { |h| h.start_with?("[#{version}]")} + push_to_git_remote( + remote: remote, + tags: false + ) - unless current_changelog_index - UI.error("Please add all changes of the version to the CHANGELOG.md file") + # Make new draft release to GitHub + create_github_draft( + version: version, + api_token: apiToken, + changelog: changelog, + archive_path: archiveUtilsPath + ) + else + UI.message("When finished, commit your changes.") end + end - # Get all split for this version and combine them again to one text - changelog_header_indices = changelog_sections.each_with_index.select {|s, _| s.match(/^\[([0-9]+)\.([0-9]+)\.([0-9]+)\-?([0-9a-zA-Z]*)\.?([0-9a-zA-Z]*)\]/) }.map(&:last) - next_changelog_index = changelog_header_indices.index { |h| h == current_changelog_index } + 1 - changelog = "### " + changelog_sections[current_changelog_index + 1...changelog_header_indices[next_changelog_index]].join("### ") + desc "Prepare snapshot" + lane :prepare_snapshot do + + snapshotName = current_git_branch().split("/").last + remote = "origin" + changelog = "### #{snapshotName}" + archiveUtilsPath = utilsFrameworkArchivePath(snapshotName) - # Ask for confirmation - if prompt(text: "#{version} has been prepped for release. If you have any additional changes you would like to make to the README or CHANGELOG, please do those before continuing. Would you like to commit, tag, and push #{version} to #{remote}?".green, boolean: true, ci_input:"y") + build_utils(version: snapshotName) + + Dir.chdir("..") do + upload_archive_to_s3(repository, archiveUtilsPath) + update_swift_package_file(repository, archiveUtilsPath) + end - # Update version in different places - update_plist_versions(sdk_version: version) - update_readme_versions(version: version) + # Ask for confirmation for github + if prompt(text: "#{snapshotName} has been prepped for snapshot-release. Would you like to commit, and push #{snapshotName} to #{remote}?".green, boolean: true, ci_input:"y") - # Add and commit all of the generated files + # Push all generated/modified files git_add git_commit( path: ".", - message: "Preparing for the #{version} release" + message: "Preparing for the #{snapshotName} release" ) - # Push latest changes push_to_git_remote( remote: remote, tags: false ) + else + UI.message("When finished, commit your changes.") + end + end - # Create and push new version tag - add_git_tag(tag: "#{version}") - push_git_tags(tag: "#{version}") + desc "Build xcframework for distribution" + lane :build_utils do |options| + if options[:version] == nil + UI.user_error!("Please add required parameter version (eg. version:\"1.0.0\"") + end - build_xcframework(version: version) - archiveUtilsPath = utilsXcFrameworkPath(version) + xcframeworkPath = "#{name}.xcframework" - # Post new release to GitHub - gh_release( - version: version, - api_token:options[:api_token], - changelog: changelog, - is_prerelease: is_prerelease, - asset1: archiveUtilsPath - ) + build_xcframework(schemeName: scheme, + frameworkName: name, + outputPath: xcframeworkPath) + + Dir.chdir("..") do + root = Dir.pwd + configuration = "Release" + buildPath = "xcbuild" - update_podspec_version(version: version) - push_podspec + archiveUtilsPath = utilsFrameworkArchivePath(options[:version]) + if File.exist?(archiveUtilsPath) + sh "rm #{archiveUtilsPath}" + end - else - Helper.log.info "When finished, commit your changes.".red + sh "zip -r #{archiveUtilsPath} #{xcframeworkPath}" + sh "rm -rf #{xcframeworkPath}" end end - desc "Build xcframework for distribution" + desc "Build any project xcframework" lane :build_xcframework do |options| - if options[:version] == nil - raise "Missing release version".red + if options[:schemeName] == nil + raise "Missing scheme name".red + end + if options[:frameworkName] == nil + raise "Missing framework name".red + end + if options[:outputPath] == nil + raise "Missing output path".red end Dir.chdir("..") do root = Dir.pwd - xcFrameworkPath = "#{project}.xcframework" configuration = "Release" buildPath = "xcbuild" - archiveUtilsPath = utilsXcFrameworkPath(options[:version]) + + schemeName = options[:schemeName] + frameworkName = options[:frameworkName] + outputPath = options[:outputPath] if File.exist?(buildPath) sh "rm -rf #{buildPath}" end - if File.exist?(xcFrameworkPath) - sh "rm -rf #{xcFrameworkPath}" - end - if File.exist?(archiveUtilsPath) - sh "rm #{archiveUtilsPath}" + if File.exist?(outputPath) + sh "rm -rf #{outputPath}" end - sh "xcodebuild archive -scheme #{scheme} -configuration #{configuration} -archivePath #{buildPath}/#{configuration}/#{project}-iphonesimulator.xcarchive -destination 'generic/platform=iOS Simulator' SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES SWIFT_SERIALIZE_DEBUGGING_OPTIONS=NO" - sh "xcodebuild archive -scheme #{scheme} -configuration #{configuration} -archivePath #{buildPath}/#{configuration}/#{project}-iphoneos.xcarchive -destination 'generic/platform=iOS' SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES SWIFT_SERIALIZE_DEBUGGING_OPTIONS=NO" + sh "rm -rf #{outputPath}" + sh "xcodebuild archive -scheme #{schemeName} -configuration #{configuration} -archivePath #{buildPath}/#{configuration}/#{frameworkName}-iphonesimulator.xcarchive -destination 'generic/platform=iOS Simulator' SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES SWIFT_SERIALIZE_DEBUGGING_OPTIONS=NO" + sh "xcodebuild archive -scheme #{schemeName} -configuration #{configuration} -archivePath #{buildPath}/#{configuration}/#{frameworkName}-iphoneos.xcarchive -destination 'generic/platform=iOS' SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES SWIFT_SERIALIZE_DEBUGGING_OPTIONS=NO" sh "xcodebuild -create-xcframework \ - -framework #{buildPath}/#{configuration}/#{project}-iphonesimulator.xcarchive/Products/Library/Frameworks/#{project}.framework \ - -framework #{buildPath}/#{configuration}/#{project}-iphoneos.xcarchive/Products/Library/Frameworks/#{project}.framework \ - -output #{xcFrameworkPath}" - - sh "cp LICENSE #{xcFrameworkPath}" - sh "zip -r #{archiveUtilsPath} #{xcFrameworkPath}" - sh "rm -rf #{xcFrameworkPath}" + -framework #{buildPath}/#{configuration}/#{frameworkName}-iphonesimulator.xcarchive/Products/Library/Frameworks/#{frameworkName}.framework \ + -framework #{buildPath}/#{configuration}/#{frameworkName}-iphoneos.xcarchive/Products/Library/Frameworks/#{frameworkName}.framework \ + -output #{outputPath}" end end - desc "Upload to a github release" - lane :gh_release do |options| + desc "Upload to a github release draft" + lane :create_github_draft do |options| if options[:version] == nil - raise "Missing release version".red + UI.user_error!("Please add required parameter version (eg. version:\"1.0.0\"") end if options[:api_token] == nil - raise "Missing api token".red + UI.user_error!("Please add required parameter api_token (eg. api_token:\"xxxxxxxxxx\"") end - - if options[:asset1] == nil - raise "Missing asset".red - end - - isPrerelease = options[:is_prerelease] - if isPrerelease == nil - isPrerelease = true + + if options[:archive_path] == nil + UI.user_error!("Please add required parameter archive_path (eg. archive_path:\"xxxxxxxxxx\"") end changelog = options[:changelog] if changelog == nil - changelog = "Pre-release" + changelog = "### #{version}" end + version = options[:version] + apiToken = options[:api_token] + archivePath = options[:archive_path] + set_github_release( repository_name: repository, - api_token: options[:api_token], - name: "#{options[:version]}", - tag_name: options[:version], + api_token: apiToken, + name: version, + tag_name: version, description: changelog, - is_prerelease: isPrerelease, - upload_assets: [options[:asset1]] + is_draft: true, + upload_assets: [archivePath] ) end - desc "Update AppStore and utils version number in project plists" + desc "Update version number in project plists" lane :update_plist_versions do |options| - if options[:sdk_version] == nil - raise "Missing SDK version".red + if options[:version] == nil + UI.user_error!("Please add required parameter version (eg. version:\"1.0.0\"") end - sdk_version = options[:sdk_version] - app_store_version = sdk_version.split("-").first + version = options[:version] + numberOnlyVersion = version.split("-").first.delete_prefix("v") - if app_store_version.match(/\A\d+(?:\.\d+)*\z/) == nil - raise "Could not generate proper AppStore version format".red + if numberOnlyVersion.match(/\A\d+(?:\.\d+)*\z/) == nil + raise "Could not generate proper version format".red end plists = ["Sources/SDKUtils/Info.plist", "Tests/SDKUtilsTests/Info.plist"] @@ -207,95 +258,88 @@ platform :ios do xcodeproj: "#{project}.xcodeproj", plist_path: path, block: proc do |plist| - plist["CFBundleShortVersionString"] = app_store_version + plist["CFBundleShortVersionString"] = numberOnlyVersion end ) } end - desc "Update podspec version" - lane :update_podspec_version do | options | - UI.user_error!("Could not find podspec file at path #{podspec_path}") unless File.exist?(podspec_path) - + desc "Update version numbers in README.adoc" + lane :update_readme_versions do | options | if !options[:version] raise "No version specified!".red end - new_version = options[:version] + version = options[:version] + path = "../README.adoc" + numberOnlyVersion = version.split("-").first.delete_prefix("v") + + if numberOnlyVersion.match(/\A\d+(?:\.\d+)*\z/) == nil + raise "Could not generate proper AppStore version format".red + end - podspec_content = File.read(podspec_path) - updated = podspec_content.gsub(/"([0-9]+)\.([0-9]+)\.([0-9]+)\-?([0-9a-zA-Z]*)\.?([0-9a-zA-Z]*)"/, "\"#{new_version}\"") - File.write(podspec_path, updated) + readmeData = File.read(path) + readmeDataUpdated = readmeData.gsub(/ [0-9]+\.[0-9]+\.[0-9]+/, " #{numberOnlyVersion}") + File.write(path, readmeDataUpdated) end - desc "Push new podspec to repo" - lane :push_podspec do - # pod_push fastlane action does not support private switch - # pod_push(path: "./Data4LifeFHIR.podspec", repo: "gesundheitscloud", allow_warnings: true) - repo_list = sh "bundle exec pod repo list" - if !repo_list.include? podspecs_repo_name - sh "bundle exec pod repo add #{podspecs_repo_name} #{podspecs_repo_url}" + desc "Update readme badge" + lane :update_badge do |options| + if options[:version] == nil + UI.user_error!("Please add required parameter version (eg. version:\"1.0.0\"") end + + Dir.chdir("..") do + sh "curl https://img.shields.io/badge/Release-#{options[:version]}-blueviolet.svg -s -o assets/images/badge-release-latest.svg" + end + end - sh "bundle exec pod repo push #{podspecs_repo_name} #{podspec_path} --allow-warnings" + def utilsFrameworkArchivePath(version) + return "Data4LifeSDKUtils-xcframework-#{version}.zip" end - desc "Lint sources using swiftlint and check the license headers" - lane :lint do |options| - autocorrect = options[:autocorrect] == true + def parseAndCheckChangelog(path, version) - files = Dir.chdir("..") do - files = Dir.glob('{Sources/SDKUtils/Source,Tests/SDKUtilsTests}/**/*.{swift,h,cpp,m}') - end + changelogData = File.read(path) - swiftlint( - files: files, - mode: autocorrect ? :autocorrect : :lint, - config_file: ".swiftlint.yml", - strict: !autocorrect - ) - end + changelogVersionsSeparator = "== link:{link-repository}/releases/tag/v" + changelogVersion = version.delete_prefix("v") + changelogSections = changelogData.split(changelogVersionsSeparator) + currentVersionSectionIndex = changelogSections.index { |section| section.include?("[#{changelogVersion}]")} - desc "Check license headers" - lane :lint_headers do |options| - autocorrect = options[:autocorrect] == true - files = Dir.chdir("..") do - files = Dir.glob('{Sources/SDKUtils/Source,Tests/SDKUtilsTests}/**/*.{swift,h,cpp,m}') + unless currentVersionSectionIndex + return nil end - license = "./LICENSE" - lint_source_for_license_headers( - license: license, - files: files, - autocorrect: autocorrect, - strict: !autocorrect - ) + changelog = "## #{version}\n" + changelogSections[currentVersionSectionIndex].lines[1..-1].join + return changelog.gsub("=", "#") end - desc "Update version numbers in README.md" - lane :update_readme_versions do | options | - if !options[:version] - raise "No version specified!".red - end + def update_swift_package_file(repository, path) + sh "swift package compute-checksum #{path}" do |status, result| - readme_path = "../README.md" - sdk_version = options[:version] - app_store_version = sdk_version.split("-").first + checksum = result.chop + url = "https://d4l-ios-artifact-repository.s3.eu-central-1.amazonaws.com/#{s3_key(repository, path)}" - if app_store_version.match(/\A\d+(?:\.\d+)*\z/) == nil - raise "Could not generate proper AppStore version format".red + packageSwiftData = File.read("Package.swift") + updatedPackageSwiftData = packageSwiftData.gsub(/url: \"[a-zA-Z0-9:\-\/_.,\\()]+xcframework[a-zA-Z0-9:\-\/_.,\\()]+\"/, "url: \"#{url}\"") + updatedPackageSwiftData = updatedPackageSwiftData.gsub(/checksum: \"[a-zA-Z0-9]+\"/, "checksum: \"#{checksum}\"") + + File.write("Package.swift", updatedPackageSwiftData) end + end - readme_contents = File.read(readme_path) - # Update CocoaPods version number (pattern: `v1.0.0-`) - updated = readme_contents.gsub(/v([0-9]+)\.([0-9]+)\.([0-9]+)-/, "v#{app_store_version}-") - # Update GitHub pages version number (pattern: `/1.0.0)`) - updated = updated.gsub(/\/([0-9]+)\.([0-9]+)\.([0-9]+)\)/, "\/#{app_store_version}\)") - File.write(readme_path, updated) - end + def upload_archive_to_s3(repository, path) + sh "aws s3api put-object --bucket d4l-ios-artifact-repository --key #{s3_key(repository, path)} --body #{path}" + end - def utilsXcFrameworkPath(version) - return "Data4LifeSDKUtils-xcframework-#{version}.zip" + def s3_key(repository, path) + return "#{repository}/#{path}" end + def current_git_branch() + sh "git branch --show-current" do |status, result| + return result.chop + end + end end