From 900663e88da4d67a924496a15598776f7235320e Mon Sep 17 00:00:00 2001 From: Pk-web6936 <202365630+Pk-web6936@users.noreply.github.com> Date: Wed, 23 Apr 2025 08:02:10 +0330 Subject: [PATCH 1/2] Update main.yml --- .github/workflows/main.yml | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2080020e..77cefc5a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,17 +1,12 @@ -name: Build +name: Build and Release AndroidLibXrayLite on: workflow_dispatch: - inputs: - release_tag: - required: false - type: string - pull_request: - branches: - - main + release: + types: [published] push: - branches: - - main + pull_request: + types: [opened, synchronize, reopened] jobs: build: runs-on: ubuntu-latest @@ -52,19 +47,19 @@ jobs: gomobile init go mod tidy gomobile bind -v -androidapi 21 -trimpath -ldflags='-s -w -buildid=' ./ - + - name: Upload build artifacts - if: github.event.inputs.release_tag == '' uses: actions/upload-artifact@v4.6.2 with: name: libv2ray path: | ${{ github.workspace }}/libv2ray*r - + - name: Upload AndroidLibXrayLite to release - if: github.event.inputs.release_tag != '' + if: github.event_name == 'release' && github.event.action == 'published' uses: svenstaro/upload-release-action@v2 with: + repo_token: ${{ secrets.GITHUB_TOKEN }} file: ./libv2ray*r - tag: ${{ github.event.inputs.release_tag }} - file_glob: true \ No newline at end of file + tag: ${{ github.ref }} + file_glob: true From 6d60b1493e2e4991029fd3144a9bb1dd969bd7da Mon Sep 17 00:00:00 2001 From: Pk-web6936 <202365630+Pk-web6936@users.noreply.github.com> Date: Wed, 23 Apr 2025 08:02:58 +0330 Subject: [PATCH 2/2] Create test.yml --- .github/workflows/test.yml | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..a8aff824 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,55 @@ +name: Test + +on: + push: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + test: + permissions: + contents: read + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - name: Checkout codebase + uses: actions/checkout@v4.2.2 + + - name: Set up Go + uses: actions/setup-go@v5.4.0 + with: + go-version-file: go.mod + cache: true + check-latest: true + + - name: Cleanup old coverage files + shell: bash + run: | + rm -f coverage.txt || true # For all operating systems + + - name: Install dependencies + shell: bash + run: go mod tidy + + - name: Run Tests + shell: bash + run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... + + - name: Upload Coverage + uses: codecov/codecov-action@v5.4.2 + if: success() + + security: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.2.2 + - run: | + go install github.com/securego/gosec/v2/cmd/gosec@latest + export PATH="$PATH:$(go env GOPATH)/bin" + gosec ./... + - name: Test + run: go test -timeout 1h -v ./...