Skip to content

Commit

Permalink
Build on each XCode version available on the runner
Browse files Browse the repository at this point in the history
  • Loading branch information
stoyicker committed Apr 16, 2024
1 parent 8e4a760 commit a8e69ab
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 29 deletions.
44 changes: 44 additions & 0 deletions .github/actions/attachXcFrameworkAndChecksum/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Setup Gradle and run a task on all modules that have it
description: Includes setting up JDK
inputs:
target:
description: The release to attach to
required: true
xcodeversion:
description: The Xcode version to configure before compiling
required: true
runs:
using: composite
steps:
- uses: actions/checkout@v3.5.3
- uses: maxim-lobanov/setup-xcode@v1.6.0
with:
xcode-version: ${{ inputs.xcodeversion }}
- uses: ./.github/actions/runGradleTask
with:
task: :library:assembleLibraryReleaseXCFramework
- run: zip -r Library.xcframework.zip library/build/XCFrameworks/release/library.xcframework
- uses: actions/download-artifact@v4.1.4
with:
name: upload_url
- run: echo UPLOAD_URL=$(cat upload_url | sed "s/{?name,label}/?name=Library-${{ inputs.target }}-xcodebuild-${{ matrix.xcodeversion }}.xcframework.zip/") >> $GITHUB_ENV
- run: |
curl -s \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
--data-binary "@Library.xcframework.zip" \
$UPLOAD_URL
- run: echo $(swift package compute-checksum Library.xcframework.zip) > checksum
- run: echo UPLOAD_URL=$(cat upload_url | sed "s/{?name,label}/?name=Library-${{ inputs.target }}-xcodebuild-${{ matrix.xcodeversion }}.xcframework.zip.checksum/") >> $GITHUB_ENV
- run: |
curl -s \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
--data-binary "@checksum" \
$UPLOAD_URL
28 changes: 27 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,36 @@ on:
branches:
- '**'
jobs:
root:
generate-build-matrix:
runs-on: macos-14-xlarge
outputs:
xcodeversions: ${{ steps.generate.outputs.xcodeversions }}
steps:
- id: generate
run: |
version_list=()
for XCODE_INSTALL in $(ls /Applications | grep Xcode); do
version_list+=("$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" /Applications/$XCODE_INSTALL/Contents/Info.plist)")
done
unique_version_list=( $(printf "%s\n" ${version_list[@]} | sort -n -u) )
jsonString="$(jq -c --null-input '$ARGS.positional' --args -- "${unique_version_list[@]}")"
echo "xcodeversions=$jsonString" >> $GITHUB_OUTPUT
build:
runs-on: macos-14-xlarge
needs: [ generate-build-matrix ]
strategy:
matrix:
xcodeversion: ${{ fromJSON(needs.generate-build-matrix.outputs.xcodeversions) }}
steps:
- uses: actions/checkout@v3.5.3
- uses: maxim-lobanov/setup-xcode@v1.6.0
with:
xcode-version: ${{ matrix.xcodeversion }}
- uses: ./.github/actions/runGradleTask
with:
task: build
barrier-build:
runs-on: ubuntu-22.04
needs: [ build ]
steps:
- run: exit 0
55 changes: 31 additions & 24 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ permissions:
packages: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
concurrency:
group: ${{ github.ref_name }}
jobs:
ensure-tag-is-on-main:
runs-on: ubuntu-22.04
Expand All @@ -17,6 +19,15 @@ jobs:
ref: main
fetch-depth: 0
- run: exit $(git merge-base --is-ancestor $GITHUB_REF_NAME HEAD)
jvm-maven-github:
runs-on: macos-14-xlarge
needs: [ ensure-tag-is-on-main ]
steps:
- uses: actions/checkout@v3.5.3
- uses: ./.github/actions/runGradleTask
with:
preTaskString: -Pversion=$GITHUB_REF_NAME
task: library:publishKotlinMultiplatformPublicationToGithubPackagesRepository
create-github-release:
runs-on: ubuntu-22.04
needs: [ ensure-tag-is-on-main ]
Expand All @@ -27,34 +38,30 @@ jobs:
with:
name: upload_url
path: upload_url
jvm-maven-github:
generate-build-matrix:
runs-on: macos-14-xlarge
needs: [ ensure-tag-is-on-main ]
outputs:
xcodeversions: ${{ steps.generate.outputs.xcodeversions }}
steps:
- uses: actions/checkout@v3.5.3
- uses: ./.github/actions/runGradleTask
with:
preTaskString: -Pversion=$GITHUB_REF_NAME
task: library:publishKotlinMultiplatformPublicationToGithubPackagesRepository
- id: generate
run: |
version_list=()
for XCODE_INSTALL in $(ls /Applications | grep Xcode); do
version_list+=("$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" /Applications/$XCODE_INSTALL/Contents/Info.plist)")
done
unique_version_list=( $(printf "%s\n" ${version_list[@]} | sort -n -u) )
jsonString="$(jq -c --null-input '$ARGS.positional' --args -- "${unique_version_list[@]}")"
echo "xcodeversions=$jsonString" >> $GITHUB_OUTPUT
attach-xcframework-to-github-release:
runs-on: macos-14-xlarge
needs: [ create-github-release ]
needs: [ create-github-release, generate-build-matrix ]
strategy:
fail-fast: false
matrix:
xcodeversion: ${{ fromJSON(needs.generate-build-matrix.outputs.xcodeversions) }}
steps:
- uses: actions/checkout@v3.5.3
- uses: ./.github/actions/runGradleTask
- uses: ./.github/actions/attachXcFrameworkAndChecksum
with:
task: :library:assembleLibraryReleaseXCFramework
- run: zip -r Library.xcframework.zip library/build/XCFrameworks/release/library.xcframework
- uses: actions/download-artifact@v4.1.4
with:
name: upload_url
- run: echo UPLOAD_URL=$(cat upload_url | sed "s/{?name,label}/?name=Library-${GITHUB_REF_NAME}.xcframework.zip/") >> $GITHUB_ENV
- run: |
curl -s \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
--data-binary "@Library.xcframework.zip" \
$UPLOAD_URL
target: ${{ github.ref_name }}
xcodeversion: ${{ matrix.xcodeversion }}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ dependencies {
<summary><b>SwiftPM</b></summary>

```swift
.package(url: "https://github.com/tidal-music/network-time-package.swift.git", .from("$VERSION"))
.binaryTarget(
url: "https://github.com/tidal-music/network-time/downloads/$VERSION/Library-$VERSION-xcodebuild-${XCODEVERSION}.xcframework.zip",
checksum: "Contents of https://github.com/tidal-music/network-time/downloads/$VERSION/Library-$VERSION-xcodebuild-$XCODEVERSION.xcframework.zip.checksum"
)
```

</details>
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ buildscript {
google()
}
dependencies {
val kotlinVersion = "1.9.20"
classpath("org.jetbrains.dokka:dokka-gradle-plugin:$kotlinVersion")
val kotlinVersion = "1.9.23"
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20") // Should be $kotlinVersion when possible
classpath(kotlin("gradle-plugin", version = kotlinVersion))
classpath(kotlin("serialization", version = kotlinVersion))
classpath("com.android.tools.build:gradle:8.1.4")
classpath("org.jetbrains.compose:compose-gradle-plugin:1.5.10")
classpath("org.jetbrains.compose:compose-gradle-plugin:1.6.1")
}
}

Expand Down

0 comments on commit a8e69ab

Please sign in to comment.