Skip to content
Closed
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
33 changes: 33 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,32 @@ jobs:
name: release
command: bundle exec fastlane release_purchases_ui_flutter

make-release-bc7:
description: "Publishes a new version of purchases_flutter with bc7 to pub.dev"
docker:
- image: ghcr.io/cirruslabs/flutter:stable
steps:
- checkout
- revenuecat/install-gem-unix-dependencies:
cache-version: v1
- revenuecat/trust-github-key
- run:
name: release
command: bundle exec fastlane release_bc7

make-release-purchases-flutter-ui-bc7:
description: "Publishes a new version of purchases_ui_flutter with bc7 to pub.dev"
docker:
- image: ghcr.io/cirruslabs/flutter:stable
steps:
- checkout
- revenuecat/install-gem-unix-dependencies:
cache-version: v1
- revenuecat/trust-github-key
- run:
name: release
command: bundle exec fastlane release_purchases_ui_bc7_flutter

github_release:
description: "Creates a github release with the current version"
docker:
Expand Down Expand Up @@ -521,10 +547,17 @@ workflows:
requires:
- make-release
<<: *release-tags
- make-release-bc7: *release-tags
- make-release-purchases-flutter-ui-bc7:
requires:
- make-release-bc7
<<: *release-tags
- github_release:
requires:
- make-release
- make-release-purchases-flutter-ui
- make-release-bc7
- make-release-purchases-flutter-ui-bc7
<<: *release-tags
weekly-run-workflow:
when:
Expand Down
118 changes: 118 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ lane :bump do |options|
versions_file_path: versions_path,
is_prerelease: options[:is_prerelease]
)

# Update CHANGELOG.md to include BC7 version
update_changelog_with_bc7_version(changelog_path, current_version_number)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have to do this because pub.dev validates that the version number appears in the changelog. This seemed the simpler way to bypass this validation.

commit_current_changes(commit_message: 'Update CHANGELOG.md with BC7 version')

