Skip to content

Extract fastlane automation to share it between SDKs#550

Closed
tonidero wants to merge 4 commits into
mainfrom
csdk-27
Closed

Extract fastlane automation to share it between SDKs#550
tonidero wants to merge 4 commits into
mainfrom
csdk-27

Conversation

@tonidero

@tonidero tonidero commented Jun 22, 2022

Copy link
Copy Markdown
Contributor

Description

https://revenuecats.atlassian.net/browse/CSDK-27

On this PR we change to use a common Fastfile with common automation that can be shared between our different SDKs. The current shared Fastfile lives on purchases-ios but I plan to extract it to a shared repo before merging this. I recommend reviewing that file as well in https://github.com/RevenueCat/purchases-ios/blob/csdk-27/fastlane/CommonFastfile or https://github.com/RevenueCat/purchases-ios/pull/1719/files#diff-e7a6ebeea31beaa1c5c15ea846d78d7902efbebd98655e084bf863a2712a489f

Also note that a release PR was created by using the bump lane here: #549

TODO

  • Point import of fastfile to common repo

@tonidero tonidero mentioned this pull request Jun 22, 2022
1 task
Comment thread fastlane/Fastfile

import_from_git(
url: "https://github.com/RevenueCat/purchases-ios.git",
branch: "csdk-27",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This needs to be updated. Once the common fastfile has been extracted to its own repo, I will do so.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When you create a new repo, here's a quick guide for SOC-2 compliance https://www.notion.so/revenuecat/Making-repositories-SOC-2-compliant-122f48c59e41455aa85ad11fcc343ace

Comment thread fastlane/Fastfile
new_version = options[:version]
fail ArgumentError, "missing version" unless new_version
previous_version = android_get_version_name(gradle_file: gradle_file_path)
android_set_version_name(version_name: new_version, gradle_file: gradle_file_path)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These functions came from a fastlane plugin. While this is probably more robust, I changed it to update the version number using the existing "manual" approach where we check for all occurrences of the previous version number and change them with the new one.

Comment thread fastlane/Fastfile
end

desc "Tag release version with latest if necessary"
lane :tag_release_with_latest_if_needed do |options|

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed this lane entirely, and I think we can probably remove the latest tag at some point. Unless anyone knows if we are using it for anything. We were not doing this on the iOS SDK, and to keep parity with the automation, I didn't add it, but I can add it to both if we think it's necessary, or only to android

Comment thread fastlane/README.md
# Available Actions

## Android
### bump

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These are all the lanes imported from the CommonFastfile.

Comment thread fastlane/.env.SAMPLE
GITHUB_PULL_REQUEST_TEAM_REVIEWERS=

# Needed for access to changelog and other git operations
GITHUB_TOKEN=

@tonidero tonidero Jun 22, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Honestly, we can use the same token here and the PR API token. I kept them separate since GITHUB_PULL_REQUEST_API_TOKEN is used by fastlane internally to create the PRs, while GITHUB_TOKEN is used on our side.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe we can add a comment here to suggest that? i.e.:

# Needed for access to changelog and other git operations
# It can be the same value as GITHUB_PULL_REQUEST_API_TOKEN

Comment thread .version
@@ -0,0 +1 @@
5.2.0-SNAPSHOT

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This technique was used in iOS and I thought it would be good to port to all our SDKs. Basically, a .version file in the root folder will always contain the current version. We can use that to substitute this string on all the files that contain the old version number with the new one. Since each platform has its own versioning system, this is a way to abstract that. Lmk if you have any concerns.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree 💯

Comment thread fastlane/README.md
[bundle exec] fastlane bump
```

Bump version, edit changelog, and create pull request

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note that this now does much more than before. Besides asking devs for a version number and updating that version number in the necessary places, this will also prompt devs to edit the CHANGELOG as part of the process, will create a release branch, commit changes, push it and create a PR. ❤️ automation!

@tonidero

Copy link
Copy Markdown
Contributor Author

Other than updating the repo and branch from where to pull the common fastfile, this should be good for review.

@aboedo aboedo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looking great so far!

Comment thread .version
@@ -0,0 +1 @@
5.2.0-SNAPSHOT

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree 💯

Comment thread RELEASING.md
1. Create a `fastlane/.env` file with your GitHub API token (see `fastlane/.env.SAMPLE`). This will be used to create the PR, so you should use your own token so the PR gets assigned to you.
2. Run `bundle exec fastlane bump`
1. Input new version number
2. Update CHANGELOG.latest.md to include the latest changes. Call out API changes (if any). You can use the existing CHANGELOG.md as a base for formatting. To compile the changelog, you can compare the changes between the base branch for the release (usually main) against the latest release, by checking https://github.com/revenuecat/purchases-android/compare/<latest_release>...<base_branch>. For example, https://github.com/revenuecat/purchases-android/compare/5.1.1...main.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looking forward to this being done automatically

Comment thread fastlane/.env.SAMPLE
GITHUB_PULL_REQUEST_TEAM_REVIEWERS=

# Needed for access to changelog and other git operations
GITHUB_TOKEN=

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe we can add a comment here to suggest that? i.e.:

# Needed for access to changelog and other git operations
# It can be the same value as GITHUB_PULL_REQUEST_API_TOKEN

Comment thread fastlane/Fastfile

import_from_git(
url: "https://github.com/RevenueCat/purchases-ios.git",
branch: "csdk-27",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When you create a new repo, here's a quick guide for SOC-2 compliance https://www.notion.so/revenuecat/Making-repositories-SOC-2-compliant-122f48c59e41455aa85ad11fcc343ace

Comment thread fastlane/Fastfile
Comment on lines +25 to +33
ENV["REPO_NAME"] = "purchases-android"
ENV["FILES_TO_UPDATE_VERSION_STRING"] = "
../library.gradle,
../common/src/main/java/com/revenuecat/purchases/common/Config.kt,
../.circleci/config.yml,
../.version,
../docs/index.html,
../gradle.properties
"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

❤️

@tonidero

Copy link
Copy Markdown
Contributor Author

I'm closing this one in favor of #557

@tonidero tonidero closed this Jul 18, 2022
@tonidero tonidero deleted the csdk-27 branch July 18, 2022 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants