forked from airbnb/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from RakuyoKit/feature/synchronize-upstream
Feature/synchronize-upstream
- Loading branch information
Showing
9 changed files
with
283 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.build | ||
.swiftpm | ||
.DS_Store | ||
.DS_Store | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source 'https://rubygems.org' do | ||
gem "rake", "~> 13.0.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
rake (13.0.6) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
rake (~> 13.0.0)! | ||
|
||
BUNDLED WITH | ||
2.1.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
require 'json' | ||
require 'net/http' | ||
require 'json' | ||
require 'tempfile' | ||
|
||
namespace :swift do | ||
desc 'Lints swift files' | ||
task :lint do | ||
sh 'swift package --allow-writing-to-package-directory format --lint' | ||
end | ||
|
||
desc 'Formats swift files' | ||
task :format do | ||
sh 'swift package --allow-writing-to-package-directory format' | ||
end | ||
end | ||
|
||
namespace :update do | ||
desc 'Updates SwiftFormat to the latest version' | ||
task :swiftformat do | ||
# Find the most recent release of SwiftFormat in the https://github.com/calda/SwiftFormat repo. | ||
response = Net::HTTP.get(URI('https://api.github.com/repos/calda/SwiftFormat/releases/latest')) | ||
latest_release_info = JSON.parse(response) | ||
|
||
latest_version_number = latest_release_info['tag_name'] | ||
|
||
# Download the artifact bundle for the latest release and compute its checksum. | ||
temp_dir = Dir.mktmpdir | ||
artifact_bundle_url = "https://github.com/calda/SwiftFormat/releases/download/#{latest_version_number}/swiftformat.artifactbundle.zip" | ||
artifact_bundle_zip_path = "#{temp_dir}/swiftformat.artifactbundle.zip" | ||
|
||
sh "curl #{artifact_bundle_url} -L --output #{artifact_bundle_zip_path}" | ||
checksum = `swift package compute-checksum #{artifact_bundle_zip_path}` | ||
|
||
# Update the Package.swift file to reference this version | ||
package_manifest_path = 'Package.swift' | ||
package_manifest_content = File.read(package_manifest_path) | ||
|
||
updated_swift_format_reference = <<-EOS | ||
.binaryTarget( | ||
name: "swiftformat", | ||
url: "https://github.com/calda/SwiftFormat/releases/download/#{latest_version_number}/SwiftFormat.artifactbundle.zip", | ||
checksum: "#{checksum.strip}"), | ||
EOS | ||
|
||
regex = /[ ]*.binaryTarget\([\S\s]*name: "swiftformat"[\S\s]*?\),\s/ | ||
updated_package_manifest = package_manifest_content.gsub(regex, updated_swift_format_reference) | ||
File.open(package_manifest_path, "w") { |file| file.puts updated_package_manifest } | ||
|
||
puts "Updated Package.swift to reference SwiftFormat #{latest_version_number}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.