Skip to content

Commit

Permalink
ci: publish to cloudsmith and cocoapods
Browse files Browse the repository at this point in the history
  • Loading branch information
DannyBedard committed Jun 18, 2024
1 parent 1ecd35b commit 219a83e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 14 deletions.
65 changes: 57 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ on:
default: false
required: true
type: boolean
android:
description: Publish an android version (maven)
default: true
required: true
type: boolean
rust:
description: Publish a rust version (crates.io)
default: true
required: true
type: boolean
android:
description: Publish an android version (maven)
swift:
description: Publish a swift version (cocoapods)
default: true
required: true
type: boolean
Expand Down Expand Up @@ -109,15 +114,13 @@ jobs:
rustup target add x86_64-unknown-linux-gnu
- name: Build
run: |
cd wrappers/android
sh build.sh
run: sh wrappers/android/build.sh

- name: Create local.properties
run: |
echo "sdk.dir=$ANDROID_HOME" > local.properties
run: echo "sdk.dir=$ANDROID_HOME" > local.properties

- run: chmod +x gradlew
- name: Allow gradlew to run
run: chmod +x gradlew

- name: Package .aar
run: ./gradlew clean assembleRelease
Expand Down Expand Up @@ -148,3 +151,49 @@ jobs:
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

build-swift:
environment: cocoapods-publish
if: ${{ inputs.swift }}
runs-on: macos-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup rust
run: |
rustup target add aarch64-apple-ios
rustup target add x86_64-apple-ios
cargo install cargo-lipo
- name: Build iOS libraries
run: sh wrappers/swift/build.sh

- name: Setup version
id: version
run: |
VERSION=$(grep -E "^\s*s\.version\s*=\s*['\"][0-9]+\.[0-9]+\.[0-9]+['\"]" Slauth.podspec | awk -F"[\"\']" '{print $2}')
echo "branch_name=release/cocoapods-v$VERSION" >> $GITHUB_OUTPUT
- name: Push to a new branch
run: |
git checkout --orphan ${{ steps.version.outputs.branch_name }}
git rm -rf .
git checkout devops/cloudsmith-cocoapods -- LICENSE wrappers/swift/classes slauth.h Slauth.podspec
git add LICENSE wrappers/swift/classes/** slauth.h Slauth.podspec target/universal/release/* target/x86_64-apple-ios/release/* target/aarch64-apple-ios/release/*
git commit -m "Set up CocoaPods release branch"
git push origin ${{ steps.version.outputs.branch_name }}
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Update Podspec
run: sed -i '' "s|:branch => '.*'|:branch => '${{ steps.version.outputs.branch_name }}'|" Slauth.podspec

- name: Validate podspec
run: pod spec lint --skip-import-validation --use-libraries --allow-warnings

- name: Publish to CocoaPods
run: pod trunk push Slauth.podspec --allow-warnings
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
10 changes: 5 additions & 5 deletions Slauth.podspec
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
Pod::Spec.new do |s|
s.name = 'Slauth'
s.version = '0.7.6'
s.summary = 'A Swift wrapper aroud Slauth Rust crate'
s.summary = 'A Swift wrapper around Slauth Rust crate'
s.description = <<-DESC
TODO: Add long description of the pod here.
DESC

s.homepage = 'https://github.com/Devolutions/Slauth.git'
s.license = { :type => 'MIT', :file => './LICENSE' }
s.author = { 'Devolutions' => 'lfauvel@devolutions.net' }
s.source = { :git => 'https://github.com/Devolutions/Slauth.git', :tag => s.version.to_s }
s.source = { :git => 'https://github.com/Devolutions/Slauth.git', :branch => 'devops/cloudsmith-cocoapods' }

s.swift_version = '5.0'
s.ios.deployment_target = '11.0'
s.ios.deployment_target = '17.0'

s.source_files = 'wrappers/swift/classes/**/*', 'slauth.h'
s.vendored_libraries = 'target/universal/release/*.a', 'target/x86_64-apple-io/release/*.a', 'target/aarch64-apple-ios/release/*.a'
s.vendored_libraries = 'target/universal/release/*.a', 'target/x86_64-apple-io/release/*.a', 'target/aarch64-apple-ios/release/*.a'
end
2 changes: 1 addition & 1 deletion wrappers/swift/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cargo lipo --release
mv target/universal/release/libslauth.a target/universal/release/libslauth_universal.a
mv target/x86_64-apple-ios/release/libslauth.a target/x86_64-apple-ios/release/libslauth_x86.a
mv target/aarch64-apple-ios/release/libslauth.a target/aarch64-apple-ios/release/libslauth_arm64.a
mv target/aarch64-apple-ios/release/libslauth.a target/aarch64-apple-ios/release/libslauth_arm64.a

0 comments on commit 219a83e

Please sign in to comment.