-
Notifications
You must be signed in to change notification settings - Fork 402
142 lines (127 loc) · 5.28 KB
/
build-xcframework.yml
File metadata and controls
142 lines (127 loc) · 5.28 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Build XCFramework
on:
release:
types: [published]
workflow_dispatch:
inputs:
target:
description: "Manual build target - use 'release' for production-like behavior (ie when fixing) and 'artifact' for testing"
required: true
type: choice
options:
- artifact # builds only, uploads as a 30-day artifact for testing, does not pollute release assets and does not trigger koog-spm
- release # uploads to GitHub release and triggers koog-spm, must be triggered from a version tag ref
env:
JAVA_VERSION: 17
JAVA_DISTRIBUTION: 'corretto'
JAVA_OPTS: "-Xms8g -Xmx8g -Dfile.encoding=UTF-8 -Djava.awt.headless=true -Dkotlin.daemon.jvm.options=-Xmx6g"
jobs:
build-xcframework:
name: Build iOS XCFramework
runs-on: macos-latest # Required for Xcode
timeout-minutes: 60
permissions:
contents: write # Required for uploading release assets
steps:
- name: Configure Git
run: |
git config --global core.autocrlf input
- uses: actions/checkout@v6
- name: Resolve version and target
id: resolve
run: |
if [ "${{ github.event_name }}" == "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
TARGET="release"
elif [ "${{ inputs.target }}" == "release" ]; then
if [ "${{ github.ref_type }}" != "tag" ]; then
echo "target 'release' requires triggering from a tag ref, not a branch" >&2
exit 1
fi
VERSION="${{ github.ref_name }}"
TARGET="release"
else
VERSION="${{ github.sha }}"
TARGET="artifact"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "target=$TARGET" >> $GITHUB_OUTPUT
echo "Using version: $VERSION, target: $TARGET"
- name: Verify koog-spm app credentials
if: steps.resolve.outputs.target == 'release'
run: |
if [ -z "${{ vars.KOOG_SPM_APP_ID }}" ]; then
echo "KOOG_SPM_APP_ID is required for release dispatch but is not set." >&2
exit 1
fi
if [ -z "${{ secrets.KOOG_SPM_APP_KEY }}" ]; then
echo "KOOG_SPM_APP_KEY is required for release dispatch but is not set." >&2
exit 1
fi
- name: Generate koog-spm app token
if: steps.resolve.outputs.target == 'release'
id: app-token
uses: actions/create-github-app-token@v1
env:
PRIVATE_KEY: ${{ secrets.KOOG_SPM_APP_KEY }}
with:
app-id: ${{ vars.KOOG_SPM_APP_ID }}
private-key: ${{ env.PRIVATE_KEY }}
repositories: koog-spm
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
with:
cache-read-only: false
- name: Verify Xcode installation
run: xcodebuild -version
- name: Build XCFramework
run: |
echo "Assembling XCFramework binary..."
./gradlew :koog-agents:assembleKoogXCFramework -Pkoog.build.xcframework=true --no-daemon --stacktrace
echo "XCFramework binary assembled"
# Uploads XCF as a 30-day artifact for manual testing runs — does not pollute GitHub releases
# We don't zip explicitly, because `upload-artifact` action does it for us
- name: Upload XCFramework artifact for testing
if: steps.resolve.outputs.target == 'artifact'
uses: actions/upload-artifact@v7
with:
name: Koog-xcframework-${{ steps.resolve.outputs.version }}
path: koog-agents/build/XCFrameworks/release/
retention-days: 30
- name: Create XCFramework zip for release
if: steps.resolve.outputs.target == 'release'
id: archive
run: |
ARCHIVE_NAME="Koog-${{ steps.resolve.outputs.version }}.xcframework.zip"
cd koog-agents/build/XCFrameworks/release
zip -r "$ARCHIVE_NAME" Koog.xcframework
echo "archive_path=$(pwd)/$ARCHIVE_NAME" >> $GITHUB_OUTPUT
echo "XCFramework zip created:"
ls -lh "$ARCHIVE_NAME"
# Calculate checksum for SPM
CHECKSUM=$(shasum -a 256 "$ARCHIVE_NAME" | awk '{ print $1 }')
echo "checksum=$CHECKSUM" >> $GITHUB_OUTPUT
echo "url=https://github.com/JetBrains/koog/releases/download/${{ steps.resolve.outputs.version }}/$ARCHIVE_NAME" >> $GITHUB_OUTPUT
echo "Checksum: $CHECKSUM"
- name: Upload XCFramework zip to release
if: steps.resolve.outputs.target == 'release'
run: gh release upload "${{ steps.resolve.outputs.version }}" "${{ steps.archive.outputs.archive_path }}" --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Dispatch koog-spm release
if: steps.resolve.outputs.target == 'release'
run: |
gh api repos/JetBrains/koog-spm/dispatches \
--method POST \
--input - << EOF
{
"event_type": "update-package",
"client_payload": {
"version": "${{ steps.resolve.outputs.version }}",
"url": "${{ steps.archive.outputs.url }}",
"checksum": "${{ steps.archive.outputs.checksum }}"
}
}
EOF
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}