From c75d75c982d6c88f39ed5fa39bc2f0cb0039b6a2 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Sun, 19 Feb 2023 01:23:06 +0800 Subject: [PATCH] chore: combine workflows --- .github/workflows/build.yaml | 22 -------- .../workflows/{prerelease.yml => build.yml} | 52 ++++++++++++++++--- .github/workflows/release.yaml | 36 ------------- dns/resolver.go | 2 +- 4 files changed, 45 insertions(+), 67 deletions(-) delete mode 100644 .github/workflows/build.yaml rename .github/workflows/{prerelease.yml => build.yml} (86%) delete mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 1def82ea..00000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: Build All -on: - workflow_dispatch: -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v3 - - name: Setup Go - uses: actions/setup-go@v3 - with: - go-version: '1.20' - check-latest: true - cache: true - - name: Build - run: make all - - name: Release - uses: softprops/action-gh-release@v1 - with: - files: bin/* - draft: true diff --git a/.github/workflows/prerelease.yml b/.github/workflows/build.yml similarity index 86% rename from .github/workflows/prerelease.yml rename to .github/workflows/build.yml index d586ca28..66b694de 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Prerelease +name: Build on: workflow_dispatch: push: @@ -8,10 +8,14 @@ on: branches: - Alpha - Beta + - Meta + tags: + - "v*" pull_request_target: branches: - Alpha - Beta + - Meta env: REGISTRY: docker.io jobs: @@ -93,7 +97,12 @@ jobs: shell: bash - name: Set variables - if: ${{github.ref_name==''}} + if: ${{github.ref_name=='Meta'}} + run: echo "VERSION=meta-$(git rev-parse --short HEAD)" >> $GITHUB_ENV + shell: bash + + - name: Set variables + if: ${{github.ref_name=='' || github.ref_type=='tag'}} run: echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV shell: bash @@ -103,6 +112,7 @@ jobs: echo "REPO=${{ github.repository }}" >> $GITHUB_ENV echo "ShortSHA=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV echo "BUILDTIME=$(date -u)" >> $GITHUB_ENV + echo "BRANCH=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV shell: bash - name: Set ENV @@ -118,7 +128,7 @@ jobs: check-latest: true - name: Test - if: ${{ github.ref_name=='Beta' && matrix.job.id=='1' && matrix.job.type=='WithoutCGO' }} + if: ${{ matrix.job.id=='1' && matrix.job.type=='WithoutCGO' }} run: | go test ./... @@ -158,7 +168,7 @@ jobs: ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} run: | mkdir bin - xgo --branch ${{ github.ref_name }} --targets="${{ matrix.job.target }}" --tags="${TAGS}" -ldflags="${LDFLAGS}" --out bin/${NAME} github.com/${{ github.repository }} + xgo --targets="${{ matrix.job.target }}" --tags="${TAGS}" -ldflags="${LDFLAGS}" --out bin/${NAME} ./ - name: Rename if: ${{ matrix.job.type=='WithCGO' }} @@ -189,9 +199,10 @@ jobs: name: artifact path: bin/ - Upload: + Upload-Prerelease: permissions: write-all - needs: [Build] + if: ${{ github.ref_type=='branch' }} + needs: [ Build ] runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v3 @@ -217,7 +228,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Upload Alpha + - name: Upload Prerelease uses: softprops/action-gh-release@v1 if: ${{ success() }} with: @@ -226,9 +237,34 @@ jobs: files: bin/* prerelease: true generate_release_notes: true + + Upload-Release: + permissions: write-all + if: ${{ github.ref_type=='tag' }} + needs: [ Build ] + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v3 + with: + name: artifact + path: bin/ + + - name: Display structure of downloaded files + run: ls -R + working-directory: bin + + - name: Upload Release + uses: softprops/action-gh-release@v1 + if: ${{ success() }} + with: + tag: ${{ github.ref_name }} + tag_name: ${{ github.ref_name }} + files: bin/* + generate_release_notes: true + Docker: permissions: write-all - needs: [Build] + needs: [ Build ] runs-on: ubuntu-latest steps: - name: Checkout repository diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 478f13e1..00000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,36 +0,0 @@ -name: Release -on: - push: - tags: - - "v*" -jobs: - Build: - runs-on: ubuntu-latest - steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v3 - - - name: Setup Go - uses: actions/setup-go@v3 - with: - go-version: '1.20' - check-latest: true - cache: true - - - name: Test - run: | - go test ./... - - name: Build - if: success() - env: - NAME: Clash.Meta - BINDIR: bin - run: make -j$(($(nproc) + 1)) releases - - - name: Upload Release - uses: softprops/action-gh-release@v1 - if: ${{ success() && startsWith(github.ref, 'refs/tags/')}} - with: - tag: ${{ github.ref }} - files: bin/* - generate_release_notes: true diff --git a/dns/resolver.go b/dns/resolver.go index 8c983111..ac8917ca 100644 --- a/dns/resolver.go +++ b/dns/resolver.go @@ -457,7 +457,7 @@ func NewResolver(config Config) *Resolver { inverse = true groupname = groupname[1:] } - log.Debugln("adding geosite policy: %s inversed %s", groupname, inverse) + log.Debugln("adding geosite policy: %s inversed %t", groupname, inverse) matcher, err := NewGeoSite(groupname) if err != nil { continue