Skip to content

Release 2.3.2 for CocoaPods sync #4

Release 2.3.2 for CocoaPods sync

Release 2.3.2 for CocoaPods sync #4

name: Publish to CocoaPods
# NOTE: CocoaPods Trunk is planned to become read-only by end of 2025.
# This automation will work only until then. SPM is the primary distribution channel.
# This workflow serves as a short-term sync for legacy CocoaPods users.
on:
push:
tags:
- 'v*' # Triggers when you push a version tag (e.g. v2.0.1, v2.4.0-beta.1)
branches:
- fix/DX-2918-cocoapods-fix # Trigger on branch push to test workflow (lint only; no publish)
release:
types: [published] # Also triggers when a GitHub Release is published
jobs:
publish:
name: Publish Podspec to CocoaPods
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for tags
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: false # We're installing CocoaPods directly
- name: Install CocoaPods
run: gem install cocoapods
- name: Extract version from tag or podspec
id: get_version
run: |
if [ "${{ github.event_name }}" == "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
VERSION=${VERSION#v}
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION="${GITHUB_REF#refs/tags/}"
VERSION=${VERSION#v}
else
# Branch push: use version from podspec (for testing workflow)
VERSION=$(grep -E "s\.version\s*=" ContentstackSwift.podspec | sed -E "s/.*['\"]([^'\"]+)['\"].*/\1/")
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- name: Verify podspec version matches tag
run: |
PODSPEC_VERSION=$(grep -E "s\.version\s*=" ContentstackSwift.podspec | sed -E "s/.*['\"]([^'\"]+)['\"].*/\1/")
TAG_VERSION="${{ steps.get_version.outputs.version }}"
if [ "$PODSPEC_VERSION" != "$TAG_VERSION" ]; then
echo "Error: Podspec version ($PODSPEC_VERSION) does not match tag version ($TAG_VERSION)"
exit 1
fi
echo "✓ Podspec version matches tag: $PODSPEC_VERSION"
- name: Lint Podspec
run: pod lib lint ContentstackSwift.podspec --allow-warnings
- name: Publish to CocoaPods
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
run: pod trunk push ContentstackSwift.podspec --allow-warnings
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}