Skip to content
Open
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
65 changes: 56 additions & 9 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,65 @@ When in doubt about whether we will be interested in including a new feature in

## Releasing a new version

Open a pull request with the following changes:
### Preparing for a release

Before creating a release, ensure the following version strings are updated and synchronized:

1. Bump the [package version](https://github.com/Shopify/checkout-sheet-kit-swift/blob/main/Sources/ShopifyCheckoutSheetKit/ShopifyCheckoutSheetKit.swift#L27)
2. Bump the [podspec version](https://github.com/Shopify/checkout-sheet-kit-swift/blob/main/ShopifyCheckoutSheetKit.podspec#L2)
3. Add an entry to the top of the [CHANGELOG](../CHANGELOG.md)

Once you have merged a pull request with these changes, you will be ready to publish a new version.
**Important**: All three version strings must match exactly, including any pre-release suffixes (e.g., `-beta.1`, `-rc.1`).

### Version format

- **Production releases**: `X.Y.Z` (e.g., `3.4.0`)
- **Pre-releases**: `X.Y.Z-{alpha|beta|rc}.N` (e.g., `3.4.0-beta.1`, `3.4.0-rc.2`)

Pre-release suffixes ensure:
- CocoaPods users must explicitly opt-in to install pre-release versions
- Swift Package Manager doesn't treat them as the default "latest" version

### Creating a release

Navigate to https://github.com/Shopify/checkout-sheet-kit-swift/releases and click "Draft a new release", then complete the following steps:

#### For production releases (from `main` branch):

1. Ensure you're on the `main` branch
2. Create a tag for the new version (e.g., `3.4.0`)
3. Use the same tag as the release title
4. Document the full list of changes since the previous release, tagging merged pull requests where applicable
5. ✅ Check "Set as the latest release" to ensure Swift Package Manager identifies this as the latest release
6. Click "Publish release"

#### For pre-releases (from non-`main` branch):

1. Ensure you're on a feature/release branch (NOT `main`)
2. Create a tag with a pre-release suffix (e.g., `3.4.0-beta.1`, `3.4.0-rc.2`)
3. Use the same tag as the release title
4. Document the changes being tested in this pre-release
5. ✅ Check "Set as a pre-release" (NOT "Set as the latest release")
6. Click "Publish release"

### What happens after publishing

When you publish a release (production or pre-release), the [publish workflow](https://github.com/Shopify/checkout-sheet-kit-swift/actions/workflows/publish.yml) will automatically:

1. **Validate versions**: Ensures podspec, Swift package, and git tag versions all match
2. **Deploy to CocoaPods**: Publishes the version to CocoaPods trunk
3. **Swift Package Manager**: Automatically works from the git tag (no deployment needed)

### Using pre-releases

For users to install a pre-release version:

To do so, navigate to
https://github.com/Shopify/checkout-sheet-kit-swift/releases and click "Draft a new release" then complete the following steps:
**CocoaPods** - Must specify the exact version in Podfile:
```ruby
pod 'ShopifyCheckoutSheetKit', '3.4.0-beta.1'
```

1. Create a tag for the new version
2. Use the same tag as the name for the version
3. Document a full list of changes since the previous release, tagging merged pull requests where applicable, in the description box.
4. Check "Set as the latest release" to ensure Swift Package Manager identifies this as the latest release.
5. When ready, click "Publish release". This will ensure SPM can identity the latest version and it will kickstart the [CI process](https://github.com/Shopify/checkout-sheet-kit-swift/actions/workflows/deploy.yml) to publish a new version of the CocoaPod.
**Swift Package Manager** - Must specify the exact version:
```swift
.package(url: "https://github.com/Shopify/checkout-sheet-kit-swift", exact: "3.4.0-beta.1")
```
26 changes: 0 additions & 26 deletions .github/workflows/deploy.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy to CocoaPods and Swift Package Manager

on:
release:
types:
- published
workflow_dispatch:

jobs:
cocoapods:
runs-on: macos-latest

steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Validate versions match
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only difference here is this validate task

run: |
PODSPEC_VERSION=$(grep -E "s.version\s*=\s*" ShopifyCheckoutSheetKit.podspec | sed -E 's/.*"([^"]+)".*/\1/')
SWIFT_VERSION=$(grep -E "public let version = " Sources/ShopifyCheckoutSheetKit/ShopifyCheckoutSheetKit.swift | sed -E 's/.*"([^"]+)".*/\1/')
GIT_TAG="${{ github.event.release.tag_name }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could be very defensive against failing to extract these vars, and do something like

    if [ -z "$PODSPEC_VERSION" ]; then
        echo "Error: Could not extract version from ShopifyCheckoutSheetKit.podspec"
        echo "Expected format: s.version = \"X.Y.Z\""
        exit 1
      fi

      if [ -z "$SWIFT_VERSION" ]; then
        echo "Error: Could not extract version from ShopifyCheckoutSheetKit.swift"
        echo "Expected format: public let version = \"X.Y.Z\""
        exit 1
      fi

But feels alright as it is


echo "Podspec version: $PODSPEC_VERSION"
echo "Swift version: $SWIFT_VERSION"
echo "Git tag: $GIT_TAG"

if [ "$PODSPEC_VERSION" != "$GIT_TAG" ]; then
echo "❌ Error: Podspec version ($PODSPEC_VERSION) doesn't match Git tag ($GIT_TAG)"
exit 1
fi

if [ "$SWIFT_VERSION" != "$GIT_TAG" ]; then
echo "❌ Error: Swift version ($SWIFT_VERSION) doesn't match Git tag ($GIT_TAG)"
exit 1
fi

echo "✅ All versions match!"

- uses: ruby/setup-ruby@0481980f17b760ef6bca5e8c55809102a0af1e5a # v1.263.0
with:
bundler-cache: true

- name: Deploy to Cocoapods
run: |
set -eo pipefail
bundle exec pod lib lint --allow-warnings --verbose
bundle exec pod trunk push --allow-warnings --verbose
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}