Skip to content

Commit

Permalink
Merge branch 'main' into jigar/deeplink-ios
Browse files Browse the repository at this point in the history
  • Loading branch information
jigar-f committed Dec 19, 2024
2 parents 429bb09 + 2377a8f commit b1b3268
Show file tree
Hide file tree
Showing 32 changed files with 1,020 additions and 361 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ jobs:
target: aab
- os: ubuntu-latest
platform: linux
# - os: macos-latest
# platform: ios
- os: macos-latest
platform: ios
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
p12-file-base64: ${{ secrets.MACOS_BNS_CERT }}
p12-password: ${{ secrets.MACOS_BNS_CERT_PASS }}

- name: Install the Apple certificate and provisioning profile
- name: Install the Apple certificate and provisioning profile IOS
if: matrix.platform == 'ios'
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.IOS_CERTIFICATE_P12_BASE64 }}
Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
echo -n "$BUILD_TUNNEL_PROVISION_PROFILE_BASE64" | base64 --decode -o $TPP_PATH
cp $TPP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
# Create ExportOptions.plist
# Create ExportOptions.plist
echo "$EXPORT_OPTIONS" | base64 --decode > "$EXPORT_OPTIONS_PATH"
- name: Setup Sentry CLI on Android
Expand Down Expand Up @@ -196,7 +196,6 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: "stable"

- run: flutter --version

- name: Setup JDK
Expand Down Expand Up @@ -293,10 +292,16 @@ jobs:
VERSION: ${{ env.version }}
run: |
make ${{ matrix.platform }}-${{ matrix.target }}-release
@echo "Generating debug symbols"
make debug-symbols
- name: Build Flutter app
- name: Generate debug symbols
if: matrix.platform == 'android' && matrix.target == 'aab'
run: make debug-symbols

- name: Setup Sentry CLI on IOS
if: matrix.platform == 'ios'
uses: mathieu-bour/setup-sentry-cli@v2

- name: Build Flutter app (iOS, Linux, macOS)
if: matrix.platform != 'windows' && matrix.platform != 'android'
run: make ${{ matrix.platform }}-release
env:
Expand Down
65 changes: 36 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,31 @@ jobs:
vf = 'version-android-dev.txt'
version = '9999.99.99-dev'
else:
a = ref.strip().replace('refs/tags/lantern-', '')
parts = a.split('-',1)
suffix = parts[1] if len(parts)>1 else ''
beta = 'beta' in suffix
internal = 'internal' in suffix
if beta:
li = 'lantern-installer-preview'
vf = 'version-android-beta.txt'
version = parts[0]
elif internal:
li = 'lantern-installer-internal'
vf = 'version-android-internal.txt'
version = parts[0]
tag = ref.strip()
if tag.startswith('refs/tags/android-lantern-'):
a = tag.replace('refs/tags/android-lantern-', '')
elif tag.startswith('refs/tags/ios-lantern-'):
a = tag.replace('refs/tags/ios-lantern-', '')
elif tag.startswith('refs/tags/desktop-lantern-'):
a = tag.replace('refs/tags/desktop-lantern-', '')
else:
li = 'lantern-installer'
vf = 'version-android.txt'
version = a
a = tag.replace('refs/tags/lantern-', '')
parts = a.split('-',1)
suffix = parts[1] if len(parts)>1 else ''
beta = 'beta' in suffix
internal = 'internal' in suffix
if beta:
li = 'lantern-installer-preview'
vf = 'version-android-beta.txt'
version = parts[0]
elif internal:
li = 'lantern-installer-internal'
vf = 'version-android-internal.txt'
version = parts[0]
else:
li = 'lantern-installer'
vf = 'version-android.txt'
version = a
print('Setting version to ' + version)
print('Setting prefix to ' + li)
print('Setting version file to ' + vf)
Expand Down Expand Up @@ -141,19 +149,19 @@ jobs:
with:
name: android-aab-build

# - name: Download the IPA
# uses: actions/download-artifact@v4
# with:
# name: Lantern.ipa
- name: Download the IPA
uses: actions/download-artifact@v4
with:
name: Lantern.ipa

# - name: Upload Lantern to TestFlight
# uses: apple-actions/upload-testflight-build@v1
# if: (needs.set-version.outputs.prefix == 'lantern-installer-preview'|| needs.set-version.outputs.prefix == 'lantern-installer') && (needs.determine-platform.outputs.platform == 'ios' || needs.determine-platform.outputs.platform == 'all')
# with:
# app-path: Lantern.ipa
# issuer-id: ${{ secrets.APPSTORE_ISSUER_ID }}
# api-key-id: ${{ secrets.APPSTORE_API_KEY_ID }}
# api-private-key: ${{ secrets.APPSTORE_API_PRIVATE_KEY }}
- name: Upload Lantern to TestFlight
uses: apple-actions/upload-testflight-build@v1
if: (needs.set-version.outputs.prefix == 'lantern-installer-preview'|| needs.set-version.outputs.prefix == 'lantern-installer') && (needs.determine-platform.outputs.platform == 'ios' || needs.determine-platform.outputs.platform == 'all')
with:
app-path: Lantern.ipa
issuer-id: ${{ secrets.APPSTORE_ISSUER_ID }}
api-key-id: ${{ secrets.APPSTORE_API_KEY_ID }}
api-private-key: ${{ secrets.APPSTORE_API_PRIVATE_KEY }}

