Skip to content
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

Add Xcframework for ios #419

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,40 @@ jobs:
files: build/*
draft: true
prerelease: false

release-ios:
name: Release-ios
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v5
with:
check-latest: true
go-version-file: 'go.mod'

- name: Cache go module
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Build
if: startsWith(github.ref, 'refs/tags/')
run: make -j releases-ios

- name: Upload Releases
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: build/*
draft: true
prerelease: false
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ WINDOWS_ARCH_LIST = \
windows-arm64 \
windows-arm32v7

LIB_LIST = \
ios \

all: linux-amd64 linux-arm64 darwin-amd64 darwin-arm64 windows-amd64

debug: BUILD_TAGS += debug
Expand All @@ -69,6 +72,15 @@ darwin-amd64-v3:
darwin-arm64:
GOARCH=arm64 GOOS=darwin $(GO_BUILD) -o $(BUILD_DIR)/$(BINARY)-$@

ios:
go install golang.org/x/mobile/cmd/gomobile@latest
go install golang.org/x/mobile/cmd/gobind@latest
go get golang.org/x/mobile/cmd/gomobile
go get golang.org/x/mobile/cmd/gobind

gomobile init
gomobile bind -a -v -ldflags '$(LDFLAGS)' -tags ios -target=ios -o $(BUILD_DIR)/$(BINARY).xcframework github.com/xjasonlyu/tun2socks/v2/engine

freebsd-386:
GOARCH=386 GOOS=freebsd $(GO_BUILD) -o $(BUILD_DIR)/$(BINARY)-$@

Expand Down Expand Up @@ -155,16 +167,22 @@ windows-arm32v7:

unix_releases := $(addsuffix .zip, $(UNIX_ARCH_LIST))
windows_releases := $(addsuffix .zip, $(WINDOWS_ARCH_LIST))
lib_releases := $(addsuffix .zip, $(LIB_LIST))

$(unix_releases): %.zip: %
@zip -qmj $(BUILD_DIR)/$(BINARY)-$(basename $@).zip $(BUILD_DIR)/$(BINARY)-$(basename $@)

$(windows_releases): %.zip: %
@zip -qmj $(BUILD_DIR)/$(BINARY)-$(basename $@).zip $(BUILD_DIR)/$(BINARY)-$(basename $@).exe

$(lib_releases): %.zip: %
@zip -qmr $(BUILD_DIR)/$(BINARY)-$(basename $@).zip $(BUILD_DIR)/$(BINARY).xcframework


all-arch: $(UNIX_ARCH_LIST) $(WINDOWS_ARCH_LIST)

releases: $(unix_releases) $(windows_releases)
releases-ios: $(lib_releases)

lint:
GOOS=darwin golangci-lint run ./...
Expand Down