Skip to content

Commit ed204d5

Browse files
author
Eli Zor
committed
chore: fix release github workflow (sic I hate CI..)
1 parent 9ae7cce commit ed204d5

File tree

4 files changed

+120
-18
lines changed

4 files changed

+120
-18
lines changed

.claude/settings.local.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"Bash(git -C /home/zor/Perso/process-tracer log --oneline --all \"--grep=version\\|ldflags\\|Version\")",
3939
"Bash(mise test:*)",
4040
"Bash(mise lint:*)",
41-
"Bash(mise tasks:*)"
41+
"Bash(mise tasks:*)",
42+
"Bash(goreleaser build:*)"
4243
],
4344
"deny": [],
4445
"ask": []

.github/workflows/ci.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ jobs:
6262
sudo bpftool btf dump file /sys/kernel/btf/vmlinux format c > internal/bpf/vmlinux.h
6363
6464
- name: Generate BPF bindings
65-
run: go generate ./internal/bpf
65+
working-directory: internal/bpf
66+
env:
67+
GOPACKAGE: bpf
68+
run: |
69+
go run github.com/cilium/ebpf/cmd/bpf2go -target amd64 processTracer ./process_tracer.bpf.c -- -I. -I/usr/include
6670
6771
- name: Run golangci-lint
6872
uses: golangci/golangci-lint-action@v8
@@ -121,7 +125,11 @@ jobs:
121125
sudo bpftool btf dump file /sys/kernel/btf/vmlinux format c > internal/bpf/vmlinux.h
122126
123127
- name: Generate BPF bindings
124-
run: go generate ./internal/bpf
128+
working-directory: internal/bpf
129+
env:
130+
GOPACKAGE: bpf
131+
run: |
132+
go run github.com/cilium/ebpf/cmd/bpf2go -target amd64 processTracer ./process_tracer.bpf.c -- -I. -I/usr/include
125133
126134
- name: Run tests
127135
run: go test -v -race -coverprofile=coverage.out ./...

.github/workflows/release.yml

Lines changed: 107 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,24 @@ permissions:
99
contents: write
1010

1111
jobs:
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

.goreleaser.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ builds:
1212
- CGO_ENABLED=0
1313
goos:
1414
- linux
15-
- darwin
1615
goarch:
1716
- amd64
1817
- arm64
@@ -59,6 +58,6 @@ release:
5958
header: |
6059
## Release {{ .Tag }}
6160
62-
Binary releases for Linux (x86_64, ARM64) and macOS (ARM64).
61+
Binary releases for Linux (x86_64, ARM64).
6362
footer: |
6463
**Full Changelog**: {{ .ReleaseURL }}/compare/{{ .PreviousTag }}...{{ .Tag }}

0 commit comments

Comments
 (0)