Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,21 @@ jobs:
- '.github/workflows/ci.yml'
- '.github/workflows/release-vitest-client.yml'

changes-swift:
runs-on: ubuntu-latest
outputs:
swift: ${{ steps.filter.outputs.swift }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
swift:
- 'clients/swift/**'
- '.github/workflows/ci.yml'
- '.github/workflows/release-swift-client.yml'

test-storybook-client:
runs-on: ubuntu-latest
needs: [lint, changes-storybook]
Expand Down Expand Up @@ -400,9 +415,32 @@ jobs:
VIZZLY_COMMIT_MESSAGE: ${{ github.event.pull_request.head.commit.message || github.event.head_commit.message }}
VIZZLY_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.event.head_commit.id }}

test-swift-client:
runs-on: macos-latest
needs: [lint, changes-swift]
if: needs.changes-swift.outputs.swift == 'true'

strategy:
matrix:
xcode-version: ['16.2', '16.4']

steps:
- uses: actions/checkout@v4

- name: Select Xcode version
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode-version }}.app

- name: Build Swift package
working-directory: ./clients/swift
run: swift build

- name: Run Swift tests
working-directory: ./clients/swift
run: swift test

ci-check:
runs-on: ubuntu-latest
needs: [lint, test, test-site, test-reporter, changes-ruby, test-ruby-client, changes-storybook, test-storybook-client, changes-static-site, test-static-site-client, changes-vitest, test-vitest-client]
needs: [lint, test, test-site, test-reporter, changes-ruby, test-ruby-client, changes-storybook, test-storybook-client, changes-static-site, test-static-site-client, changes-vitest, test-vitest-client, changes-swift, test-swift-client]
if: always()
steps:
- name: Check if all jobs passed
Expand Down Expand Up @@ -434,4 +472,9 @@ jobs:
exit 1
fi

if [[ "${{ needs.changes-swift.outputs.swift }}" == "true" && "${{ needs.test-swift-client.result }}" == "failure" ]]; then
echo "Swift client tests failed"
exit 1
fi

echo "All jobs passed"
177 changes: 177 additions & 0 deletions .github/workflows/release-swift-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: Release Swift Client

on:
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major

jobs:
release:
runs-on: macos-latest
permissions:
contents: write
id-token: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_PAT || secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Select Xcode version
run: sudo xcode-select -s /Applications/Xcode_16.4.app

- name: Configure git
run: |
git config --local user.email "${{ secrets.GIT_USER_EMAIL }}"
git config --local user.name "${{ secrets.GIT_USER_NAME }}"

- name: Get current version
id: current_version
working-directory: ./clients/swift
run: |
# Extract version from CHANGELOG.md
CURRENT_VERSION=$(grep -m 1 "## \[" CHANGELOG.md | sed 's/## \[\(.*\)\].*/\1/')
if [ -z "$CURRENT_VERSION" ]; then
CURRENT_VERSION="0.1.0"
fi
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT

- name: Calculate new version
id: new_version
run: |
CURRENT="${{ steps.current_version.outputs.version }}"

# Validate version format (X.Y.Z)
if ! [[ "$CURRENT" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Invalid version format '$CURRENT'. Expected X.Y.Z"
exit 1
fi

IFS='.' read -r -a parts <<< "$CURRENT"

case "${{ github.event.inputs.version_type }}" in
major)
NEW_VERSION="$((parts[0] + 1)).0.0"
;;
minor)
NEW_VERSION="${parts[0]}.$((parts[1] + 1)).0"
;;
patch)
NEW_VERSION="${parts[0]}.${parts[1]}.$((parts[2] + 1))"
;;
esac

echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "tag=swift/v$NEW_VERSION" >> $GITHUB_OUTPUT

- name: Generate changelog with Claude
id: changelog
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
prompt: |
Generate release notes for the Vizzly Swift SDK v${{ steps.new_version.outputs.version }}.

