forked from apple/swift-nio-http2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_podspec.sh
executable file
·122 lines (102 loc) · 3.29 KB
/
build_podspec.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
##===----------------------------------------------------------------------===##
##
## This source file is part of the SwiftNIO open source project
##
## Copyright (c) 2017-2019 Apple Inc. and the SwiftNIO project authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
##
## SPDX-License-Identifier: Apache-2.0
##
##===----------------------------------------------------------------------===##
set -eu
function usage() {
echo "$0 [-u] version nio_version"
echo
echo "OPTIONS:"
echo " -u: Additionally upload the podspec"
echo " -f: Skip over all targets before the specified target"
}
upload=false
skip_until=""
while getopts ":u" opt; do
case $opt in
u)
upload=true
;;
f)
skip_until="$OPTARG"
;;
\?)
usage
exit 1
;;
esac
done
shift "$((OPTIND-1))"
if [[ $# -lt 2 ]]; then
usage
exit 1
fi
version=$1
# Current SwiftNIO Version to add as dependency in the .podspec
nio_version=$2
if [[ $nio_version =~ ^([0-9]+)\. ]]; then
# Extract and incremenet the major version to use an upper bound on the
# version requirement (we can't use '~>' as it means 'up to the next
# major' if you specify x.y and 'up to the next minor' if you specify x.y.z).
next_major_version=$((${BASH_REMATCH[1]} + 1))
else
echo "Invalid NIO version '$nio_version'"
exit 1
fi
newline=$'\n'
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
tmpdir=$(mktemp -d /tmp/.build_podspecsXXXXXX)
echo "Building podspec in $tmpdir"
targets=( $("${here}/list_topsorted_dependencies.sh" -l -r | sed 's/^NIO/SwiftNIO/') )
for target in "${targets[@]}"; do
if [[ -n "$skip_until" && "$target" != "$skip_until" ]]; then
echo "Skipping $target"
continue
elif [[ "$skip_until" == "$target" ]]; then
skip_until=""
fi
echo "Building podspec for $target"
dependencies=()
while read -r raw_dependency; do
if [ "$raw_dependency" == "SwiftNIOHPACK" ]; then
dependencies+=( "${newline} s.dependency '$raw_dependency', s.version.to_s" )
else
dependencies+=( "${newline} s.dependency '$raw_dependency', '>= $nio_version', '< $next_major_version'" )
fi
done < <("${here}/list_topsorted_dependencies.sh" -d "${target#Swift}" | sed 's/^NIO/SwiftNIO/')
cat > "${tmpdir}/${target}.podspec" <<- EOF
Pod::Spec.new do |s|
s.name = '$target'
s.version = '$version'
s.license = { :type => 'Apache 2.0', :file => 'LICENSE.txt' }
s.summary = 'Useful code around SwiftNIO.'
s.homepage = 'https://github.com/apple/swift-nio-http2'
s.author = 'Apple Inc.'
s.source = { :git => 'https://github.com/apple/swift-nio-http2.git', :tag => s.version.to_s }
s.documentation_url = 'https://apple.github.io/swift-nio-http2/'
s.module_name = '${target#Swift}'
s.swift_version = '5.0'
s.cocoapods_version = '>=1.6.0'
s.ios.deployment_target = '10.0'
s.osx.deployment_target = '10.12'
s.tvos.deployment_target = '10.0'
s.source_files = 'Sources/${target#Swift}/**/*.{swift,c,h}'
${dependencies[*]-}
end
EOF
pod repo update # last chance of getting the latest versions of previous pushed pods
if $upload; then
echo "Uploading ${tmpdir}/${target}.podspec"
pod trunk push "${tmpdir}/${target}.podspec" --synchronous
fi
done