From b896b7ccddd7dfb6e01c42d373feb8cdf351c256 Mon Sep 17 00:00:00 2001 From: PuerNya Date: Sun, 17 Dec 2023 00:34:24 +0800 Subject: [PATCH] Build SFA --- .github/renovate.json | 28 ----- .github/update_dependencies.sh | 5 - .github/workflows/debug.yml | 222 --------------------------------- .github/workflows/docker.yml | 47 ------- .github/workflows/lint.yml | 41 ------ .github/workflows/sfa.yml | 117 +++++++++++++++++ .github/workflows/stale.yml | 15 --- 7 files changed, 117 insertions(+), 358 deletions(-) delete mode 100644 .github/renovate.json delete mode 100755 .github/update_dependencies.sh delete mode 100644 .github/workflows/debug.yml delete mode 100644 .github/workflows/docker.yml delete mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/sfa.yml delete mode 100644 .github/workflows/stale.yml diff --git a/.github/renovate.json b/.github/renovate.json deleted file mode 100644 index 78d9c96144..0000000000 --- a/.github/renovate.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "commitMessagePrefix": "[dependencies]", - "extends": [ - "config:base", - ":disableRateLimiting" - ], - "baseBranches": [ - "dev-next" - ], - "golang": { - "enabled": false - }, - "packageRules": [ - { - "matchManagers": [ - "github-actions" - ], - "groupName": "github-actions" - }, - { - "matchManagers": [ - "dockerfile" - ], - "groupName": "Dockerfile" - } - ] -} \ No newline at end of file diff --git a/.github/update_dependencies.sh b/.github/update_dependencies.sh deleted file mode 100755 index 4702ddfe01..0000000000 --- a/.github/update_dependencies.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -PROJECTS=$(dirname "$0")/../.. -go get -x github.com/sagernet/$1@$(git -C $PROJECTS/$1 rev-parse HEAD) -go mod tidy diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml deleted file mode 100644 index 06b49dc7e7..0000000000 --- a/.github/workflows/debug.yml +++ /dev/null @@ -1,222 +0,0 @@ -name: Debug build - -on: - push: - branches: - - stable-next - - main-next - - dev-next - paths-ignore: - - '**.md' - - '.github/**' - - '!.github/workflows/debug.yml' - pull_request: - branches: - - stable-next - - main-next - - dev-next - -jobs: - build: - name: Debug build - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - fetch-depth: 0 - - name: Get latest go version - id: version - run: | - echo go_version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') >> $GITHUB_OUTPUT - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: ${{ steps.version.outputs.go_version }} - - name: Add cache to Go proxy - run: | - version=`git rev-parse HEAD` - mkdir build - pushd build - go mod init build - go get -v github.com/sagernet/sing-box@$version - popd - continue-on-error: true - - name: Run Test - run: | - go test -v ./... - build_go118: - name: Debug build (Go 1.18) - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - fetch-depth: 0 - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: 1.18.10 - - name: Cache go module - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod - key: go118-${{ hashFiles('**/go.sum') }} - - name: Run Test - run: make ci_build_go118 - build_go120: - name: Debug build (Go 1.20) - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - fetch-depth: 0 - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: 1.20.7 - - name: Cache go module - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod - key: go118-${{ hashFiles('**/go.sum') }} - - name: Run Test - run: make ci_build - cross: - strategy: - matrix: - include: - # windows - - name: windows-amd64 - goos: windows - goarch: amd64 - goamd64: v1 - - name: windows-amd64-v3 - goos: windows - goarch: amd64 - goamd64: v3 - - name: windows-386 - goos: windows - goarch: 386 - - name: windows-arm64 - goos: windows - goarch: arm64 - - name: windows-arm32v7 - goos: windows - goarch: arm - goarm: 7 - - # linux - - name: linux-amd64 - goos: linux - goarch: amd64 - goamd64: v1 - - name: linux-amd64-v3 - goos: linux - goarch: amd64 - goamd64: v3 - - name: linux-386 - goos: linux - goarch: 386 - - name: linux-arm64 - goos: linux - goarch: arm64 - - name: linux-armv5 - goos: linux - goarch: arm - goarm: 5 - - name: linux-armv6 - goos: linux - goarch: arm - goarm: 6 - - name: linux-armv7 - goos: linux - goarch: arm - goarm: 7 - - name: linux-mips-softfloat - goos: linux - goarch: mips - gomips: softfloat - - name: linux-mips-hardfloat - goos: linux - goarch: mips - gomips: hardfloat - - name: linux-mipsel-softfloat - goos: linux - goarch: mipsle - gomips: softfloat - - name: linux-mipsel-hardfloat - goos: linux - goarch: mipsle - gomips: hardfloat - - name: linux-mips64 - goos: linux - goarch: mips64 - - name: linux-mips64el - goos: linux - goarch: mips64le - - name: linux-s390x - goos: linux - goarch: s390x - # darwin - - name: darwin-amd64 - goos: darwin - goarch: amd64 - goamd64: v1 - - name: darwin-amd64-v3 - goos: darwin - goarch: amd64 - goamd64: v3 - - name: darwin-arm64 - goos: darwin - goarch: arm64 - # freebsd - - name: freebsd-amd64 - goos: freebsd - goarch: amd64 - goamd64: v1 - - name: freebsd-amd64-v3 - goos: freebsd - goarch: amd64 - goamd64: v3 - - name: freebsd-386 - goos: freebsd - goarch: 386 - - name: freebsd-arm64 - goos: freebsd - goarch: arm64 - - fail-fast: false - runs-on: ubuntu-latest - env: - GOOS: ${{ matrix.goos }} - GOARCH: ${{ matrix.goarch }} - GOAMD64: ${{ matrix.goamd64 }} - GOARM: ${{ matrix.goarm }} - GOMIPS: ${{ matrix.gomips }} - CGO_ENABLED: 0 - TAGS: with_clash_api,with_quic - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - fetch-depth: 0 - - name: Get latest go version - id: version - run: | - echo go_version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') >> $GITHUB_OUTPUT - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: ${{ steps.version.outputs.go_version }} - - name: Build - id: build - run: make - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: sing-box-${{ matrix.name }} - path: sing-box* diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index a106e593a5..0000000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Build Docker Images -on: - workflow_dispatch: - inputs: - tag: - description: "The tag version you want to build" -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Setup QEMU for Docker Buildx - uses: docker/setup-qemu-action@v3 - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker metadata - id: metadata - uses: docker/metadata-action@v5 - with: - images: ghcr.io/sagernet/sing-box - - name: Get tag to build - id: tag - run: | - echo "latest=ghcr.io/sagernet/sing-box:latest" >> $GITHUB_OUTPUT - if [[ -z "${{ github.event.inputs.tag }}" ]]; then - echo "versioned=ghcr.io/sagernet/sing-box:${{ github.ref_name }}" >> $GITHUB_OUTPUT - else - echo "versioned=ghcr.io/sagernet/sing-box:${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT - fi - - name: Build and release Docker images - uses: docker/build-push-action@v5 - with: - platforms: linux/386,linux/amd64,linux/arm64,linux/s390x - target: dist - build-args: | - BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 - tags: | - ${{ steps.tag.outputs.latest }} - ${{ steps.tag.outputs.versioned }} - push: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 56d21b721d..0000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Lint - -on: - push: - branches: - - stable-next - - main-next - - dev-next - paths-ignore: - - '**.md' - - '.github/**' - - '!.github/workflows/lint.yml' - pull_request: - branches: - - stable-next - - main-next - - dev-next - -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - fetch-depth: 0 - - name: Get latest go version - id: version - run: | - echo go_version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') >> $GITHUB_OUTPUT - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: ${{ steps.version.outputs.go_version }} - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - version: latest - args: --timeout=30m - install-mode: binary \ No newline at end of file diff --git a/.github/workflows/sfa.yml b/.github/workflows/sfa.yml new file mode 100644 index 0000000000..a37184b22c --- /dev/null +++ b/.github/workflows/sfa.yml @@ -0,0 +1,117 @@ +name: Build SFA + +on: + push: + +jobs: + build: + runs-on: ubuntu-latest + env: + TAGS: "with_quic,with_dhcp,with_wireguard,with_shadowsocksr,with_ech,with_utls,with_reality_server,with_clash_api,with_v2ray_api,with_gvisor" + + steps: + - uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + + - name: Get latest go version + id: go_version + run: | + echo go_version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') >> $GITHUB_OUTPUT + + - name: Setup Go + uses: actions/setup-go@v4.1.0 + with: + go-version: 1.21.5 + + - name: Checkout SFA Repository + uses: actions/checkout@v4.1.1 + with: + repository: SagerNet/sing-box-for-android + path: SFA + submodules: recursive + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'oracle' + java-version: 20 + + - name: Setup NDK + uses: nttld/setup-ndk@v1 + id: setup-ndk + with: + ndk-version: r26b + add-to-path: false + local-cache: false + + - name: Build SFA + env: + ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} + run: | + git remote add sekai https://github.com/SagerNet/sing-box + git fetch sekai + mkdir -p SFA/app/libs/ + make lib_install + version=$(CGO_ENABLED=0 go run ./cmd/internal/read_tag) + CC=${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android34-clang + CGO_ENABLED=0 gomobile bind -v -a -trimpath -androidapi 21 -javapkg=io.nekohasekai -libname=box -tags ${TAGS} -ldflags "-X github.com/sagernet/sing-box/constant.Version=${version} -s -w -buildid=" ./experimental/libbox + cp ./libbox.aar SFA/app/libs/ + cd SFA + echo "" >> gradle.properties + echo "org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8 -XX:+UseParallelGC" >> gradle.properties + echo "org.gradle.caching=true" >> gradle.properties + echo "org.gradle.parallel=true" >> gradle.properties + echo "VERSION_NAME=${version}" > local.properties + echo "VERSION_CODE=$(date +%Y%m%d%H)" >> local.properties + sed -i '/signingConfigs\.release/d' app/build.gradle + chmod +x ./gradlew + ./gradlew assembleRelease --debug + + - name: Sign SFA + uses: PuerNya/sign-android-release@v2 + with: + releaseDirectory: SFA/app/build/outputs/apk/other/release + signingKeyBase64: ${{ secrets.SIGN_KEY }} + alias: ${{ secrets.ALIAS }} + keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} + + - name: Upload arm64-v8a artifact + uses: actions/upload-artifact@v3 + with: + name: SFA-arm64-v8a + path: | + SFA/app/build/outputs/apk/other/release/*-arm64-v8a-signed.apk + SFA/app/build/outputs/apk/other/release/*-arm64-v8a-*-signed.apk + + - name: Upload armeabi-v7a artifact + uses: actions/upload-artifact@v3 + with: + name: SFA-armeabi-v7a + path: | + SFA/app/build/outputs/apk/other/release/*-armeabi-v7a-signed.apk + SFA/app/build/outputs/apk/other/release/*-armeabi-v7a-*-signed.apk + + - name: Upload x86_64 artifact + uses: actions/upload-artifact@v3 + with: + name: SFA-x86_64 + path: | + SFA/app/build/outputs/apk/other/release/*-x86_64-signed.apk + SFA/app/build/outputs/apk/other/release/*-x86_64-*-signed.apk + + - name: Upload x86 artifact + uses: actions/upload-artifact@v3 + with: + name: SFA-x86 + path: | + SFA/app/build/outputs/apk/other/release/*-x86-signed.apk + SFA/app/build/outputs/apk/other/release/*-x86-*-signed.apk + + - name: Upload universal artifact + uses: actions/upload-artifact@v3 + with: + name: SFA-universal + path: | + SFA/app/build/outputs/apk/other/release/*-universal-signed.apk + SFA/app/build/outputs/apk/other/release/*-universal-*-signed.apk \ No newline at end of file diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index b6307da29f..0000000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Mark stale issues and pull requests - -on: - schedule: - - cron: "30 1 * * *" - -jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v9 - with: - stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days' - days-before-stale: 60 - days-before-close: 5 \ No newline at end of file