-
Notifications
You must be signed in to change notification settings - Fork 18
Use netbird as submodule #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
doromaraujo
wants to merge
11
commits into
main
Choose a base branch
from
use-netbird-submodule
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e3c2601
Add netbird SDK project as submodule
doromaraujo dfa0842
Set netbird submodule to v0.64.2 tag
doromaraujo d624d8b
Change build-go-lib script to use submodule path
doromaraujo 30359cc
Add some validation steps to build-go-lib
doromaraujo a75c279
Separate build for iOS and tvOS in different scripts
doromaraujo c926cdf
Remove old build file
doromaraujo 5de97fe
Update submodule to v0.64.3
doromaraujo 5f0373c
Add platform parameter to build-ios-lib.sh
doromaraujo bd9fe9e
Rename build-ios-lib.sh back to build-go-lib.sh
doromaraujo bb141ab
Adapt build to use submodule
doromaraujo 653cbad
Configure build to use the configured submodule commit
doromaraujo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [submodule "libs/netbird"] | ||
| path = libs/netbird | ||
| url = https://github.com/netbirdio/netbird |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,145 @@ | ||
| #!/bin/bash | ||
| set -e | ||
| # Script to build NetBird iOS/tvOS bindings using gomobile | ||
| # | ||
| # Usage: ./build-go-lib.sh [platform] [version] | ||
| # | ||
| # Parameters: | ||
| # 1. platform (optional): Target platform(s) to build for | ||
| # - ios : Build for iOS and iOS Simulator only (uses standard gomobile) | ||
| # - tvos : Build for tvOS and tvOS Simulator only (uses gomobile-netbird) | ||
| # - both : Build for all platforms (uses gomobile-netbird) [default] | ||
| # | ||
| # 2. version (optional): Git tag to build | ||
| # - If provided, validates the tag exists in the submodule and checks it out | ||
| # - If omitted and current commit is exactly tagged, uses that tag | ||
| # - Otherwise, uses "dev-<short-hash>" (or "ci-<short-hash>" in GitHub Actions) | ||
| # - Leading 'v' is stripped from semver tags (v1.2.3 -> 1.2.3) | ||
| # | ||
| # Examples: | ||
| # ./build-go-lib.sh # Build both platforms using current commit | ||
| # ./build-go-lib.sh ios # Build iOS only using current commit | ||
| # ./build-go-lib.sh tvos v0.64.1 # Build tvOS only using tag v0.64.1 | ||
| # ./build-go-lib.sh both v0.64.1 # Build both platforms using tag v0.64.1 | ||
| # | ||
| # Output: | ||
| # Creates NetBirdSDK.xcframework in the current directory | ||
|
|
||
| rn_app_path=$(pwd) | ||
| netbirdPath=$1 | ||
| if [ -z "${1+x}" ] | ||
| then | ||
| netbirdPath=${GOPATH}/src/github.com/netbirdio/netbird | ||
| fi | ||
| set -euo pipefail | ||
|
|
||
| version=$2 | ||
| if [ -z "${2+x}" ] | ||
| then | ||
| version=development | ||
| fi | ||
| # Normalize semantic versions to drop a leading 'v' (e.g., v1.2.3 -> 1.2.3). | ||
| # Only strips if the string starts with 'v' followed by a digit, so it won't affect | ||
| # dev/ci strings or other non-semver values. | ||
| normalize_version() { | ||
| local ver="$1" | ||
| if [[ "$ver" =~ ^v[0-9] ]]; then | ||
| ver="${ver#v}" | ||
| fi | ||
| echo "$ver" | ||
| } | ||
|
|
||
| cd $netbirdPath | ||
| # Checkout a git tag in the specified repository path | ||
| # Tries the tag as provided, then with 'v' prefix if needed | ||
| checkout_tag() { | ||
| local tag="$1" | ||
| local repo_path="$2" | ||
|
|
||
| gomobile-netbird init | ||
| CGO_ENABLED=0 gomobile-netbird bind -target=ios,iossimulator,tvos,tvossimulator -bundleid=io.netbird.framework -ldflags="-X github.com/netbirdio/netbird/version.version=$version" -o $rn_app_path/NetBirdSDK.xcframework $netbirdPath/client/ios/NetBirdSDK | ||
| if git -C "$repo_path" rev-parse "refs/tags/$tag" >/dev/null 2>&1; then | ||
| git -C "$repo_path" checkout "$tag" | ||
| return 0 | ||
| fi | ||
|
|
||
| cd - | ||
| # Try with 'v' prefix if not provided | ||
| if [[ ! "$tag" =~ ^v ]] && git -C "$repo_path" rev-parse "refs/tags/v$tag" >/dev/null 2>&1; then | ||
| git -C "$repo_path" checkout "v$tag" | ||
| return 0 | ||
| fi | ||
|
|
||
| echo "Error: Tag '$tag' does not exist" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| # Get version string, optionally checking out a tag if provided | ||
| get_version() { | ||
| local version_arg="${1:-}" | ||
| local repo_path="$2" | ||
|
|
||
| if [ -n "$version_arg" ]; then | ||
| # Version provided - validate and checkout the tag | ||
| checkout_tag "$version_arg" "$repo_path" | ||
| normalize_version "$version_arg" | ||
| return | ||
| fi | ||
|
|
||
| # No version provided - try to get an exact tag for current commit | ||
| local tag | ||
| tag=$(git -C "$repo_path" describe --tags --exact-match 2>/dev/null || true) | ||
|
|
||
| if [ -n "$tag" ]; then | ||
| normalize_version "$tag" | ||
| return | ||
| fi | ||
|
|
||
| # Fallback to dev/ci prefix with short hash | ||
| local short_hash | ||
| short_hash=$(git -C "$repo_path" rev-parse --short HEAD) | ||
|
|
||
| if [ "${GITHUB_ACTIONS:-}" = "true" ]; then | ||
| echo "ci-$short_hash" | ||
| else | ||
| echo "dev-$short_hash" | ||
| fi | ||
| } | ||
|
|
||
| project_root=$(pwd) | ||
| netbirdPath=$project_root/libs/netbird | ||
|
|
||
| # Parse arguments | ||
| platform="${1:-both}" | ||
| version_arg="${2:-}" | ||
|
|
||
| # Validate platform argument | ||
| case "$platform" in | ||
| ios|tvos|both) | ||
| ;; | ||
| *) | ||
| echo "Error: Invalid platform '$platform'. Must be 'ios', 'tvos', or 'both'." >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| # Get version (this also checks out the tag if provided) | ||
| version=$(get_version "$version_arg" "$netbirdPath") | ||
|
|
||
| cd "$netbirdPath" | ||
|
|
||
| echo "Using version: $version" | ||
| echo "Building for platform: $platform" | ||
|
|
||
| # Set targets and gomobile command based on platform | ||
| case "$platform" in | ||
| ios) | ||
| targets="ios,iossimulator" | ||
| gomobile_cmd="gomobile" | ||
| ;; | ||
| tvos) | ||
| targets="tvos,tvossimulator" | ||
| gomobile_cmd="gomobile-netbird" | ||
| ;; | ||
| both) | ||
| targets="ios,iossimulator,tvos,tvossimulator" | ||
| gomobile_cmd="gomobile-netbird" | ||
| ;; | ||
| esac | ||
|
|
||
| # Initialize gomobile | ||
| $gomobile_cmd init | ||
|
|
||
| # Build | ||
| $gomobile_cmd bind \ | ||
| -target="$targets" \ | ||
| -bundleid=io.netbird.framework \ | ||
| -ldflags="-X github.com/netbirdio/netbird/version.version=$version" \ | ||
| -o "$project_root/NetBirdSDK.xcframework" \ | ||
| "$netbirdPath/client/ios/NetBirdSDK" | ||
|
|
||
| cd - > /dev/null | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: netbirdio/ios-client
Length of output: 546
🏁 Script executed:
Repository: netbirdio/ios-client
Length of output: 46
🏁 Script executed:
Repository: netbirdio/ios-client
Length of output: 234
🏁 Script executed:
Repository: netbirdio/ios-client
Length of output: 296
🏁 Script executed:
Repository: netbirdio/ios-client
Length of output: 118
🏁 Script executed:
Repository: netbirdio/ios-client
Length of output: 1722
🏁 Script executed:
# Check the actual workflow files to see how they invoke the script cat .github/workflows/build.yml cat .github/workflows/test.ymlRepository: netbirdio/ios-client
Length of output: 9789
Update script invocations and documentation for new API signature.
The new script signature
./build-go-lib.sh [platform] [version]is a breaking change from the old./build-go-lib.sh <path>interface. Both GitHub Actions workflows (.github/workflows/build.ymland.github/workflows/test.yml) and the README.md still use the old invocation pattern./build-go-lib.sh ../netbird, which will fail validation in the platform check (lines 100-106) since../netbirddoes not match the valid platforms (ios, tvos, both).Update:
./build-go-lib.sh both(or specific platform)🤖 Prompt for AI Agents