-
Notifications
You must be signed in to change notification settings - Fork 11
89 lines (78 loc) · 2.83 KB
/
Copy pathpublish-pod.yml
File metadata and controls
89 lines (78 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Publish to CocoaPods
on:
push:
branches: [ main ]
paths:
- 'Roboflow.podspec'
workflow_dispatch:
inputs:
force_tag:
description: 'Allow republish of existing tag (use with caution)'
type: boolean
required: false
default: false
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/setup-xcode@v1.6.0
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
- name: Create and push tag
run: |
echo "Creating tag for version ${{ steps.get_version.outputs.VERSION }}..."
git config user.name github-actions
git config user.email github-actions@github.com
# Check if tag already exists remotely
if git ls-remote --tags origin | grep -q "refs/tags/${{ steps.get_version.outputs.VERSION }}$"; then
if [[ "${{ github.event.inputs.force_tag }}" == "true" ]]; then
echo "Tag ${{ steps.get_version.outputs.VERSION }} already exists. Force push enabled, overwriting..."
git tag -f "${{ steps.get_version.outputs.VERSION }}"
git push origin "${{ steps.get_version.outputs.VERSION }}" --force
echo "Force pushed tag: ${{ steps.get_version.outputs.VERSION }}"
else
echo "Error: Tag ${{ steps.get_version.outputs.VERSION }} already exists and force push is not enabled."
echo "To overwrite, run the workflow manually with 'Allow republish of existing tag' option checked."
exit 1
fi
else
git tag "${{ steps.get_version.outputs.VERSION }}"
git push origin "${{ steps.get_version.outputs.VERSION }}"
echo "Created and pushed new tag: ${{ steps.get_version.outputs.VERSION }}"
fi
- name: Publish to CocoaPods
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
echo "Publishing version ${{ steps.get_version.outputs.VERSION }} to CocoaPods..."
pod trunk push
echo "Successfully published to CocoaPods!"