update_hybrids_versions_file(
versions_file_path: versions_path,
new_sdk_version: current_version_number,
Expand Down Expand Up @@ -114,6 +119,72 @@ lane :release_purchases_ui_flutter do |options|
end
end

desc "Create BC7 variant release"
lane :release_bc7 do |options|
# Modify files in-place for BC7 variant
UI.message("Creating BC7 variant of purchases_flutter in-place...")

# Apply BC7 modifications
apply_bc7_modifications('..', false)

# Temporarily commit changes to satisfy git clean check
Dir.chdir('..') do
sh('git', 'add', 'pubspec.yaml', 'android/build.gradle')
sh('git', 'commit', '-m', '[TEMPORARY] BC7 modifications for publishing')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to commit the files with changes, otherwise it will fail pub.dev validation. This should be fine during CI, since we won't be pushing this commit. But we reset the changes at the end anyway... It might not be undone if the flutter pub publish command fails for any reason though, but this should be fine when run on CI as I mentioned.

end

# Dry run
Dir.chdir('..') do
Copy link
Contributor

Choose a reason for hiding this comment

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

I was just thinking it might be nice to be able to reuse existing code a bit more, for example calling the regular release lane here. But I also realized this would often require passing some new parameters and would probably not be worth the effort. Since it should be temporary in the grand scheme of things anyways I think this approach makes sense as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah... I think we could try to refactor it to avoid repeating code, but as you said, this will go away in a few months at most, so might be easier to clean it up later if we keep it split.

sh('flutter', 'pub', 'publish', '--dry-run')
end

# Setup credentials and publish
setup_credentials_file
Dir.chdir('..') do
sh('flutter', 'pub', 'publish', '--force')
end

UI.success("✅ Successfully published purchases_bc7_flutter")

# Undo the temporary commit
Dir.chdir('..') do
sh('git', 'reset', 'HEAD~1')
end
end

desc "Create purchases_ui_bc7_flutter release"
lane :release_purchases_ui_bc7_flutter do |options|
# Modify files in-place for BC7 variant
UI.message("Creating BC7 variant of purchases_ui_flutter in-place...")

# Apply BC7 modifications
apply_bc7_modifications('../purchases_ui_flutter', true)

# Temporarily commit changes to satisfy git clean check
Dir.chdir('../purchases_ui_flutter') do
sh('git', 'add', 'pubspec.yaml', 'android/build.gradle')
sh('git', 'commit', '-m', '[TEMPORARY] BC7 modifications for publishing')
end

# Dry run
Dir.chdir('../purchases_ui_flutter') do
sh('flutter', 'pub', 'publish', '--dry-run')
end

# Setup credentials and publish
setup_credentials_file
Dir.chdir('../purchases_ui_flutter') do
sh('flutter', 'pub', 'publish', '--force')
end

UI.success("✅ Successfully published purchases_ui_bc7_flutter")

# Undo the temporary commit
Dir.chdir('../purchases_ui_flutter') do
sh('git', 'reset', 'HEAD~1')
end
end

desc "Make github release with current version number"
lane :github_release_current_version do |options|
github_release(version: current_version_number)
Expand Down Expand Up @@ -304,3 +375,50 @@ def check_no_git_tag_exists(version_number)
raise "git tag with version #{version_number} already exists!"
end
end

def update_changelog_with_bc7_version(changelog_path, version)
changelog_file_path = File.join('..', changelog_path)
changelog_content = File.read(changelog_file_path)

# Find the first occurrence of "## X.Y.Z" and replace with "## X.Y.Z & X.Y.Z+bc7"
changelog_content.sub!(/^## (#{Regexp.escape(version)})$/, "## \\1 & \\1+bc7")

File.write(changelog_file_path, changelog_content)
UI.success("✅ Updated CHANGELOG.md to include BC7 version")
end

def apply_bc7_modifications(source_dir, is_ui_library)
# Update pubspec.yaml - append -bc7 to version
pubspec_path = File.join(source_dir, 'pubspec.yaml')
pubspec_content = File.read(pubspec_path)

UI.message("🔧 Updating pubspec.yaml for UI library BC7 variant...")
# Append -bc7 to version number
pubspec_content.gsub!(/^version:\s+(\S+)/, 'version: \1+bc7')

File.write(pubspec_path, pubspec_content)
UI.success("✅ Updated pubspec.yaml with BC7 version")

# Update Android build.gradle - change dependency to BC7 variant
build_gradle_path = File.join(source_dir, 'android', 'build.gradle')
build_gradle_content = File.read(build_gradle_path)

if is_ui_library
UI.message("🔧 Updating Android build.gradle for UI library...")
# Change purchases-hybrid-common-ui to purchases-hybrid-common-ui-bc7
build_gradle_content.gsub!(
'com.revenuecat.purchases:purchases-hybrid-common-ui:',
'com.revenuecat.purchases:purchases-hybrid-common-ui-bc7:'
)
else
UI.message("🔧 Updating Android build.gradle for main library...")
# Change purchases-hybrid-common to purchases-hybrid-common-bc7
build_gradle_content.gsub!(
'com.revenuecat.purchases:purchases-hybrid-common:',
'com.revenuecat.purchases:purchases-hybrid-common-bc7:'
)
end

File.write(build_gradle_path, build_gradle_content)
UI.success("✅ Updated Android build.gradle with BC7 dependency")
end
16 changes: 16 additions & 0 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ Create release

Create purchases_ui_flutter release

### release_bc7

```sh
[bundle exec] fastlane release_bc7
```

Create BC7 variant release

### release_purchases_ui_bc7_flutter

```sh
[bundle exec] fastlane release_purchases_ui_bc7_flutter
```

Create purchases_ui_bc7_flutter release

### github_release_current_version

```sh
Expand Down