From 851926342dfb622a6b541ebb57c3fded23466398 Mon Sep 17 00:00:00 2001 From: Sam Beran Date: Wed, 27 Aug 2025 16:30:47 -0500 Subject: [PATCH 1/4] initial version of publish action --- .github/workflows/publish-pod.yml | 101 ++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 .github/workflows/publish-pod.yml diff --git a/.github/workflows/publish-pod.yml b/.github/workflows/publish-pod.yml new file mode 100644 index 0000000..faf89b9 --- /dev/null +++ b/.github/workflows/publish-pod.yml @@ -0,0 +1,101 @@ +name: Publish to CocoaPods + +on: + push: + branches: [ main ] + paths: + - 'Roboflow.podspec' + workflow_dispatch: + inputs: + force_publish: + description: 'Force publish even if tag exists' + required: false + default: 'true' + type: choice + options: + - 'true' + - 'false' + +jobs: + publish: + runs-on: macos-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all tags + + - 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=$(grep -E "spec.version\s*=\s*" Roboflow.podspec | sed -E 's/.*"([0-9.]+)".*/\1/') + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + echo "Detected version: $VERSION" + + - name: Check if tag exists + id: check_tag + if: github.event_name == 'push' + run: | + if git rev-parse "${{ steps.get_version.outputs.VERSION }}" >/dev/null 2>&1; then + echo "TAG_EXISTS=true" >> $GITHUB_OUTPUT + echo "Tag ${{ steps.get_version.outputs.VERSION }} already exists" + else + echo "TAG_EXISTS=false" >> $GITHUB_OUTPUT + echo "Tag ${{ steps.get_version.outputs.VERSION }} does not exist" + fi + + - name: Determine if should publish + id: should_publish + run: | + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + echo "SHOULD_PUBLISH=true" >> $GITHUB_OUTPUT + echo "Manual trigger - will publish" + elif [[ "${{ steps.check_tag.outputs.TAG_EXISTS }}" == "true" ]]; then + echo "SHOULD_PUBLISH=false" >> $GITHUB_OUTPUT + echo "Tag already exists - skipping publish" + else + echo "SHOULD_PUBLISH=true" >> $GITHUB_OUTPUT + echo "New version detected - will publish" + fi + + - name: Validate podspec + if: steps.should_publish.outputs.SHOULD_PUBLISH == 'true' + run: | + echo "Running pod lib lint..." + pod lib lint Roboflow.podspec --allow-warnings + + - name: Create and push tag + if: steps.should_publish.outputs.SHOULD_PUBLISH == 'true' && steps.check_tag.outputs.TAG_EXISTS != 'true' + run: | + git config user.name github-actions + git config user.email github-actions@github.com + 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.should_publish.outputs.SHOULD_PUBLISH == 'true' + env: + COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} + run: | + echo "Publishing version ${{ steps.get_version.outputs.VERSION }} to CocoaPods..." + pod trunk push Roboflow.podspec --allow-warnings + echo "Successfully published to CocoaPods!" + + - name: Skip message + if: steps.should_publish.outputs.SHOULD_PUBLISH == 'false' + run: | + echo "Skipping publish - tag ${{ steps.get_version.outputs.VERSION }} already exists" + echo "To force publish, use the manual workflow trigger" \ No newline at end of file From 68d9f8e946998024fe88d12221afdd66f5a5fb3c Mon Sep 17 00:00:00 2001 From: Sam Beran Date: Wed, 27 Aug 2025 17:16:21 -0500 Subject: [PATCH 2/4] simplify --- .github/workflows/publish-pod.yml | 63 +++++++++---------------------- 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/.github/workflows/publish-pod.yml b/.github/workflows/publish-pod.yml index faf89b9..4d89e6c 100644 --- a/.github/workflows/publish-pod.yml +++ b/.github/workflows/publish-pod.yml @@ -6,19 +6,12 @@ on: paths: - 'Roboflow.podspec' workflow_dispatch: - inputs: - force_publish: - description: 'Force publish even if tag exists' - required: false - default: 'true' - type: choice - options: - - 'true' - - 'false' jobs: publish: runs-on: macos-latest + permissions: + contents: write steps: - name: Checkout code @@ -40,62 +33,42 @@ jobs: - name: Extract version from podspec id: get_version run: | - VERSION=$(grep -E "spec.version\s*=\s*" Roboflow.podspec | sed -E 's/.*"([0-9.]+)".*/\1/') + VERSION=$(pod ipc spec Roboflow.podspec | jq -r '.version') echo "VERSION=$VERSION" >> $GITHUB_OUTPUT echo "Detected version: $VERSION" - - name: Check if tag exists - id: check_tag - if: github.event_name == 'push' + - name: Validate podspec run: | - if git rev-parse "${{ steps.get_version.outputs.VERSION }}" >/dev/null 2>&1; then - echo "TAG_EXISTS=true" >> $GITHUB_OUTPUT - echo "Tag ${{ steps.get_version.outputs.VERSION }} already exists" - else - echo "TAG_EXISTS=false" >> $GITHUB_OUTPUT - echo "Tag ${{ steps.get_version.outputs.VERSION }} does not exist" - fi + echo "Linting pod..." + pod lib lint - - name: Determine if should publish - id: should_publish + - name: Check if should publish + id: check_publish run: | - if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then - echo "SHOULD_PUBLISH=true" >> $GITHUB_OUTPUT - echo "Manual trigger - will publish" - elif [[ "${{ steps.check_tag.outputs.TAG_EXISTS }}" == "true" ]]; then + # 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 - echo "Tag already exists - skipping publish" else + echo "Tag ${{ steps.get_version.outputs.VERSION }} does not exist - will proceed with publishing" echo "SHOULD_PUBLISH=true" >> $GITHUB_OUTPUT - echo "New version detected - will publish" fi - - name: Validate podspec - if: steps.should_publish.outputs.SHOULD_PUBLISH == 'true' - run: | - echo "Running pod lib lint..." - pod lib lint Roboflow.podspec --allow-warnings - - name: Create and push tag - if: steps.should_publish.outputs.SHOULD_PUBLISH == 'true' && steps.check_tag.outputs.TAG_EXISTS != 'true' + 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 github-actions@github.com - git tag ${{ steps.get_version.outputs.VERSION }} - git push origin ${{ steps.get_version.outputs.VERSION }} + 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.should_publish.outputs.SHOULD_PUBLISH == 'true' + if: steps.check_publish.outputs.SHOULD_PUBLISH env: COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} run: | echo "Publishing version ${{ steps.get_version.outputs.VERSION }} to CocoaPods..." pod trunk push Roboflow.podspec --allow-warnings - echo "Successfully published to CocoaPods!" - - - name: Skip message - if: steps.should_publish.outputs.SHOULD_PUBLISH == 'false' - run: | - echo "Skipping publish - tag ${{ steps.get_version.outputs.VERSION }} already exists" - echo "To force publish, use the manual workflow trigger" \ No newline at end of file + echo "Successfully published to CocoaPods!" \ No newline at end of file From 4d51f48e02932e4b0af102458df04da46f6d3260 Mon Sep 17 00:00:00 2001 From: Sam Beran Date: Wed, 27 Aug 2025 17:22:19 -0500 Subject: [PATCH 3/4] remove uneeded args from pod push --- .github/workflows/publish-pod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-pod.yml b/.github/workflows/publish-pod.yml index 4d89e6c..5e18c45 100644 --- a/.github/workflows/publish-pod.yml +++ b/.github/workflows/publish-pod.yml @@ -70,5 +70,5 @@ jobs: COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} run: | echo "Publishing version ${{ steps.get_version.outputs.VERSION }} to CocoaPods..." - pod trunk push Roboflow.podspec --allow-warnings + pod trunk push echo "Successfully published to CocoaPods!" \ No newline at end of file From 3d1f65c629fa019d9f78b5414621ef3e46303e9f Mon Sep 17 00:00:00 2001 From: Sam Beran Date: Wed, 27 Aug 2025 17:26:52 -0500 Subject: [PATCH 4/4] update README --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 1ee7edc..8c8b395 100644 --- a/README.md +++ b/README.md @@ -191,3 +191,16 @@ The test suite includes: - **Cross-platform Compatibility**: All tests run without UIKit dependencies, ensuring compatibility across Apple platforms Test images are located in `Tests/assets/` and the tests automatically download and cache models for testing. All tests are designed to run without requiring additional setup or configuration. + + + +## Publishing a New Version + +To publish a new version to CocoaPods: + +1. Update the version number in `Roboflow.podspec` +2. Issue a pull request and merge to the `main` branch +3. The GitHub Action will automatically: + - Validate the podspec + - Create and push a git tag for the version + - Publish to CocoaPods trunk