@@ -9,18 +9,24 @@ permissions:
99 contents : write
1010
1111jobs :
12- goreleaser :
13- name : Release with goreleaser
14- runs-on : ubuntu-latest
12+ build :
13+ name : Build for ${{ matrix.arch }}
14+ runs-on : ${{ matrix.runner }}
15+ strategy :
16+ matrix :
17+ include :
18+ - arch : amd64
19+ runner : ubuntu-latest
20+ goarch : amd64
21+ - arch : arm64
22+ runner : ubuntu-24.04-arm
23+ goarch : arm64
1524 steps :
1625 - name : Checkout code
1726 uses : actions/checkout@v5
1827 with :
1928 fetch-depth : 0
2029
21- - name : Fetch all tags
22- run : git fetch --force --tags
23-
2430 - name : Set up Go
2531 uses : actions/setup-go@v6
2632 with :
@@ -64,13 +70,101 @@ jobs:
6470 sudo bpftool btf dump file /sys/kernel/btf/vmlinux format c > internal/bpf/vmlinux.h
6571
6672 - name : Generate BPF bindings
67- run : go generate ./internal/bpf
73+ working-directory : internal/bpf
74+ env :
75+ GOPACKAGE : bpf
76+ run : |
77+ go run github.com/cilium/ebpf/cmd/bpf2go -target ${{ matrix.arch }} processTracer ./process_tracer.bpf.c -- -I. -I/usr/include
78+
79+ - name : Build binary
80+ env :
81+ GOOS : linux
82+ GOARCH : ${{ matrix.goarch }}
83+ run : |
84+ VERSION=${GITHUB_REF#refs/tags/}
85+ COMMIT=$(git rev-parse --short HEAD)
86+ DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
87+
88+ go build -ldflags "\
89+ -s -w \
90+ -X main.version=${VERSION} \
91+ -X main.commit=${COMMIT} \
92+ -X main.date=${DATE}" \
93+ -o process-tracer \
94+ ./cmd/process-tracer
6895
69- - name : Run GoReleaser
70- uses : goreleaser/goreleaser-action@v6
96+ - name : Create tarball
97+ run : |
98+ VERSION=${GITHUB_REF#refs/tags/}
99+ TARBALL="process-tracer_${VERSION}_linux_${{ matrix.arch }}.tar.gz"
100+ tar -czf ${TARBALL} process-tracer LICENSE README.md
101+ sha256sum ${TARBALL} > ${TARBALL}.sha256
102+
103+ - name : Upload artifact
104+ uses : actions/upload-artifact@v4
71105 with :
72- distribution : goreleaser
73- version : ' ~> v2'
74- args : release --clean
106+ name : binary-${{ matrix.arch }}
107+ path : |
108+ process-tracer_*.tar.gz
109+ process-tracer_*.tar.gz.sha256
110+
111+ release :
112+ name : Create GitHub Release
113+ needs : build
114+ runs-on : ubuntu-latest
115+ steps :
116+ - name : Checkout code
117+ uses : actions/checkout@v5
118+ with :
119+ fetch-depth : 0
120+
121+ - name : Download all artifacts
122+ uses : actions/download-artifact@v4
123+ with :
124+ pattern : binary-*
125+ merge-multiple : true
126+
127+ - name : Create checksums file
128+ run : |
129+ cat *.sha256 > checksums.txt
130+ rm *.sha256
131+
132+ - name : Generate release notes
133+ id : notes
134+ run : |
135+ VERSION=${GITHUB_REF#refs/tags/}
136+ PREV_TAG=$(git describe --tags --abbrev=0 ${VERSION}^ 2>/dev/null || echo "")
137+
138+ echo "## Release ${VERSION}" > release_notes.md
139+ echo "" >> release_notes.md
140+ echo "Binary releases for Linux (x86_64, ARM64)." >> release_notes.md
141+ echo "" >> release_notes.md
142+
143+ if [ -n "$PREV_TAG" ]; then
144+ echo "### Changes" >> release_notes.md
145+ git log ${PREV_TAG}..${VERSION} --pretty=format:"- %s" \
146+ --grep="^feat" --grep="^fix" --grep="^perf" \
147+ | grep -v "^- chore:" | grep -v "^- docs:" | grep -v "^- test:" >> release_notes.md || true
148+ echo "" >> release_notes.md
149+ echo "" >> release_notes.md
150+ echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...${VERSION}" >> release_notes.md
151+ fi
152+
153+ - name : Create Release
75154 env :
76- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
155+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
156+ run : |
157+ VERSION=${GITHUB_REF#refs/tags/}
158+
159+ # Check if this is a prerelease
160+ PRERELEASE=""
161+ if [[ "$VERSION" =~ -(alpha|beta|rc) ]]; then
162+ PRERELEASE="--prerelease"
163+ fi
164+
165+ gh release create ${VERSION} \
166+ ${PRERELEASE} \
167+ --title "Release ${VERSION}" \
168+ --notes-file release_notes.md \
169+ process-tracer_*.tar.gz \
170+ checksums.txt
0 commit comments