build_podspec.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. ##===----------------------------------------------------------------------===##
  3. ##
  4. ## This source file is part of the Swift Logging API open source project
  5. ##
  6. ## Copyright (c) 2019 Apple Inc. and the Swift Logging API project authors
  7. ## Licensed under Apache License v2.0
  8. ##
  9. ## See LICENSE.txt for license information
  10. ## See CONTRIBUTORS.txt for the list of Swift Logging API project authors
  11. ##
  12. ## SPDX-License-Identifier: Apache-2.0
  13. ##
  14. ##===----------------------------------------------------------------------===##
  15. ##===----------------------------------------------------------------------===##
  16. ##
  17. ## This source file is part of the SwiftNIO open source project
  18. ##
  19. ## Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
  20. ## Licensed under Apache License v2.0
  21. ##
  22. ## See LICENSE.txt for license information
  23. ## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
  24. ##
  25. ## SPDX-License-Identifier: Apache-2.0
  26. ##
  27. ##===----------------------------------------------------------------------===##
  28. set -eu
  29. function usage() {
  30. echo "$0 [-u] version"
  31. echo
  32. echo "OPTIONS:"
  33. echo " -u: Additionally upload the podspec"
  34. }
  35. upload=false
  36. while getopts ":u" opt; do
  37. case $opt in
  38. u)
  39. upload=true
  40. ;;
  41. \?)
  42. usage
  43. exit 1
  44. ;;
  45. esac
  46. done
  47. shift "$((OPTIND-1))"
  48. if [[ $# -eq 0 ]]; then
  49. echo "Must provide target version"
  50. exit 1
  51. fi
  52. version=$1
  53. podspec_name="Logging"
  54. here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  55. tmpdir=$(mktemp -d /tmp/.build_podspecsXXXXXX)
  56. echo "Building podspec in $tmpdir"
  57. cat > "${tmpdir}/${podspec_name}.podspec" <<- EOF
  58. Pod::Spec.new do |s|
  59. s.name = '$podspec_name'
  60. s.version = '$version'
  61. s.license = { :type => 'Apache 2.0', :file => 'LICENSE.txt' }
  62. s.summary = 'A Logging API for Swift.'
  63. s.homepage = 'https://github.com/apple/swift-log'
  64. s.author = 'Apple Inc.'
  65. s.source = { :git => 'https://github.com/apple/swift-log.git', :tag => s.version.to_s }
  66. s.documentation_url = 'https://apple.github.io/swift-log'
  67. s.module_name = 'Logging'
  68. s.swift_version = '5.0'
  69. s.cocoapods_version = '>=1.6.0'
  70. s.ios.deployment_target = '8.0'
  71. s.osx.deployment_target = '10.9'
  72. s.tvos.deployment_target = '9.0'
  73. s.watchos.deployment_target = '2.0'
  74. s.source_files = 'Sources/Logging/**/*.swift'
  75. end
  76. EOF
  77. if $upload; then
  78. echo "Uploading ${tmpdir}/${podspec_name}.podspec"
  79. pod trunk push "${tmpdir}/${podspec_name}.podspec"
  80. else
  81. echo "Linting ${tmpdir}/${podspec_name}.podspec"
  82. pod spec lint "${tmpdir}/${podspec_name}.podspec"
  83. fi