Skip to content

Commit

Permalink
Merge branch 'main' into release/5.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vegaro committed Aug 31, 2022
2 parents ddcb8aa + ae22e5e commit 89f6b10
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 57 deletions.
88 changes: 40 additions & 48 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1
orbs:
rn: react-native-community/[email protected]
revenuecat: revenuecat/sdks-common-config@1.1.0
revenuecat: revenuecat/sdks-common-config@2.0.0

aliases:
release-tags: &release-tags
Expand All @@ -10,53 +10,19 @@ aliases:
ignore: /^.*-SNAPSHOT/
branches:
ignore: /.*/
release-branches: &release-branches
filters:
tags:
ignore: /.*/
branches:
only: /^release\/.*/

commands:
install-dependencies:
steps:
- run:
name: Yarn Install
command: yarn install --non-interactive --cache-folder /tmp/yarn

set_up_git_user:
description: Set git config parameters
steps:
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "RevenueCat CI"

trust-github-key:
steps:
- run:
name: Trust GitHub key
command: |
for ip in $(dig @8.8.8.8 github.com +short); \
do ssh-keyscan github.com,$ip; \
ssh-keyscan $ip; \
done 2>/dev/null >> ~/.ssh/known_hosts
install-rubydocker-dependencies:
steps:
- restore_cache:
keys:
- v1-rubydocker-gem-cache-{{ checksum "Gemfile.lock" }}
- run:
name: Bundle install
command: bundle install --clean --path vendor/bundle
- save_cache:
key: v1-rubydocker-gem-cache-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
install-mac-dependencies:
steps:
- restore_cache:
keys:
- v1-gem-cache-{{ checksum "Gemfile.lock" }}
- run:
name: Bundle install
command: bundle install --clean --path vendor/bundle
- save_cache:
key: v1-gem-cache-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
copy-npm-rc:
steps:
- run:
Expand Down Expand Up @@ -90,8 +56,9 @@ jobs:
steps:
- checkout
- install-dependencies
- install-mac-dependencies
- set_up_git_user
- revenuecat/install-gem-mac-dependencies:
cache-version: v1
- revenuecat/setup-git-credentials
- run:
name: Build docs
command: bundle exec fastlane generate_docs
Expand Down Expand Up @@ -140,9 +107,10 @@ jobs:
- image: cimg/ruby:3.1.2
steps:
- checkout
- install-rubydocker-dependencies
- trust-github-key
- set_up_git_user
- revenuecat/install-gem-unix-dependencies:
cache-version: v1
- revenuecat/trust-github-key
- revenuecat/setup-git-credentials
- run:
name: Prepare next version
command: bundle exec fastlane prepare_next_version
Expand All @@ -155,21 +123,35 @@ jobs:
steps:
- checkout
- install-dependencies
- install-mac-dependencies
- trust-github-key
- revenuecat/install-gem-mac-dependencies:
cache-version: v1
- revenuecat/trust-github-key
- copy-npm-rc
- run:
name: release
command: bundle exec fastlane release

workflows:
test:
when:
not:
equal: [ scheduled_pipeline, << pipeline.trigger_source >> ]
jobs:
- analyse_js
- android
- ios
deploy:
when:
not:
equal: [ scheduled_pipeline, << pipeline.trigger_source >> ]
jobs:
- hold:
type: approval
<<: *release-branches
- revenuecat/tag-current-branch:
requires:
- hold
<<: *release-branches
- make-release:
<<: *release-tags
- prepare-next-version:
Expand All @@ -181,5 +163,15 @@ workflows:
requires:
- make-release
danger:
when:
not:
equal: [ scheduled_pipeline, << pipeline.trigger_source >> ]
jobs:
- revenuecat/danger
weekly-run-workflow:
when:
and:
- equal: [ scheduled_pipeline, << pipeline.trigger_source >> ]
- equal: [ "release-train", << pipeline.schedule.name >> ]
jobs:
- revenuecat/automatic-bump
6 changes: 2 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/RevenueCat/fastlane-plugin-revenuecat_internal
revision: 0acf0aaf142737e2c2b43c74d1fa1de6941ea822
revision: 562dbc8d71bba33ec58b5c999d15e4c39b09bc7f
specs:
fastlane-plugin-revenuecat_internal (0.1.0)

Expand Down Expand Up @@ -317,9 +317,7 @@ GEM
zeitwerk (2.6.0)

PLATFORMS
arm64-darwin-20
arm64-darwin-21
x86_64-darwin-21
ruby

DEPENDENCIES
cocoapods
Expand Down
20 changes: 17 additions & 3 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Releasing a version:

Automatic Releasing
=========
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.
1. Run `bundle exec fastlane bump`
1. Confirm base branch is correct
Expand All @@ -9,5 +9,19 @@
1. `bundle exec fastlane update_hybrid_common version:x.x.x` to set the purchases-hybrid-common version number if needed.
1. Run `npm run build` and make sure it works. If any issues appear, fix them first.
1. Wait until PR is approved (don't merge yet) and pull branch from origin (to make sure you've got all the changes locally)
1. Create a tag for the new release in the last commit of the branch and push the tag. The rest will be performed automatically by CircleCI. If the automation fails, you can revert to manually calling `bundle exec fastlane release`.
1. When the PR is approved, approve the hold job created in CircleCI. CircleCI will create a tag for the version. Alternatively, you can tag the last commit in the release branch and push it to the repository.
1. The rest will be performed automatically by CircleCI. If the automation fails, you can revert to manually calling `bundle exec fastlane release`.
1. After that, you can merge the release PR to main and merge the bump to the next snapshot version PR right after.

Hotfix Releases
=========
Sometimes you might need to release a patch on a version that's not the latest. Or sometimes there might have been commits on main that shouldn't be released, but the latest version has a big bug. For example, let's say the last version is 4.0.0, but there's a bug on 3.9.0 that needs to be released as a 3.9.1:

1. Open a PR with the fix, merge it to main.
1. Jump to 3.9.0 and create a new branch release/3.9.0. Push this branch since it will be used as base for the PR you will open in the next steps.
1. Run `bundle exec fastlane bump` as you would do with any release. This will create a new PR `release/3.9.1`. Make sure the base branch of the PR is pointing to `release/3.9.0` and that the PR is labeled with **DO NOT MERGE** (add it to the title too so it's not merged by mistake)
1. Locally, while in branch the release branch (`release/3.9.1` in this case), cherry pick the changes with your fix that you just merged to `main` using `git cherry-pick <sha_of_the_squashed_commit_in_main>`. Fix any conflicts if there are any. Push the cherry picked commit to the remote branch `release/3.9.1`.
1. When the PR is approved, **DO NOT MERGE IT**. Approve the hold job in CircleCI as you would do for any other release. If there is no hold job because the release is older than when we introduced that job, manually tag the last commit in `release/3.9.1` with `3.9.1`.
1. CircleCI will start the deployment process
1. Close the PR after the release has been completed and delete both `release/3.9.0` and `release/3.9.1` branches.
1. Remember to edit the CHANGELOG.md in `main` to include the version that has been just released
39 changes: 37 additions & 2 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ lane :bump do |options|
files_to_update_without_prerelease_modifiers: [],
repo_name: repo_name,
github_rate_limit: options[:github_rate_limit],
editor: options[:editor]
editor: options[:editor],
next_version: options[:next_version],
automatic_release: options[:automatic_release]
)
update_hybrids_versions_file(
versions_file_path: './VERSIONS.md',
Expand All @@ -35,6 +37,24 @@ lane :bump do |options|
push_to_git_remote(set_upstream: true)
end

desc "Automatically bumps version, edit changelog, and create pull request"
lane :automatic_bump do |options|
next_version, type_of_bump = determine_next_version_using_labels(
repo_name: repo_name,
github_rate_limit: options[:github_rate_limit]
)
options[:next_version] = next_version
options[:automatic_release] = true
if type_of_bump == :skip
UI.message('Skipping automatic bump since the next version doesn\'t include public facing changes')
next
elsif type_of_bump == :major
UI.message('Skipping automatic bump since the next version is a major release')
next
end
bump(options)
end

desc "Make github release"
lane :github_release do |options|
create_github_release(
Expand Down Expand Up @@ -205,6 +225,15 @@ lane :generate_docs do
end
end

desc "Tag current branch with current version number"
lane :tag_current_branch do |options|
version_number = current_version_number
check_no_git_tag_exists(version_number)

add_git_tag(tag: version_number)
push_git_tags(tag: version_number)
end

###############################################################################
# Helper functions 🤜🤛 #
###############################################################################
Expand All @@ -227,4 +256,10 @@ end

def current_version_number
File.read("../.version").strip
end
end

def check_no_git_tag_exists(version_number)
if git_tag_exists(tag: version_number, remote: true, remote_name: 'origin')
raise "git tag with version #{version_number} already exists!"
end
end
16 changes: 16 additions & 0 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do

Bump version, edit changelog, and create pull request

### automatic_bump

```sh
[bundle exec] fastlane automatic_bump
```

Automatically bumps version, edit changelog, and create pull request

### github_release

```sh
Expand Down Expand Up @@ -93,6 +101,14 @@ Update Hybrid Common, Build PurchaseTester, and updates download scripts. Calls

Generate docs

### tag_current_branch

```sh
[bundle exec] fastlane tag_current_branch
```

Tag current branch with current version number

----

This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
Expand Down

0 comments on commit 89f6b10

Please sign in to comment.