- name: Upload Android App bundle to Play Store (beta)
if: needs.set-version.outputs.prefix == 'lantern-installer-preview' && (needs.determine-platform.outputs.platform == 'android' || needs.determine-platform.outputs.platform == 'all')
Expand All @@ -166,7 +174,6 @@ jobs:
debugSymbols: ${{ github.workspace }}/build/outputs/debug-symbols/debug-symbols.zip
mappingFile: ${{ github.workspace }}/build/app/outputs/mapping/prodPlay/mapping.txt


- name: Upload Android App bundle to Play Store (production)
if: needs.set-version.outputs.prefix == 'lantern-installer' && (needs.determine-platform.outputs.platform == 'android' || needs.determine-platform.outputs.platform == 'all')
uses: r0adkll/upload-google-play@v1
Expand Down
23 changes: 11 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ $(ANDROID_LIB): $(GO_SOURCES)
-target=$(ANDROID_ARCH_GOMOBILE) \
-tags='headless lantern' -o=$(ANDROID_LIB) \
-androidapi=23 \
-ldflags="$(LDFLAGS) $(EXTRA_LDFLAGS)" \
-ldflags="-s -w $(LDFLAGS) $(EXTRA_LDFLAGS)" \
$(GOMOBILE_EXTRA_BUILD_FLAGS) \
github.com/getlantern/lantern-client/internalsdk github.com/getlantern/pathdb/testsupport github.com/getlantern/pathdb/minisql

Expand Down Expand Up @@ -436,7 +436,6 @@ $(MOBILE_BUNDLE): $(MOBILE_SOURCES) $(GO_SOURCES) $(MOBILE_ANDROID_LIB) require-

android-debug: $(MOBILE_DEBUG_APK)


debug-symbols:
@echo "Generating debug symbols for Android..."
cd android && ./gradlew zipDebugSymbols
Expand All @@ -449,13 +448,12 @@ set-version:
NEXT_BUILD=$$(($$CURRENT_BUILD + 1)); \
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $$NEXT_BUILD" $(INFO_PLIST)

#ios: macos build-framework ffigen

ios-release: set-version guard-SENTRY_AUTH_TOKEN guard-SENTRY_ORG guard-SENTRY_PROJECT_IOS pubget
@echo "Flutter Clean"
ios-release:require-version set-version guard-SENTRY_AUTH_TOKEN guard-SENTRY_ORG guard-SENTRY_PROJECT_IOS
flutter clean
@echo "Flutter pub get"
flutter pub get
@echo "Creating the Flutter iOS build..."
@echo "Creating the Flutter iOS build.set-version guard-SENTRY_AUTH_TOKEN guard-SENTRY_ORG guard-SENTRY_PROJECT_IOS.."
flutter build ipa --flavor prod --release --export-options-plist ./ExportOptions.plist
@echo "Uploading debug symbols to Sentry..."
export SENTRY_LOG_LEVEL=info
Expand Down Expand Up @@ -696,18 +694,19 @@ sourcedump: require-version

ios: assert-go-version install-gomobile
@echo "Nuking $(INTERNALSDK_FRAMEWORK_DIR) and $(MINISQL_FRAMEWORK_DIR)"
rm -Rf $(INTERNALSDK_FRAMEWORK_DIR) $(MINISQL_FRAMEWORK_DIR)
@echo "generating Ios.xcFramework"
go env -w 'GOPRIVATE=github.com/getlantern/*' && \
@rm -Rf $(INTERNALSDK_FRAMEWORK_DIR) $(MINISQL_FRAMEWORK_DIR)
@echo "Generating Ios.xcFramework"
@go env -w 'GOPRIVATE=github.com/getlantern/*' && \
gomobile init && \
gomobile bind -target=ios,iossimulator \
-tags='headless lantern ios netgo' \
-ldflags="$(LDFLAGS)" \
$(GOMOBILE_EXTRA_BUILD_FLAGS) \
github.com/getlantern/lantern-client/internalsdk github.com/getlantern/pathdb/testsupport github.com/getlantern/pathdb/minisql github.com/getlantern/lantern-client/internalsdk/ios
@echo "moving framework"
mkdir -p $(INTERNALSDK_FRAMEWORK_DIR)
mv ./$(INTERNALSDK_FRAMEWORK_NAME) $(INTERNALSDK_FRAMEWORK_DIR)/$(INTERNALSDK_FRAMEWORK_NAME)
@echo "Moving framework"
@mkdir -p $(INTERNALSDK_FRAMEWORK_DIR)
@mv ./$(INTERNALSDK_FRAMEWORK_NAME) $(INTERNALSDK_FRAMEWORK_DIR)/$(INTERNALSDK_FRAMEWORK_NAME)
@echo "Framework generated"

