Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCOCOA-2308: Add GHA workflow for core prebuilds #8517

Merged
merged 18 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
101 changes: 98 additions & 3 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
name: Build Core binaries
on: workflow_dispatch
on:
workflow_dispatch:
inputs:
core-version:
type: string
required: false
default: ''
description: Core version (tag/ref) to use to generate the binaries for. If not provided, the version in dependencies.list will be used
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(tag/ref) implies that you can build things other than tagged versions with this but I'm pretty sure doing so will fail as REALM_VERSION needs to be something that can be parsed as a version. To support that it'd need to do something along the lines of checking out the supplied branch but using the result of git describe as the version everywhere else.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've clarified this now. This should either be a tag or the output of git describe. It doesn't appear like we can do actual releases with a git describe-d version, but we can still create prebuilds and use them during development if we wanted to run a CI build on all platforms from an untagged version of Core.


jobs:
build-packages:
runs-on: macos-14
name: Prepare outputs
name: Build for ${{ matrix.target }}
outputs:
core-version: ${{ steps.get-core-version.outputs.version }}
strategy:
matrix:
target: [macosx, iphoneos, iphonesimulator, tvos, tvsimulator, watchos, watchsimulator, maccatalyst]
target: [macosx, iphoneos, iphonesimulator, appletvos, appletvsimulator, watchos, watchsimulator, maccatalyst]
xcode: ["14.3.1"]
include:
- target: xros
Expand All @@ -15,7 +25,92 @@ jobs:
xcode: "15.2.0"
steps:
- uses: actions/checkout@v4

- name: Switch to Xcode ${{ matrix.xcode }}
uses: maxim-lobanov/setup-xcode@v1.6.0
with:
xcode-version: ${{ matrix.xcode }}

- name: Get Core Version
id: get-core-version
run: |
REALM_CORE_VERSION=${{ inputs.core-version }}
if [[ -z $REALM_CORE_VERSION ]]; then
REALM_CORE_VERSION=$(sed -n 's/^REALM_CORE_VERSION=\(.*\)$/\1/p' dependencies.list)
fi
echo "version=$REALM_CORE_VERSION" >> "$GITHUB_OUTPUT"

- name: Checkout Core
uses: actions/checkout@v4
with:
repository: realm/realm-core
path: core
submodules: recursive
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need core's submodules

Copy link
Member Author

@nirinchev nirinchev Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are needed to build the core binaries, aren't they? Otherwise, I get errors like this one when running build-apple-device.sh:

CMake Error at external/CMakeLists.txt:4 (add_subdirectory):
  The source directory

    /Users/runner/work/realm-swift/realm-swift/core/external/catch

  does not contain a CMakeLists.txt file.

fetch-depth: 0
fetch-tags: true

- name: Checkout Core@${{ steps.get-core-version.outputs.version }}
run: git checkout ${{ steps.get-core-version.outputs.version }}
working-directory: core

- name: Build for ${{ matrix.target }}
run: sh tools/${{ matrix.target != 'macosx' && format('build-apple-device.sh -p {0} -c Release', matrix.target) || 'build-cocoa.sh -bm' }} -v ${{ steps.get-core-version.outputs.version }}
working-directory: core

- name: Archive binaries
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.target }}
path: core/realm-Release-*.tar.gz

combine-xcframework:
runs-on: macos-14
name: Combine xcframework
environment:
name: Prebuilds
url: ${{ steps.upload-to-s3.outputs.url }}
needs:
- build-packages
steps:
- uses: actions/checkout@v4

- name: Checkout Core
uses: actions/checkout@v4
with:
repository: realm/realm-core
path: core
ref: ${{ needs.build-packages.outputs.core-version }}

- name: Download binaries
uses: actions/download-artifact@v4
with:
path: core

- name: Combine xcframework
run: |
mv binaries-*/* ./
sh tools/build-cocoa.sh -v ${{ needs.build-packages.outputs.core-version }}
mkdir ../release
mv realm-monorepo-xcframework-${{ needs.build-packages.outputs.core-version }}.tar.xz ../release/
working-directory: core

- name: Archive xcframework
uses: actions/upload-artifact@v4
with:
name: Realm-${{ needs.build-packages.outputs.core-version }}.xcframework.tar.xz
path: release

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_KEY }}
aws-region: us-east-1

- name: Upload release folder to S3
id: upload-to-s3
run: |
s3_folder="static.realm.io/downloads/core/${{ needs.build-packages.outputs.core-version }}/cocoa"
aws s3 sync --acl public-read . "s3://$s3_folder"
echo "url=https://$s3_folder/realm-monorepo-xcframework-${{ needs.build-packages.outputs.core-version }}.tar.xz" >> $GITHUB_OUTPUT
working-directory: release
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ let package = Package(
targets: ["Realm", "RealmSwift"]),
],
dependencies: [
.package(url: "https://github.com/realm/realm-core.git", exact: coreVersion)
.package(url: "https://github.com/realm/realm-core.git", revision: "v\(coreVersion)")
nirinchev marked this conversation as resolved.
Show resolved Hide resolved
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion dependencies.list
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION=10.48.0
REALM_CORE_VERSION=13.26.0
REALM_CORE_VERSION=v13.26.0
nirinchev marked this conversation as resolved.
Show resolved Hide resolved
STITCH_VERSION=8bf8ebcff6e804586c30a6ccbadb060753071a42
2 changes: 1 addition & 1 deletion scripts/download-core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ copy_core() {

tries_left=3
readonly version="$REALM_CORE_VERSION"
readonly url="${REALM_BASE_URL}/v${version}/cocoa/realm-monorepo-xcframework-v${version}.tar.xz"
readonly url="${REALM_BASE_URL}/${version}/cocoa/realm-monorepo-xcframework-${version}.tar.xz"
# First check if we need to do anything
if [ -e "$dst" ]; then
if [ -e "$dst/version.txt" ]; then
Expand Down