Skip to content

Commit

Permalink
Merge branch 'main' into remove-purchasesfactory
Browse files Browse the repository at this point in the history
  • Loading branch information
JayShortway committed Jun 20, 2024
2 parents a8fc55a + a384257 commit 9589e82
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 32 deletions.
40 changes: 9 additions & 31 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,6 @@ commands:
name: Install Android SDK platform tools
command: sdkmanager "platform-tools"

require-snapshot-version:
description: Check that the current version is a SNAPSHOT version
steps:
- run:
name: Check that the current version is a SNAPSHOT version
command: |
set -euo pipefail
file_path="gradle/libs.versions.toml"
version=$(grep 'revenuecat-kmp = ' "$file_path" | awk -F ' = ' '{print $2}' | tr -d '"')
if [[ ! "$version" =~ -SNAPSHOT$ ]]; then
echo "$version is not a SNAPSHOT version. Exiting..."
exit 1
else
echo "$version is a SNAPSHOT version. Proceeding..."
fi
parameters:
action:
type: enum
Expand Down Expand Up @@ -81,35 +65,29 @@ jobs:
automatic_release:<< pipeline.parameters.automatic >>
publish:
description: "Publishes a release, either SNAPSHOT or final."
description: "Publishes the SDK, either a SNAPSHOT or release version."
executor: xcode15
parameters:
snapshot:
description: Whether to publish a SNAPSHOT version. Will publish a final release if set to false.
type: boolean
steps:
- checkout
- when:
condition: << parameters.snapshot >>
steps:
- require-snapshot-version
- install-android-sdk-on-macos
- android/restore-gradle-cache
- android/restore-build-cache
- run:
name: Set environment variables for publishing
command: |
echo 'export ORG_GRADLE_PROJECT_mavenCentralUsername="$SONATYPE_NEXUS_TOKEN_USERNAME"' >> "$BASH_ENV"
echo 'export ORG_GRADLE_PROJECT_mavenCentralPassword="$SONATYPE_NEXUS_TOKEN_PASSWORD"' >> "$BASH_ENV"
echo 'export ORG_GRADLE_PROJECT_signingInMemoryKey="$SIGNING_GPG_IN_MEMORY"' >> "$BASH_ENV"
echo 'export ORG_GRADLE_PROJECT_signingInMemoryKeyPassword="$GPG_SIGNING_KEY_PW_NEW"' >> "$BASH_ENV"
# TODO Remove this condition to allow releasing non-SNAPSHOT versions.
- when:
condition: << parameters.snapshot >>
steps:
- run:
name: Publish to Maven Central
command: ./gradlew publishAllPublicationsToMavenCentralRepository
name: "Publish snapshot to Sonatype's snapshots repository"
command: bundle exec fastlane publish_if_snapshot
- unless:
condition: << parameters.snapshot >>
steps:
- run:
name: "Publish release to Maven Central"
command: bundle exec fastlane publish_if_release
- android/save-gradle-cache
- android/save-build-cache

Expand Down
41 changes: 41 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,26 @@ lane :tag_current_branch do |options|
push_git_tags(tag: version_number)
end

desc "Publish the SDK if the current version is a SNAPSHOT version"
lane :publish_if_snapshot do |options|
version = current_version_number
if version.end_with?("-SNAPSHOT")
publish
else
UI.user_error!("The current version '#{version}' is not a SNAPSHOT version.")
end
end

desc "Publish the SDK if the current version is a release version"
lane :publish_if_release do |options|
version = current_version_number
if version.end_with?("-SNAPSHOT")
UI.user_error!("The current version '#{version}' is a SNAPSHOT version.")
else
publish
end
end

desc "Creates a GitHub release for the current version"
lane :github_release_current_version do |options|
github_release(version: current_version_number)
Expand Down Expand Up @@ -155,3 +175,24 @@ def get_phc_version
raise "git tag with version #{version_number} already exists!"
end
end

# Publishes the SDK. If the current version is a SNAPSHOT version, it will be published
# to Sonatype's snapshots repository, otherwise it will be published to Maven Central.
#
# This requires the following environment variables to be set:
# - SONATYPE_NEXUS_TOKEN_USERNAME
# - SONATYPE_NEXUS_TOKEN_PASSWORD
# - SIGNING_GPG_IN_MEMORY
# - GPG_SIGNING_KEY_PW_NEW
#
# These are set on CircleCI by providing the maven-central-publishing context when
# running the publish job.
def publish
version = current_version_number
UI.verbose("Publishing #{version}")
ENV["ORG_GRADLE_PROJECT_mavenCentralUsername"] = ENV["SONATYPE_NEXUS_TOKEN_USERNAME"]
ENV["ORG_GRADLE_PROJECT_mavenCentralPassword"] = ENV["SONATYPE_NEXUS_TOKEN_PASSWORD"]
ENV["ORG_GRADLE_PROJECT_signingInMemoryKey"] = ENV["SIGNING_GPG_IN_MEMORY"]
ENV["ORG_GRADLE_PROJECT_signingInMemoryKeyPassword"] = ENV["GPG_SIGNING_KEY_PW_NEW"]
gradle(task: "publishAllPublicationsToMavenCentralRepository")
end
42 changes: 41 additions & 1 deletion fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Bumps version, edits changelog, and creates pull request
[bundle exec] fastlane automatic_bump
```

Automatically bumps version, edits changelog, and creates pull request
Automatically determines next version, bumps it, edits changelog, and creates pull request

### update_hybrid_common

Expand All @@ -38,6 +38,46 @@ Automatically bumps version, edits changelog, and creates pull request

Update purchases-hybrid-common dependency

### tag_current_branch

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

Tags the current branch with the current version number

### publish_if_snapshot

```sh
[bundle exec] fastlane publish_if_snapshot
```

Publish the SDK if the current version is a SNAPSHOT version

### publish_if_release

```sh
[bundle exec] fastlane publish_if_release
```

Publish the SDK if the current version is a release version

### github_release_current_version

```sh
[bundle exec] fastlane github_release_current_version
```

Creates a GitHub release for the current version

### github_release

```sh
[bundle exec] fastlane github_release
```

Creates a GitHub release

----

This README.md is auto-generated and will be re-generated every time [
Expand Down

0 comments on commit 9589e82

Please sign in to comment.