From 8dc9ace58f040dd1d538939a4b416a90d785fe61 Mon Sep 17 00:00:00 2001 From: Franco Meloni Date: Sat, 4 Jan 2020 17:05:23 +0000 Subject: [PATCH] Add rocket to the project --- Package.resolved | 51 +++++++++++++++++++++++++-- Package.swift | 89 +++++++++++++++++------------------------------- Rakefile | 29 ++-------------- 3 files changed, 81 insertions(+), 88 deletions(-) diff --git a/Package.resolved b/Package.resolved index 62b3d4b0f..01e434a2f 100644 --- a/Package.resolved +++ b/Package.resolved @@ -28,13 +28,22 @@ "version": "1.2.0" } }, + { + "package": "Logger", + "repositoryURL": "https://github.com/shibapm/Logger", + "state": { + "branch": null, + "revision": "53c3ecca5abe8cf46697e33901ee774236d94cce", + "version": "0.2.3" + } + }, { "package": "Nimble", "repositoryURL": "https://github.com/Quick/Nimble.git", "state": { "branch": null, - "revision": "6abeb3f5c03beba2b9e4dbe20886e773b5b629b6", - "version": "8.0.4" + "revision": "b02b00b30b6353632aa4a5fb6124f8147f7140c0", + "version": "8.0.5" } }, { @@ -42,10 +51,19 @@ "repositoryURL": "https://github.com/AliSoftware/OHHTTPStubs.git", "state": { "branch": "feature/spm-support", - "revision": "fda9902f8c5c4170c6914d7dc845174e8c75bf92", + "revision": "4726e07728b8bff3152a8c31c34a0bb7cc2aef19", "version": null } }, + { + "package": "PackageConfig", + "repositoryURL": "https://github.com/shibapm/PackageConfig.git", + "state": { + "branch": null, + "revision": "fd0829aac9851434b3d2db0890e27bc489fc973a", + "version": "0.12.2" + } + }, { "package": "Quick", "repositoryURL": "https://github.com/Quick/Quick.git", @@ -64,6 +82,15 @@ "version": "6.1.0" } }, + { + "package": "Rocket", + "repositoryURL": "https://github.com/shibapm/Rocket", + "state": { + "branch": null, + "revision": "623cb4ccf55d708d082516ccd5cfea3dac8f9032", + "version": "1.0.0" + } + }, { "package": "RxSwift", "repositoryURL": "https://github.com/ReactiveX/RxSwift.git", @@ -72,6 +99,24 @@ "revision": "b3e888b4972d9bc76495dd74d30a8c7fad4b9395", "version": "5.0.1" } + }, + { + "package": "SwiftShell", + "repositoryURL": "https://github.com/kareman/SwiftShell", + "state": { + "branch": null, + "revision": "fb7fc2c9ad8811caf324431a508fb79e3fb74f99", + "version": "5.0.1" + } + }, + { + "package": "Yams", + "repositoryURL": "https://github.com/jpsim/Yams", + "state": { + "branch": null, + "revision": "c947a306d2e80ecb2c0859047b35c73b8e1ca27f", + "version": "2.0.0" + } } ] }, diff --git a/Package.swift b/Package.swift index aeaec0721..6e057cd4d 100644 --- a/Package.swift +++ b/Package.swift @@ -1,62 +1,6 @@ // swift-tools-version:5.0 -// This Package.swift is split for production use and development separately. -// Basically SPM fetches testing dependencies even though they are not needed for the main target. And because -// of that, sometimes the build fails as the build system wants to build XCTest or other frameworks for main bundle... -// TL;DR waiting for SE-0226 to be implemented: https://github.com/apple/swift-evolution/blob/master/proposals/0226-package-manager-target-based-dep-resolution.md -// -// In the meantime: -// - when you include our library as a dependency SPM won't fetch testing libraries -// - when you want to test the library use `TEST=1 swift test` and it should work properly import PackageDescription -import class Foundation.ProcessInfo - -let shouldTest = ProcessInfo.processInfo.environment["TEST"] == "1" - -func resolveDependencies() -> [Package.Dependency] { - let baseDependencies: [Package.Dependency] = [ - .package(url: "https://github.com/Alamofire/Alamofire.git", .exact("5.0.0-rc.3")), - .package(url: "https://github.com/Moya/ReactiveSwift.git", .upToNextMajor(from: "6.1.0")), - .package(url: "https://github.com/ReactiveX/RxSwift.git", .upToNextMajor(from: "5.0.0")) - ] - - if shouldTest { - let testDependencies: [Package.Dependency] = [ - .package(url: "https://github.com/Quick/Quick.git", .upToNextMajor(from: "2.0.0")), - .package(url: "https://github.com/Quick/Nimble.git", .upToNextMajor(from: "8.0.0")), - .package(url: "https://github.com/AliSoftware/OHHTTPStubs.git", .branch("feature/spm-support")) - ] - - return baseDependencies + testDependencies - } else { - return baseDependencies - } -} - -func resolveTargets() -> [Target] { - let baseTargets: [Target] = [ - .target(name: "Moya", dependencies: ["Alamofire"]), - .target(name: "ReactiveMoya", dependencies: ["Moya", "ReactiveSwift"]), - .target(name: "RxMoya", dependencies: ["Moya", "RxSwift"]) - ] - - if shouldTest { - let testTargets: [Target] = [ - .testTarget(name: "MoyaTests", dependencies: [ - "Moya", - "RxMoya", - "ReactiveMoya", - "Quick", - "Nimble", - "OHHTTPStubsSwift" - ]) - ] - - return baseTargets + testTargets - } else { - return baseTargets - } -} let package = Package( name: "Moya", @@ -71,6 +15,35 @@ let package = Package( .library(name: "ReactiveMoya", targets: ["ReactiveMoya"]), .library(name: "RxMoya", targets: ["RxMoya"]) ], - dependencies: resolveDependencies(), - targets: resolveTargets() + dependencies: [ + .package(url: "https://github.com/Alamofire/Alamofire.git", .exact("5.0.0-rc.3")), + .package(url: "https://github.com/Moya/ReactiveSwift.git", .upToNextMajor(from: "6.1.0")), + .package(url: "https://github.com/ReactiveX/RxSwift.git", .upToNextMajor(from: "5.0.0")), + .package(url: "https://github.com/Quick/Quick.git", .upToNextMajor(from: "2.0.0")), // dev + .package(url: "https://github.com/Quick/Nimble.git", .upToNextMajor(from: "8.0.0")), // dev + .package(url: "https://github.com/AliSoftware/OHHTTPStubs.git", .branch("feature/spm-support")), // dev + .package(url: "https://github.com/shibapm/Rocket", .upToNextMajor(from: "1.0.0")), + ], + targets: [ + .target(name: "Moya", dependencies: ["Alamofire"]), + .target(name: "ReactiveMoya", dependencies: ["Moya", "ReactiveSwift"]), + .target(name: "RxMoya", dependencies: ["Moya", "RxSwift"]), + .testTarget(name: "MoyaTests", dependencies: ["Moya", "RxMoya", "ReactiveMoya", "Quick","Nimble", "OHHTTPStubsSwift"]) // dev + ] ) + +#if canImport(PackageConfig) +import PackageConfig + +let config = PackageConfiguration([ + "rocket": [ + "before": [ + "scripts/update_changelog.sh", + "scripts/update_podspec.sh" + ], + "after": [ + "rake create_release\\[\"$VERSION\"\\]" + ] + ], +]).write() +#endif diff --git a/Rakefile b/Rakefile index e2157eb03..b38eca15d 100644 --- a/Rakefile +++ b/Rakefile @@ -151,35 +151,10 @@ namespace :test do end desc 'Release a version, specified as an argument.' -task :release, :version do |task, args| - version = args[:version] - release_date = Time.now.strftime("%Y-%m-%d") - # Needs a X.Y.Z-text format. - abort "You must specify a version in semver format." if version.nil? || version.scan(/\d+\.\d+\.\d+(-\w+\.\d+)?/).length == 0 - - puts "Updating podspec." - filename = "Moya.podspec" - contents = File.read(filename) - contents.gsub!(/s\.version\s*=\s"\d+\.\d+\.\d+(-\w+\.\d)?"/, "s.version = \"#{version}\"") - File.open(filename, 'w') { |file| file.puts contents } - - puts "Updating changelog." - changelog_filename = "CHANGELOG.md" - changelog = File.read(changelog_filename) - changelog.gsub!(/# Next/, "# Next\n\n# [#{version}] - #{release_date}") - File.open(changelog_filename, 'w') { |file| file.puts changelog } - - puts "Committing, tagging, and pushing." - message = "Releasing version #{version}." - sh "git commit -am '#{message}'" - sh "git tag #{version} -m '#{message}'" - sh "git push --follow-tags" - - puts "Pushing to CocoaPods trunk." - sh "bundle exec pod trunk push Moya.podspec --allow-warnings" - +task :create_release, :version do |task, args| puts "Pushing as a GitHub Release." require 'octokit' + version = args[:version] Octokit::Client.new(netrc: true). create_release('Moya/Moya', version,