-
Notifications
You must be signed in to change notification settings - Fork 96
116 lines (104 loc) · 2.92 KB
/
agent.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Build + Release
on:
push:
tags:
- "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:
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
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOMIPS: ${{ matrix.gomips }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.20.14"
- name: Build Test
if: github.event_name != 'push' || !contains(github.ref, 'refs/tags/')
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: build --single-target --clean --snapshot
- name: Build
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: build --single-target --clean
- name: Archive
run: zip -jr dist/nezha-agent_${GOOS}_${GOARCH}.zip dist/*/*
- 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