diff --git a/.github/workflows/publish-cocoapods.yml b/.github/workflows/publish-cocoapods.yml new file mode 100644 index 0000000..8d0384d --- /dev/null +++ b/.github/workflows/publish-cocoapods.yml @@ -0,0 +1,67 @@ +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) + 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 }} + diff --git a/ContentstackSwift.podspec b/ContentstackSwift.podspec index f91ff17..66931c8 100644 --- a/ContentstackSwift.podspec +++ b/ContentstackSwift.podspec @@ -10,7 +10,7 @@ Pod::Spec.new do |s| s.name = 'ContentstackSwift' - s.version = '2.0.1' + s.version = '2.3.2' s.summary = 'Contentstack is a headless CMS with an API-first approach that puts content at the centre.' s.description = <<-DESC @@ -28,7 +28,7 @@ Pod::Spec.new do |s| 'uttamukkoji' => 'uttamukkoji@gmail.com', 'Contentstack' => 'support@contentstack.io' } - s.source = { :git => 'https://github.com/contentstack/contentstack-swift.git', :tag => s.version } + s.source = { :git => 'https://github.com/contentstack/contentstack-swift.git', :tag => "v#{s.version}" } s.social_media_url = 'https://x.com/Contentstack' s.swift_version = '5.6'