Context:
- Client location: `clients/swift/`
- Previous tag: `swift/v${{ steps.current_version.outputs.version }}`
- New version: `${{ steps.new_version.outputs.version }}`
- This is a monorepo with multiple clients and a CLI

Instructions:
1. Use git commands (via Bash tool) to get commits since last swift/* tag
2. Analyze which commits are relevant to `clients/swift/`
3. Read the code changes if needed to understand impact
4. Generate user-friendly release notes with categories: Added, Changed, Fixed
5. Focus on user-facing changes only
6. If no relevant changes, output: "No changes to Swift client in this release"

Save the changelog to `clients/swift/CHANGELOG-RELEASE.md` with this format:

## What's Changed

### Added
- New features

### Changed
- Breaking or notable changes

### Fixed
- Bug fixes

**Full Changelog**: https://github.com/vizzly-testing/cli/compare/swift/v${{ steps.current_version.outputs.version }}...swift/v${{ steps.new_version.outputs.version }}
claude_args: '--allowed-tools "Bash(git:*)"'

- name: Update CHANGELOG.md
working-directory: ./clients/swift
run: |
# Check if changelog was generated successfully
if [ ! -f CHANGELOG-RELEASE.md ]; then
echo "Warning: CHANGELOG-RELEASE.md not found, creating fallback changelog"
cat > CHANGELOG-RELEASE.md << 'EOF'
## What's Changed

Release v${{ steps.new_version.outputs.version }}

See the full diff for detailed changes.
EOF
fi

# Prepend new release to CHANGELOG.md
echo -e "# Vizzly Swift SDK Changelog\n" > CHANGELOG-NEW.md
echo "## [${{ steps.new_version.outputs.version }}] - $(date +%Y-%m-%d)" >> CHANGELOG-NEW.md
echo "" >> CHANGELOG-NEW.md
cat CHANGELOG-RELEASE.md >> CHANGELOG-NEW.md
echo "" >> CHANGELOG-NEW.md
tail -n +2 CHANGELOG.md >> CHANGELOG-NEW.md
mv CHANGELOG-NEW.md CHANGELOG.md
rm CHANGELOG-RELEASE.md

- name: Build Swift package
working-directory: ./clients/swift
run: swift build

- name: Run tests
working-directory: ./clients/swift
run: swift test

- name: Commit and push changes
run: |
git add clients/swift/CHANGELOG.md
git commit -m "πŸ”– Swift client v${{ steps.new_version.outputs.version }}"
git push origin main
git tag "${{ steps.new_version.outputs.tag }}"
git push origin "${{ steps.new_version.outputs.tag }}"

- name: Read changelog for release
id: release_notes
working-directory: ./clients/swift
run: |
# Extract just this version's changelog
CHANGELOG=$(sed -n '/## \[${{ steps.new_version.outputs.version }}\]/,/## \[/p' CHANGELOG.md | sed '$ d')
{
echo 'notes<<CHANGELOG_EOF'
echo "$CHANGELOG"
echo 'CHANGELOG_EOF'
} >> $GITHUB_OUTPUT

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.new_version.outputs.tag }}
name: πŸ“± Swift SDK v${{ steps.new_version.outputs.version }}
body: ${{ steps.release_notes.outputs.notes }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions clients/swift/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Swift Package Manager
.build/
*.xcodeproj
.swiftpm/

# Xcode
xcuserdata/
*.xcworkspace
!default.xcworkspace

# macOS
.DS_Store

# Swift
*.swiftmodule
*.swiftdoc
20 changes: 20 additions & 0 deletions clients/swift/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Changelog

All notable changes to the Vizzly Swift SDK will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added
- Initial Swift SDK implementation
- Core `VizzlyClient` class with HTTP communication
- Auto-discovery of TDD server via `.vizzly/server.json`
- XCTest integration extensions for `XCUIApplication`, `XCUIElement`, and `XCTestCase`
- Automatic metadata capture (platform, device, viewport)
- iOS and macOS support
- Environment variable configuration support
- Graceful error handling and client disabling
- Comprehensive example UI tests
- Full documentation and README
Loading