Skip to content

Publish to CocoaPods #2

Publish to CocoaPods

Publish to CocoaPods #2

Workflow file for this run

name: Publish to CocoaPods
on:
push:
branches: [ main ]
paths:
- 'Roboflow.podspec'
workflow_dispatch:
jobs:
publish:
runs-on: macos-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all tags
- name: Setup Xcode
uses: maxim-lobanov/[email protected]
with:
xcode-version: 'latest-stable'
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: false
- name: Install CocoaPods
run: |
gem install cocoapods
pod --version
- name: Extract version from podspec
id: get_version
run: |
VERSION=$(pod ipc spec Roboflow.podspec | jq -r '.version')
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Detected version: $VERSION"
- name: Validate podspec
run: |
echo "Setting up iOS simulator..."
xcrun simctl list devices
echo ""
echo "Linting pod..."
pod lib lint --verbose --allow-warnings
- name: Check if should publish
id: check_publish
run: |
# Check if tag already exists
if git rev-parse "${{ steps.get_version.outputs.VERSION }}" >/dev/null 2>&1; then
echo "Tag ${{ steps.get_version.outputs.VERSION }} already exists - will skip publishing"
echo "SHOULD_PUBLISH=false" >> $GITHUB_OUTPUT
else
echo "Tag ${{ steps.get_version.outputs.VERSION }} does not exist - will proceed with publishing"
echo "SHOULD_PUBLISH=true" >> $GITHUB_OUTPUT
fi
- name: Create and push tag
if: steps.check_publish.outputs.SHOULD_PUBLISH
run: |
echo "Creating tag for version ${{ steps.get_version.outputs.VERSION }}..."
git config user.name github-actions
git config user.email [email protected]
git tag "${{ steps.get_version.outputs.VERSION }}"
git push origin "${{ steps.get_version.outputs.VERSION }}"
echo "Created and pushed tag: ${{ steps.get_version.outputs.VERSION }}"
- name: Publish to CocoaPods
if: steps.check_publish.outputs.SHOULD_PUBLISH
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
echo "DRY RUN Publishing version ${{ steps.get_version.outputs.VERSION }} to CocoaPods..."
echo "pod trunk push"
echo "Successfully published to CocoaPods!"