Skip to content

Commit

Permalink
ci. add go release config
Browse files Browse the repository at this point in the history
  • Loading branch information
hengyoush committed Oct 19, 2024
1 parent a4dc8d5 commit df6b667
Show file tree
Hide file tree
Showing 35 changed files with 101,424 additions and 1,964 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/release-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: release-test

on:
workflow_dispatch:
push:
branches: [ "master", "dev", "feature/e2e" ]
pull_request:
branches: [ "master", "dev" ]

permissions:
contents: read

jobs:

release-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- name: Set up Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
with:
go-version: '1.22.4'

- name: Run GoReleaser Draft
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6
with:
distribution: goreleaser
version: latest
args: release --snapshot --clean --skip=publish -p 1

- name: Test binary
run: |
mkdir amd64 && tar zxvf dist/kyanos_v0.0.0-next_linux_amd64.tar.gz -C amd64
mkdir arm64 && tar zxvf dist/kyanos_v0.0.0-next_linux_arm64.tar.gz -C arm64
./amd64/kyanos --help
file ./amd64/kyanos |grep x86-64 |grep 'statically linked'
file ./arm64/kyanos |grep aarch64 |grep 'statically linked'
- name: Store Releases
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
with:
name: kyanos_v0.0.0-next_linux_amd64.tar.gz
path: dist/kyanos.0.0-next_linux_amd64.tar.gz

- name: Store Releases
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
with:
name: kyanos_v0.0.0-next_linux_arm64.tar.gz
path: dist/kyanos_v0.0.0-next_linux_arm64.tar.gz
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*.dylib
*.o
__debug**
agent/agent_x86_bpfel.o

# Test binary, built with `go test -c`
*.test
Expand All @@ -28,3 +27,5 @@ deps/**

eapm-ebpf
kyanos

dist/
66 changes: 66 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2
project_name: kyanos
before:
hooks:
- wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
- sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"
- sudo apt update
- sudo apt-get install -y gcc flex bison make autoconf libelf-dev gcc-aarch64-linux-gnu libc6-dev-arm64-cross pkg-config llvm clang
- git submodule update --init --recursive

builds:
- id: kyanos-arm64
binary: kyanos
env:
- CGO_ENABLED=1
- CC=aarch64-linux-gnu-gcc
flags:
- -tags=static
ldflags:
- -linkmode 'external'
- -extldflags "-static"
goos:
- linux
goarch:
- arm64
hooks:
pre:
- bash -c 'sudo make clean || true'
- bash -c 'sudo make build-bpf || true'

- id: kyanos-amd64
binary: kyanos
env:
- CGO_ENABLED=1
- CC=clang
- CGO_LDFLAGS="-Xlinker -rpath=. -static"
goos:
- linux
goarch:
- amd64
hooks:
pre:
# - bash -c 'sudo make clean || true'
- bash -c 'sudo make build-bpf || true'

archives:
- builds:
- kyanos-arm64
- kyanos-amd64

checksum:
name_template: 'checksums.txt'

release:
prerelease: auto

snapshot:
version_template: "{{ .Tag }}-next"
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,15 @@ $(BPFTOOL): | $(BPFTOOL_OUTPUT)

GO_FILES := $(shell find $(SRC_DIR) -type f -name '*.go' | sort)

kyanos: $(LIBBPF_OBJ) $(GO_FILES) $(wildcard bpf/*.[ch]) | $(OUTPUT)
.PHONY: build-bpf
build-bpf: $(LIBBPF_OBJ) $(wildcard bpf/*.[ch]) | $(OUTPUT)
TARGET=amd64 go generate ./bpf/
TARGET=arm64 go generate ./bpf/

kyanos: $(GO_FILES)
$(call msg,BINARY,$@)
./build.sh
export CGO_LDFLAGS="-Xlinker -rpath=. -static" && go build

# delete failed targets
.DELETE_ON_ERROR:

Expand Down
Loading

0 comments on commit df6b667

Please sign in to comment.