Skip to content

Commit

Permalink
fix(ios): publish libcrypto, libssl, libevent, libtor, libz frameworks (
Browse files Browse the repository at this point in the history
#1372)

This diff fixes ooni/probe#2569.

While there, consolidate quick bash-based tests into the `checks.yml`
action.

While there, expect Xcode 15.0 for local builds.
  • Loading branch information
bassosimone authored Oct 16, 2023
1 parent 6541ef1 commit 657fed6
Show file tree
Hide file tree
Showing 25 changed files with 790 additions and 152 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Performs code quality checks
# Performs miscellaneous quick checks
name: checks
on:
pull_request:
push:
branches:
- "master"

jobs:
perform_code_quality_checks:
Expand All @@ -14,4 +12,11 @@ jobs:
os: [ "ubuntu-22.04" ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- run: ./MOBILE/ios/createpodspecs_test

- run: ./script/nocopyreadall.bash

- run: ./script/ghpublish_test.bash
18 changes: 0 additions & 18 deletions .github/workflows/ghpublish.yml

This file was deleted.

94 changes: 92 additions & 2 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,57 @@ jobs:
# ./internal/cmd/buildtool needs coreutils for sha256 plus GNU build tools
- run: brew install autoconf automake coreutils libtool

- run: make EXPECTED_XCODE_VERSION=14.2 MOBILE/ios
- run: make EXPECTED_XCODE_VERSION=14.2 ios

- uses: actions/upload-artifact@v3
with:
name: libcrypto.xcframework.zip
path: ./MOBILE/ios/libcrypto.xcframework.zip

- uses: actions/upload-artifact@v3
with:
name: libcrypto.podspec
path: ./MOBILE/ios/libcrypto.podspec

- uses: actions/upload-artifact@v3
with:
name: libevent.xcframework.zip
path: ./MOBILE/ios/libevent.xcframework.zip

- uses: actions/upload-artifact@v3
with:
name: libevent.podspec
path: ./MOBILE/ios/libevent.podspec

- uses: actions/upload-artifact@v3
with:
name: libssl.xcframework.zip
path: ./MOBILE/ios/libssl.xcframework.zip

- uses: actions/upload-artifact@v3
with:
name: libssl.podspec
path: ./MOBILE/ios/libssl.podspec

- uses: actions/upload-artifact@v3
with:
name: libtor.xcframework.zip
path: ./MOBILE/ios/libtor.xcframework.zip

- uses: actions/upload-artifact@v3
with:
name: libtor.podspec
path: ./MOBILE/ios/libtor.podspec

- uses: actions/upload-artifact@v3
with:
name: libz.xcframework.zip
path: ./MOBILE/ios/libz.xcframework.zip

- uses: actions/upload-artifact@v3
with:
name: libz.podspec
path: ./MOBILE/ios/libz.podspec

- uses: actions/upload-artifact@v3
with:
Expand All @@ -60,6 +110,46 @@ jobs:
with:
fetch-depth: 0

- uses: actions/download-artifact@v3
with:
name: libcrypto.xcframework.zip

- uses: actions/download-artifact@v3
with:
name: libcrypto.podspec

- uses: actions/download-artifact@v3
with:
name: libevent.xcframework.zip

- uses: actions/download-artifact@v3
with:
name: libevent.podspec

- uses: actions/download-artifact@v3
with:
name: libssl.xcframework.zip

- uses: actions/download-artifact@v3
with:
name: libssl.podspec

- uses: actions/download-artifact@v3
with:
name: libtor.xcframework.zip

- uses: actions/download-artifact@v3
with:
name: libtor.podspec

- uses: actions/download-artifact@v3
with:
name: libz.xcframework.zip

- uses: actions/download-artifact@v3
with:
name: libz.podspec

- uses: actions/download-artifact@v3
with:
name: oonimkall.xcframework.zip
Expand All @@ -68,7 +158,7 @@ jobs:
with:
name: oonimkall.podspec

- run: ./script/ghpublish.bash oonimkall.xcframework.zip oonimkall.podspec
- run: ./script/ghpublish.bash libcrypto.xcframework.zip libcrypto.podspec libevent.xcframework.zip libevent.podspec libssl.xcframework.zip libssl.podspec libtor.xcframework.zip libtor.podspec libz.xcframework.zip libz.podspec oonimkall.xcframework.zip oonimkall.podspec
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
5 changes: 3 additions & 2 deletions MOBILE/ios/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/oonimkall.framework/
/oonimkall.*
/*.xcframework/
/*.zip
/*.podspec
2 changes: 1 addition & 1 deletion MOBILE/ios/check-xcode-version
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -euo pipefail

EXPECTED_XCODE_VERSION=${EXPECTED_XCODE_VERSION:-14.2}
EXPECTED_XCODE_VERSION=${EXPECTED_XCODE_VERSION:-15.0}

printf "checking for xcodebuild... "
command -v xcodebuild || {
Expand Down
6 changes: 0 additions & 6 deletions MOBILE/ios/createpodspec

This file was deleted.

25 changes: 25 additions & 0 deletions MOBILE/ios/createpodspecs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -euo pipefail
__version=$(date -u +%Y.%m.%d-%H%M%S)
__release="${1:-$(git describe --tags || echo '0.0.0-dev')}"

# Save original variable before substitution so we can unit test it
__orig=${__release}

# determine whether we're publishing to a release or to rolling
#
# when publishing to rolling the __release variable is like: 'v3.19.0-alpha-27-g4678578b'
# otherwise it's like `v3.19.0`, `v3.19.0-alpha`, or `v3.19.0-beta.555`.
if ! [[ $__release =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+(\.[0-9]+)?)?$ ]]; then
__release=rolling
fi

if [[ ${CREATE_POD_SPECS_DEBUG:-0} == 1 ]]; then
echo "$__orig -> $__release"
exit 0
fi

for name in libcrypto libevent libssl libtor libz oonimkall; do
cat ./MOBILE/ios/${name}-template.podspec | sed -e "s/@VERSION@/$__version/g" \
-e "s/@RELEASE@/$__release/g" >./MOBILE/ios/${name}.podspec
done
32 changes: 32 additions & 0 deletions MOBILE/ios/createpodspecs_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -euo pipefail

export CREATE_POD_SPECS_DEBUG=1

function check() {
local expect=$1
local got=$2
echo -n "checking whether '$expect' equals '$got'... " 1>&2
if [[ "$got" != "$expect" ]]; then
echo "NO" 1>&2
exit 1
fi
echo "yes"
}

expect="v3.10.9-beta.116-44-g1777474 -> rolling"
got=$(./MOBILE/ios/createpodspecs v3.10.9-beta.116-44-g1777474)
check "$expect" "$got"

expect="v3.10.0 -> v3.10.0"
got=$(./MOBILE/ios/createpodspecs v3.10.0)
check "$expect" "$got"

expect="v3.10.0-alpha -> v3.10.0-alpha"
got=$(./MOBILE/ios/createpodspecs v3.10.0-alpha)
check "$expect" "$got"

expect="v3.10.0-alpha.1 -> v3.10.0-alpha.1"
got=$(./MOBILE/ios/createpodspecs v3.10.0-alpha.1)
check "$expect" "$got"

13 changes: 13 additions & 0 deletions MOBILE/ios/libcrypto-template.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Pod::Spec.new do |s|
s.name = "libcrypto"
s.version = "@VERSION@"
s.summary = "OpenSSL libcrypto compiled for OONI Probe iOS"
s.author = "Simone Basso"
s.homepage = "https://github.com/ooni/probe-cli"
s.license = { :type => "Apache" }
s.source = {
:http => "https://github.com/ooni/probe-cli/releases/download/@RELEASE@/libcrypto.xcframework.zip"
}
s.platform = :ios, "9.0"
s.ios.vendored_frameworks = "libcrypto.xcframework"
end
13 changes: 13 additions & 0 deletions MOBILE/ios/libevent-template.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Pod::Spec.new do |s|
s.name = "libevent"
s.version = "@VERSION@"
s.summary = "Libevent compiled for OONI Probe iOS"
s.author = "Simone Basso"
s.homepage = "https://github.com/ooni/probe-cli"
s.license = { :type => "BSD" }
s.source = {
:http => "https://github.com/ooni/probe-cli/releases/download/@RELEASE@/libevent.xcframework.zip"
}
s.platform = :ios, "9.0"
s.ios.vendored_frameworks = "libevent.xcframework"
end
13 changes: 13 additions & 0 deletions MOBILE/ios/libssl-template.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Pod::Spec.new do |s|
s.name = "libssl"
s.version = "@VERSION@"
s.summary = "OpenSSL libssl compiled for OONI Probe iOS"
s.author = "Simone Basso"
s.homepage = "https://github.com/ooni/probe-cli"
s.license = { :type => "Apache" }
s.source = {
:http => "https://github.com/ooni/probe-cli/releases/download/@RELEASE@/libssl.xcframework.zip"
}
s.platform = :ios, "9.0"
s.ios.vendored_frameworks = "libssl.xcframework"
end
13 changes: 13 additions & 0 deletions MOBILE/ios/libtor-template.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Pod::Spec.new do |s|
s.name = "libtor"
s.version = "@VERSION@"
s.summary = "tor compiled for OONI Probe iOS"
s.author = "Simone Basso"
s.homepage = "https://github.com/ooni/probe-cli"
s.license = { :type => "BSD" }
s.source = {
:http => "https://github.com/ooni/probe-cli/releases/download/@RELEASE@/libtor.xcframework.zip"
}
s.platform = :ios, "9.0"
s.ios.vendored_frameworks = "libtor.xcframework"
end
13 changes: 13 additions & 0 deletions MOBILE/ios/libz-template.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Pod::Spec.new do |s|
s.name = "libz"
s.version = "@VERSION@"
s.summary = "zlib compiled for OONI Probe iOS"
s.author = "Simone Basso"
s.homepage = "https://github.com/ooni/probe-cli"
s.license = { :type => "zlib" }
s.source = {
:http => "https://github.com/ooni/probe-cli/releases/download/@RELEASE@/libz.xcframework.zip"
}
s.platform = :ios, "9.0"
s.ios.vendored_frameworks = "libz.xcframework"
end
48 changes: 48 additions & 0 deletions MOBILE/ios/make-extra-frameworks
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
set -euxo pipefail

TOPDIR=$(dirname $(dirname $(dirname $(realpath $0))))
WORK=$(mktemp -d)

# make_framework constructs a framework.
#
# This function does not bother itself with installing headers because we have
# already used the relevant headers when invoking `gomobile bind`.
#
# Arguments:
#
# - $1 is the name of the framework to create.
function make_framework() {
local name=$1
shift

# Start afresh.
rm -rf MOBILE/ios/${name}.xcframework

# Create iphoneos/arm64 framework.
mkdir -p $WORK/iphoneos/${name}.framework/Versions/A/Headers
ln -s A $WORK/iphoneos/${name}.framework/Versions/Current
ln -s Versions/Current/Headers $WORK/iphoneos/${name}.framework/Headers
ln -s Versions/Current/${name} $WORK/iphoneos/${name}.framework/${name}
xcrun lipo $TOPDIR/internal/libtor/iphoneos/arm64/lib/${name}.a -create \
-o $WORK/iphoneos/${name}.framework/Versions/A/${name}

# Create iphonesimulator/{amd,arm}64 framework.
mkdir -p $WORK/iphonesimulator/${name}.framework/Versions/A/Headers
ln -s A $WORK/iphonesimulator/${name}.framework/Versions/Current
ln -s Versions/Current/Headers $WORK/iphonesimulator/${name}.framework/Headers
ln -s Versions/Current/${name} $WORK/iphonesimulator/${name}.framework/${name}
xcrun lipo $TOPDIR/internal/libtor/iphonesimulator/amd64/lib/${name}.a \
$TOPDIR/internal/libtor/iphonesimulator/arm64/lib/${name}.a \
-create -output $WORK/iphonesimulator/${name}.framework/Versions/A/${name}

# Create a .xcframework.
xcodebuild -create-xcframework -framework /private$WORK/iphoneos/${name}.framework \
-framework /private$WORK/iphonesimulator/${name}.framework -output MOBILE/ios/${name}.xcframework
}

make_framework libz
make_framework libcrypto
make_framework libssl
make_framework libevent
make_framework libtor
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Pod::Spec.new do |s|
s.summary = "OONI Probe Library for iOS"
s.author = "Simone Basso"
s.homepage = "https://github.com/ooni/probe-cli"
s.license = { :type => "BSD" }
s.license = { :type => "GPL" }
s.source = {
:http => "https://github.com/ooni/probe-cli/releases/download/@RELEASE@/oonimkall.xcframework.zip"
}
Expand Down
7 changes: 0 additions & 7 deletions MOBILE/ios/zipframework

This file was deleted.

9 changes: 9 additions & 0 deletions MOBILE/ios/zipframeworks
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -euxo pipefail
(
cd ./MOBILE/ios
for name in libcrypto libevent libssl libtor libz oonimkall; do
rm -rf ${name}.xcframework.zip
zip -yr ${name}.xcframework.zip ${name}.xcframework
done
)
Loading

0 comments on commit 657fed6

Please sign in to comment.