ci: use matrix to reduce build time (#70)
* ci: use matrix to reduce build time * chore: update gopsutil to v4.24.9
This commit is contained in:
parent
aad063f7dd
commit
62a5c7869d
128
.github/workflows/agent.yml
vendored
128
.github/workflows/agent.yml
vendored
@ -1,42 +1,116 @@
|
|||||||
name: Release
|
name: Build + Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths-ignore:
|
||||||
|
- ".github/workflows/agent.yml"
|
||||||
|
- ".github/workflows/codeql-analysis.yml"
|
||||||
|
- ".github/workflows/test.yml"
|
||||||
|
- ".github/workflows/contributors.yml"
|
||||||
|
- "README.md"
|
||||||
|
- ".goreleaser.yml"
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
build:
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
goos: [linux, windows, darwin, freebsd]
|
||||||
|
goarch: [amd64, arm64, 386]
|
||||||
|
include:
|
||||||
|
- goos: linux
|
||||||
|
goarch: 386
|
||||||
|
- goos: linux
|
||||||
|
goarch: s390x
|
||||||
|
- goos: linux
|
||||||
|
goarch: riscv64
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm
|
||||||
|
- goos: linux
|
||||||
|
goarch: mips
|
||||||
|
gomips: softfloat
|
||||||
|
- goos: linux
|
||||||
|
goarch: mipsle
|
||||||
|
gomips: softfloat
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: arm
|
||||||
|
exclude:
|
||||||
|
- goos: darwin
|
||||||
|
goarch: 386
|
||||||
|
|
||||||
|
name: Build artifacts
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
env:
|
||||||
# 1.20 是 Windows 7/8 Server 2008/2012 最后一个支持版本
|
GOOS: ${{ matrix.goos }}
|
||||||
image: goreleaser/goreleaser-cross:v1.20
|
GOARCH: ${{ matrix.goarch }}
|
||||||
|
GOMIPS: ${{ matrix.gomips }}
|
||||||
steps:
|
steps:
|
||||||
- run: |
|
- uses: actions/checkout@v4
|
||||||
git config --global --add safe.directory /__w/agent/agent
|
|
||||||
- uses: actions/checkout@master
|
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: actions/setup-go@v4
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: "1.20.13"
|
go-version: "1.20.14"
|
||||||
- name: Run GoReleaser
|
|
||||||
uses: goreleaser/goreleaser-action@v2
|
- name: Build Test
|
||||||
|
if: github.event_name != 'push' || !contains(github.ref, 'refs/tags/')
|
||||||
|
uses: goreleaser/goreleaser-action@v6
|
||||||
with:
|
with:
|
||||||
distribution: goreleaser
|
distribution: goreleaser
|
||||||
version: latest
|
version: '~> v2'
|
||||||
args: release
|
args: build --single-target --clean --snapshot
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
- name: Build
|
||||||
- name: Trigger sync
|
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
|
||||||
if: ${{ env.SYNCED == 0 }}
|
uses: goreleaser/goreleaser-action@v6
|
||||||
uses: actions/github-script@v6
|
|
||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
distribution: goreleaser
|
||||||
script: |
|
version: '~> v2'
|
||||||
await github.rest.actions.createWorkflowDispatch({
|
args: build --single-target --clean
|
||||||
owner: 'nezhahq',
|
|
||||||
repo: 'agent',
|
- name: Archive
|
||||||
workflow_id: 'sync-release.yml',
|
run: zip -jr dist/nezha-agent_${GOOS}_${GOARCH}.zip dist/*/*
|
||||||
ref: 'main'
|
|
||||||
})
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: nezha-agent_${{ env.GOOS }}_${{ env.GOARCH }}
|
||||||
|
path: |
|
||||||
|
./dist/nezha-agent_${{ env.GOOS }}_${{ env.GOARCH }}.zip
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
|
||||||
|
needs: build
|
||||||
|
name: Release
|
||||||
|
steps:
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: ./assets
|
||||||
|
|
||||||
|
- name: Checksum
|
||||||
|
run: sha256sum ./assets/*/*.zip | awk -F" |/" '{print $1, $NF}' > checksums.txt
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
uses: ncipollo/release-action@v1
|
||||||
|
with:
|
||||||
|
artifacts: "checksums.txt,assets/*/*.zip"
|
||||||
|
generateReleaseNotes: true
|
||||||
|
|
||||||
|
- name: Trigger sync
|
||||||
|
env:
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
GH_DEBUG: api
|
||||||
|
run: |
|
||||||
|
gh workflow run sync-release.yml
|
||||||
|
36
.github/workflows/test-on-pr.yml
vendored
36
.github/workflows/test-on-pr.yml
vendored
@ -1,36 +0,0 @@
|
|||||||
name: Run Tests on PR
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
jobs:
|
|
||||||
tests:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: goreleaser/goreleaser-cross:v1.20
|
|
||||||
steps:
|
|
||||||
- run: |
|
|
||||||
git config --global --add safe.directory /__w/agent/agent
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-go@v4
|
|
||||||
with:
|
|
||||||
go-version: "1.20.13"
|
|
||||||
- name: Unit test
|
|
||||||
# Skip TestCloudflareDetection here, as most IP addresses of Github's action
|
|
||||||
# runners have been marked as bot.
|
|
||||||
run: |
|
|
||||||
go test -skip TestCloudflareDetection -v ./...
|
|
||||||
- name: Build test
|
|
||||||
run: |
|
|
||||||
go build ./cmd/agent
|
|
||||||
#- name: Run Gosec Security Scanner
|
|
||||||
# run: |
|
|
||||||
# go install github.com/securego/gosec/v2/cmd/gosec@v2.19.0
|
|
||||||
# gosec -exclude=G104 ./...
|
|
||||||
- name: Run GoReleaser
|
|
||||||
uses: goreleaser/goreleaser-action@v2
|
|
||||||
with:
|
|
||||||
distribution: goreleaser
|
|
||||||
version: latest
|
|
||||||
args: build --snapshot
|
|
27
.github/workflows/test.yml
vendored
27
.github/workflows/test.yml
vendored
@ -11,31 +11,32 @@ on:
|
|||||||
- ".github/workflows/contributors.yml"
|
- ".github/workflows/contributors.yml"
|
||||||
- "README.md"
|
- "README.md"
|
||||||
- ".goreleaser.yml"
|
- ".goreleaser.yml"
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
container:
|
fail-fast: true
|
||||||
image: goreleaser/goreleaser-cross:v1.20
|
matrix:
|
||||||
|
os: [ubuntu, windows, macos]
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}-latest
|
||||||
steps:
|
steps:
|
||||||
- run: |
|
|
||||||
git config --global --add safe.directory /__w/agent/agent
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: "1.20.13"
|
go-version: "1.20.14"
|
||||||
|
|
||||||
- name: Unit test
|
- name: Unit test
|
||||||
# Skip TestCloudflareDetection here, as most IP addresses of Github's action
|
# Skip TestCloudflareDetection here, as most IP addresses of Github's action
|
||||||
# runners have been marked as bot.
|
# runners have been marked as bot.
|
||||||
run: |
|
run: |
|
||||||
go test -skip TestCloudflareDetection -v ./...
|
go test -skip TestCloudflareDetection -v ./...
|
||||||
|
|
||||||
#- name: Run Gosec Security Scanner
|
#- name: Run Gosec Security Scanner
|
||||||
|
# if: runner.os == 'Linux'
|
||||||
# run: |
|
# run: |
|
||||||
# go install github.com/securego/gosec/v2/cmd/gosec@v2.19.0
|
# go install github.com/securego/gosec/v2/cmd/gosec@v2.19.0
|
||||||
# gosec -exclude=G104 ./...
|
# gosec -exclude=G104 ./...
|
||||||
- name: Run GoReleaser
|
|
||||||
uses: goreleaser/goreleaser-action@v2
|
|
||||||
with:
|
|
||||||
distribution: goreleaser
|
|
||||||
version: latest
|
|
||||||
args: build --snapshot
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
version: 2
|
||||||
before:
|
before:
|
||||||
hooks:
|
hooks:
|
||||||
- go mod tidy -v
|
- go mod tidy -v
|
||||||
@ -11,6 +12,7 @@ builds:
|
|||||||
- linux
|
- linux
|
||||||
- windows
|
- windows
|
||||||
- freebsd
|
- freebsd
|
||||||
|
- darwin
|
||||||
goarch:
|
goarch:
|
||||||
- arm
|
- arm
|
||||||
- arm64
|
- arm64
|
||||||
@ -27,52 +29,5 @@ builds:
|
|||||||
goarch: arm
|
goarch: arm
|
||||||
main: ./cmd/agent
|
main: ./cmd/agent
|
||||||
binary: nezha-agent
|
binary: nezha-agent
|
||||||
- id: darwin-amd64
|
|
||||||
env:
|
|
||||||
- CGO_ENABLED=1
|
|
||||||
- CC=o64-clang
|
|
||||||
- CXX=o64-clang++
|
|
||||||
ldflags:
|
|
||||||
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}}
|
|
||||||
goos:
|
|
||||||
- darwin
|
|
||||||
goarch:
|
|
||||||
- amd64
|
|
||||||
main: ./cmd/agent
|
|
||||||
binary: nezha-agent
|
|
||||||
- id: darwin-arm64
|
|
||||||
env:
|
|
||||||
- CGO_ENABLED=1
|
|
||||||
- CC=oa64-clang
|
|
||||||
- CXX=oa64-clang++
|
|
||||||
ldflags:
|
|
||||||
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}}
|
|
||||||
goos:
|
|
||||||
- darwin
|
|
||||||
goarch:
|
|
||||||
- arm64
|
|
||||||
main: ./cmd/agent
|
|
||||||
binary: nezha-agent
|
|
||||||
universal_binaries:
|
|
||||||
- name_template: "nezha-agent"
|
|
||||||
replace: false
|
|
||||||
checksum:
|
|
||||||
name_template: "checksums.txt"
|
|
||||||
snapshot:
|
snapshot:
|
||||||
name_template: "nezha-agent"
|
version_template: "nezha-agent"
|
||||||
archives:
|
|
||||||
- name_template: "nezha-agent_{{ .Os }}_{{ .Arch }}"
|
|
||||||
format: zip
|
|
||||||
files:
|
|
||||||
- none*
|
|
||||||
changelog:
|
|
||||||
sort: asc
|
|
||||||
filters:
|
|
||||||
exclude:
|
|
||||||
- "^docs:"
|
|
||||||
- "^test:"
|
|
||||||
- "^chore"
|
|
||||||
- Merge pull request
|
|
||||||
- Merge branch
|
|
||||||
- go mod tidy
|
|
||||||
- New translations
|
|
||||||
|
3
go.mod
3
go.mod
@ -19,7 +19,7 @@ require (
|
|||||||
github.com/nezhahq/service v0.0.0-20240704142721-eba37f9cc709
|
github.com/nezhahq/service v0.0.0-20240704142721-eba37f9cc709
|
||||||
github.com/quic-go/quic-go v0.40.1
|
github.com/quic-go/quic-go v0.40.1
|
||||||
github.com/refraction-networking/utls v1.6.3
|
github.com/refraction-networking/utls v1.6.3
|
||||||
github.com/shirou/gopsutil/v4 v4.24.6
|
github.com/shirou/gopsutil/v4 v4.24.9
|
||||||
github.com/spf13/cobra v1.8.1
|
github.com/spf13/cobra v1.8.1
|
||||||
github.com/spf13/viper v1.19.0
|
github.com/spf13/viper v1.19.0
|
||||||
golang.org/x/net v0.29.0
|
golang.org/x/net v0.29.0
|
||||||
@ -66,7 +66,6 @@ require (
|
|||||||
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
|
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
|
||||||
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||||
github.com/shoenig/go-m1cpu v0.1.6 // indirect
|
|
||||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||||
github.com/spf13/afero v1.11.0 // indirect
|
github.com/spf13/afero v1.11.0 // indirect
|
||||||
github.com/spf13/cast v1.6.0 // indirect
|
github.com/spf13/cast v1.6.0 // indirect
|
||||||
|
7
go.sum
7
go.sum
@ -139,11 +139,8 @@ github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6ke
|
|||||||
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
|
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
|
||||||
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
|
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
|
||||||
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
|
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
|
||||||
github.com/shirou/gopsutil/v4 v4.24.6 h1:9qqCSYF2pgOU+t+NgJtp7Co5+5mHF/HyKBUckySQL64=
|
github.com/shirou/gopsutil/v4 v4.24.9 h1:KIV+/HaHD5ka5f570RZq+2SaeFsb/pq+fp2DGNWYoOI=
|
||||||
github.com/shirou/gopsutil/v4 v4.24.6/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA=
|
github.com/shirou/gopsutil/v4 v4.24.9/go.mod h1:3fkaHNeYsUFCGZ8+9vZVWtbyM1k2eRnlL+bWO8Bxa/Q=
|
||||||
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
|
|
||||||
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
|
|
||||||
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
|
|
||||||
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
||||||
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
||||||
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
|
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user