diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 99e612c..580d2f9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Check out code into the Go module directory - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 @@ -53,7 +53,7 @@ jobs: with: context: . push: true - platforms: linux/amd64,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 tags: | xjasonlyu/tun2socks:dev ghcr.io/xjasonlyu/tun2socks:dev @@ -64,7 +64,7 @@ jobs: with: context: . push: true - platforms: linux/amd64,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 tags: | xjasonlyu/tun2socks:latest xjasonlyu/tun2socks:${{ steps.shell.outputs.version }} diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index f599dee..0000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Go Static Check - -on: - push: - branches: - - '*' - tags-ignore: - - '*' - pull_request: - -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Setup Go - uses: actions/setup-go@v2 - with: - go-version: 1.17.x - - - name: Cache go module - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Get dependencies, run test and static check - run: | - go test ./... - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - golangci-lint run --disable-all -E govet -E gofumpt -E megacheck ./... diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 11ab0f2..cb75ff9 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -4,9 +4,19 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + + - name: Get latest go version + id: version + run: | + echo ::set-output name=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') + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: ${{ steps.version.outputs.go_version }} + - name: golangci-lint - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v3 with: version: latest - args: --disable-all -E govet -E gofumpt -E megacheck ./... diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 806584a..0229226 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,23 +11,39 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Get latest Go version + id: version + run: | + echo ::set-output name=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') + - name: Setup Go uses: actions/setup-go@v2 with: - go-version: 1.17.x + go-version: ${{ steps.version.outputs.go_version }} + + - name: Cache go module + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Run test + run: | + go test ./... - name: Build + if: startsWith(github.ref, 'refs/tags/') run: make -j releases - name: Upload Releases uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: files: build/* draft: true diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..bed927f --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,16 @@ +linters: + disable-all: true + enable: + - gofumpt + - staticcheck + - govet + - gci + +linters-settings: + gci: + sections: + - standard + - prefix(github.com/xjasonlyu/tun2socks) + - default + staticcheck: + go: '1.18'