build-release-framework: assert-go-version install-gomobile
@echo "Nuking $(INTERNALSDK_FRAMEWORK_DIR) and $(MINISQL_FRAMEWORK_DIR)"
Expand Down
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ All these dependencies must be in your PATH. Some of this is Android specific, s
### 🚀 Setup Project:

* Install all prerequisites
* Run `git submodule update --init --recursive`
* Run `git lfs install && git pull`.
* Put the [app.env](https://my.1password.com/app#/everything/AllItems/whdjlkyj7ku6pumtyc7nh5vg4yadqasjh2hspgjgvgfllyekhcrq) file (Frontend vault) from 1Password in the repo root.
* Go to the **SDK MANAGER**
* Go to the **SDK MANAGER** (Tools->SDK Manager in Android Studio)
* Select **Android SDK**
* Check the SDK from android 5.0(LOLLIPOP) up to the Latest Version at the moment.
* Go to **SDK Tools** and check the option **Show Package Details**
* Go to the **SDK Tools** tab in the same window and check the option **Show Package Details**
* On the Android SDK Build-Tools, check from: SDK 30 up to the latest at the moment. (is optional if you wish to add more SDK alternatives such as 27.0, 28 or 29).
* On the NDK(Side by side) check the latest version of 22.x (not anything newer)
* Make sure that you have the latest **Android SDK Command-line Tools**
Expand All @@ -75,17 +74,17 @@ All these dependencies must be in your PATH. Some of this is Android specific, s
* Click on Apply and accept the Terms and Conditions.
* Open Xcode first time open Xcode and install necessary components
* Download Certificate and provisioning profile from 1Pass [Search [IOS Certificates and profiles](https://my.1password.com/vaults/all/allitems)]
* Lastly `Flutter Doctor` to confirm that your setup is correct and ready!
* Lastly `flutter doctor` to confirm that your setup is correct and ready!

### 🤖 Running the project on Android

* `make android-lib ANDROID_ARCH` (you need to generated liblantern-all.aar containing the Go backend code in order for the project to compile.)
* `flutter pub get`
* `make android` (you need to generated liblantern-all.aar containing the Go backend code in order for the project to compile.)
* `flutter run --flavor prod`

### 🍏 Running the project on iOS

* `make build-framework` (you need to generated Internalsdk.xcframework. containing the Go backend code in order for the project to compile.)
* `make ios` (you need to generated Internalsdk.xcframework. containing the Go backend code in order for the project to compile.)
* `flutter pub get`
* `flutter run --flavor prod`

Expand All @@ -108,6 +107,17 @@ All these dependencies must be in your PATH. Some of this is Android specific, s
* `flutter pub get`
* `flutter run --flavor prod` or if you are using android studio use desktop configuration

#### As a Command-Line Application

A command-line implementation of Lantern is defined in the `cli` directory.

* `go build -o lantern-cli ./cli`
* `./lantern-cli <arguments>` (run with `-h` or `--help` to see available arguments)

You will likely want to specify the `-addr` argument (e.g. `-addr localhost:8080`) to define where the local proxy should be available.

If you want to point at a specific remote proxy, consult `hit_proxy.bash` for an example on how to set up a config directory with specific proxy config.

### Running on emulators

You can easily run emulators directly from the command line with the following:
Expand Down
82 changes: 82 additions & 0 deletions cli/cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Command cli provides a command-line implementation of the Lantern client. Run this command with
// -h or --help to see all available arguments.
package main

import (
"context"
"os"
"os/signal"
"sync"
"syscall"
"time"

"github.com/getlantern/golog"
"github.com/getlantern/lantern-client/desktop/app"

"github.com/pterm/pterm"
)

var (
log = golog.LoggerFor("lantern")
)

type cliClient struct {
app *app.App
mu sync.Mutex
}

func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, os.Interrupt, syscall.SIGTERM)
go func() {
<-signalChan
pterm.Warning.Println("Received shutdown signal.")
cancel()
}()

client := &cliClient{}
client.start(ctx)
defer client.stop()

<-ctx.Done()
}

func (client *cliClient) start(ctx context.Context) {
client.mu.Lock()
defer client.mu.Unlock()
if client.app != nil {
pterm.Warning.Println("Lantern is already running")
return
}

// create new instance of Lantern app
app, err := app.NewApp()
if err != nil {
pterm.Error.Printf("Unable to initialize app: %v", err)
return
}
client.app = app

// Run Lantern in the background
go app.Run(ctx)
}

func (client *cliClient) stop() {
client.mu.Lock()
defer client.mu.Unlock()
if client.app == nil {
// Lantern is not running, no cleanup needed
return
}

pterm.Info.Println("Stopping Lantern...")
client.app.Exit(nil)
client.app = nil

// small delay to give Lantern time to cleanup
time.Sleep(1 * time.Second)
pterm.Success.Println("Lantern stopped successfully.")
}
Loading

0 comments on commit b1b3268

Please sign in to comment.