Skip to content

Commit

Permalink
chore: Update sdk name and version to Flutter (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto authored Jan 9, 2024
1 parent d777ad1 commit 1d273d7
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 7 deletions.
11 changes: 8 additions & 3 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ Releasing
=========

1. Update the CHANGELOG.md with the version
2. Update the version in `pubspec.yaml`
2. Choose a tag name (e.g. `3.0.0`), this is the version number of the release.
1. Preview releases follow the pattern `3.0.0-alpha.1`, `3.0.0-beta.1`, `3.0.0-RC.1`
2. Execute the script with the tag's name, the script will update the version file and create a tag.

```bash
./scripts/prepare-release.sh 3.0.0
```
3. Go to [GH Releases](https://github.com/PostHog/posthog-android/releases)
4. Choose a tag name (e.g. `3.0.0`), this is the version number of the release (the tag must follow this format).
1. Preview releases follow the pattern `3.0.0-alpha.1`, `3.0.0-beta.1`, `3.0.0-RC.1`
4. Choose a tag name (e.g. `3.0.0`), same as step 2.
5. Choose a release name (e.g. `3.0.0`), ideally it matches the above.
6. Write a description of the release.
7. Publish the release.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.posthog.posthog_flutter

internal val postHogVersion = "4.0.0-alpha.1"
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class PosthogFlutterPlugin : FlutterPlugin, MethodCallHandler {
captureDeepLinks = false
captureApplicationLifecycleEvents = trackApplicationLifecycleEvents
debug = enableDebug
sdkName = "posthog-flutter"
sdkVersion = postHogVersion
}
PostHogAndroid.setup(applicationContext, config)

Expand Down
11 changes: 11 additions & 0 deletions ios/Classes/PostHogFlutterVersion.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// PostHogFlutterVersion.swift
// posthog_flutter
//
// Created by Manoel Aranda Neto on 08.01.24.
//

import Foundation

// This property is internal only
internal let postHogFlutterVersion = "4.0.0-alpha.1"
5 changes: 5 additions & 0 deletions ios/Classes/PosthogFlutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public class PosthogFlutterPlugin: NSObject, FlutterPlugin {
)
config.captureApplicationLifecycleEvents = postHogCaptureLifecyleEvents
config.captureScreenViews = false

// Update SDK name and version
postHogSdkName = "posthog-flutter"
postHogVersion = postHogFlutterVersion

PostHogSDK.shared.setup(config)
//
}
Expand Down
8 changes: 4 additions & 4 deletions ios/posthog_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
Pod::Spec.new do |s|
s.name = 'posthog_flutter'
s.version = '0.0.1'
s.summary = 'A new flutter plugin project.'
s.summary = 'The hassle-free way to add posthog to your Flutter app.'
s.description = <<-DESC
Postog flutter plugin
DESC
s.homepage = 'http://example.com'
s.homepage = 'https://posthog.com/'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.author = { 'PostHog' => 'engineering@posthog.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.dependency 'PostHog', '~> 3.0.0-alpha.5'
s.dependency 'PostHog', '~> 3.0.0-beta.2'
s.platform = :ios, '13.0'

# Flutter.framework does not contain a i386 slice.
Expand Down
20 changes: 20 additions & 0 deletions scripts/bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# ./scripts/bump-version.sh <new version>
# eg ./scripts/bump-version.sh "3.0.0-alpha.1"

set -eux

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR/..

NEW_VERSION="$1"

# Replace iOS `postHogFlutterVersion` with the given version
perl -pi -e "s/postHogFlutterVersion = \".*\"/postHogFlutterVersion = \"$NEW_VERSION\"/" ios/Classes/PostHogFlutterVersion.swift

# Replace Android `postHogVersion` with the given version
perl -pi -e "s/postHogVersion = \".*\"/postHogVersion = \"$NEW_VERSION\"/" android/src/main/kotlin/com/posthog/posthog_flutter/PostHogVersion.kt

# Replace Flutter `version` with the given version
perl -pi -e "s/^version: .*/version: $NEW_VERSION/" pubspec.yaml
14 changes: 14 additions & 0 deletions scripts/commit-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -euo pipefail

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR/..

if [[ $(git status) == *"nothing to commit"* ]]; then
echo "Nothing to commit."
else
echo "Going to push the changes."
git fetch
git commit -am "Update version"
git push
fi
14 changes: 14 additions & 0 deletions scripts/prepare-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -eux

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR/..

NEW_VERSION="$1"

# bump version
./scripts/bump-version.sh $NEW_VERSION

# commit changes
./scripts/commit-code.sh

0 comments on commit 1d273d7

Please sign in to comment.