Skip to content

Commit 01cb59c

Browse files
Merge pull request #124 from contentstack/fix/DX-2918-cocoapods-fix
Update podspec version to 2.3.3-beta.1, add CocoaPods publish workflow,
2 parents ebf33c9 + 4a433bc commit 01cb59c

2 files changed

Lines changed: 69 additions & 2 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Publish to CocoaPods
2+
3+
# NOTE: CocoaPods Trunk is planned to become read-only by end of 2025.
4+
# This automation will work only until then. SPM is the primary distribution channel.
5+
# This workflow serves as a short-term sync for legacy CocoaPods users.
6+
7+
on:
8+
push:
9+
tags:
10+
- 'v*' # Triggers when you push a version tag (e.g. v2.0.1, v2.4.0-beta.1)
11+
release:
12+
types: [published] # Also triggers when a GitHub Release is published
13+
14+
jobs:
15+
publish:
16+
name: Publish Podspec to CocoaPods
17+
runs-on: macos-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0 # Fetch all history for tags
23+
24+
- name: Set up Ruby
25+
uses: ruby/setup-ruby@v1
26+
with:
27+
ruby-version: '3.0'
28+
bundler-cache: false # We're installing CocoaPods directly
29+
30+
- name: Install CocoaPods
31+
run: gem install cocoapods
32+
33+
- name: Extract version from tag or podspec
34+
id: get_version
35+
run: |
36+
if [ "${{ github.event_name }}" == "release" ]; then
37+
VERSION="${{ github.event.release.tag_name }}"
38+
VERSION=${VERSION#v}
39+
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
40+
VERSION="${GITHUB_REF#refs/tags/}"
41+
VERSION=${VERSION#v}
42+
else
43+
# Branch push: use version from podspec (for testing workflow)
44+
VERSION=$(grep -E "s\.version\s*=" ContentstackSwift.podspec | sed -E "s/.*['\"]([^'\"]+)['\"].*/\1/")
45+
fi
46+
echo "version=$VERSION" >> $GITHUB_OUTPUT
47+
echo "Extracted version: $VERSION"
48+
49+
- name: Verify podspec version matches tag
50+
run: |
51+
PODSPEC_VERSION=$(grep -E "s\.version\s*=" ContentstackSwift.podspec | sed -E "s/.*['\"]([^'\"]+)['\"].*/\1/")
52+
TAG_VERSION="${{ steps.get_version.outputs.version }}"
53+
if [ "$PODSPEC_VERSION" != "$TAG_VERSION" ]; then
54+
echo "Error: Podspec version ($PODSPEC_VERSION) does not match tag version ($TAG_VERSION)"
55+
exit 1
56+
fi
57+
echo "✓ Podspec version matches tag: $PODSPEC_VERSION"
58+
59+
- name: Lint Podspec
60+
run: pod lib lint ContentstackSwift.podspec --allow-warnings
61+
62+
- name: Publish to CocoaPods
63+
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
64+
run: pod trunk push ContentstackSwift.podspec --allow-warnings
65+
env:
66+
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
67+

ContentstackSwift.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
Pod::Spec.new do |s|
1212
s.name = 'ContentstackSwift'
13-
s.version = '2.0.1'
13+
s.version = '2.3.2'
1414
s.summary = 'Contentstack is a headless CMS with an API-first approach that puts content at the centre.'
1515

1616
s.description = <<-DESC
@@ -28,7 +28,7 @@ Pod::Spec.new do |s|
2828
'uttamukkoji' => 'uttamukkoji@gmail.com',
2929
'Contentstack' => 'support@contentstack.io'
3030
}
31-
s.source = { :git => 'https://github.com/contentstack/contentstack-swift.git', :tag => s.version }
31+
s.source = { :git => 'https://github.com/contentstack/contentstack-swift.git', :tag => "v#{s.version}" }
3232
s.social_media_url = 'https://x.com/Contentstack'
3333
s.swift_version = '5.6'
3434

0 commit comments

Comments
 (0)