-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(workflow): add release workflow etc. (#61)
* add release workflow. * add more arch and vendor btf support. * add complete btf files embed support. * add commitizen integration.
- Loading branch information
Showing
14 changed files
with
4,067 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: release | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- v* | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
|
||
release-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Remove large directories | ||
run: | | ||
df -h | ||
cd /opt/hostedtoolcache | ||
find . -mindepth 1 -maxdepth 1 -type d -not -name 'go' -exec rm -rf {} + | ||
df -h | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5 | ||
with: | ||
go-version: '1.22.6' | ||
|
||
- name: Run GoReleaser Draft | ||
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6 | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --clean --draft=true -p 1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GORELEASE_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
*.dylib | ||
*.o | ||
__debug** | ||
node_modules/ | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/bin/bash | ||
BASEDIR=$(dirname "${0}") | ||
cd ${BASEDIR}/../ | ||
BASEDIR=$(pwd) | ||
cd ${BASEDIR} | ||
|
||
BTFHUB_REPO="https://github.com/aquasecurity/btfhub.git" | ||
BTFHUB_ARCH_REPO="https://github.com/aquasecurity/btfhub-archive.git" | ||
|
||
|
||
KYANOS_BPF_CORE="${BASEDIR}/bpf/agent_$2_bpfel.o" | ||
|
||
BTFHUB_DIR="${BASEDIR}/deps/btfhub" | ||
BTFHUB_ARCH_DIR="${BASEDIR}/deps/btfhub-archive" | ||
|
||
ARCH=$(uname -m) | ||
|
||
case ${ARCH} in | ||
"x86_64") | ||
ARCH="x86_64" | ||
;; | ||
"aarch64") | ||
ARCH="arm64" | ||
;; | ||
*) | ||
die "unsupported architecture" | ||
;; | ||
esac | ||
|
||
|
||
die() { | ||
echo ${@} | ||
exit 1 | ||
} | ||
|
||
branch_clean() { | ||
cd ${1} || die "could not change dirs" | ||
|
||
# small sanity check | ||
[ ! -d ./.git ] && die "$(basename $(pwd)) not a repo dir" | ||
|
||
# git fetch -a || die "could not fetch ${1}" # make sure its updated | ||
# git clean -fdX # clean leftovers | ||
# git reset --hard # reset letfovers | ||
# git checkout origin/main -b main-$$ | ||
# git branch -D main | ||
# git branch -m main-$$ main # origin/main == main | ||
|
||
cd ${BASEDIR} | ||
} | ||
|
||
CMDS="rsync git cp rm mv" | ||
for cmd in ${CMDS}; do | ||
command -v $cmd 2>&1 >/dev/null || die "cmd ${cmd} not found" | ||
done | ||
[ ! -f ${KYANOS_BPF_CORE} ] && die "kyanos CO-RE obj not found: ${KYANOS_BPF_CORE}" | ||
|
||
[ ! -d ${BTFHUB_DIR} ] && git clone "${BTFHUB_REPO}" ${BTFHUB_DIR} | ||
[ ! -d ${BTFHUB_ARCH_DIR} ] && git clone --depth=1 "${BTFHUB_ARCH_REPO}" ${BTFHUB_ARCH_DIR} | ||
|
||
if [ -z ${SKIP_FETCH} ]; then | ||
branch_clean ${BTFHUB_DIR} | ||
branch_clean ${BTFHUB_ARCH_DIR} | ||
fi | ||
|
||
cd ${BTFHUB_DIR} | ||
|
||
|
||
# sync only supported kernels | ||
|
||
ARCH_EXCLUDE=$(printf "x86_64\naarch64\n" | grep -v $(uname -m) | xargs) | ||
rsync -avz \ | ||
${BTFHUB_ARCH_DIR}/ \ | ||
--exclude=.git* \ | ||
--exclude=README.md \ | ||
--exclude=${ARCH_EXCLUDE} \ | ||
--include='*ubuntu*' \ | ||
--include='*centos*' \ | ||
--include='*debian*' \ | ||
./archive/ | ||
|
||
# generate tailored BTFs | ||
|
||
[ ! -d ${BASEDIR}/bpf/custom-archive ] && mkdir -p ${BASEDIR}/bpf/custom-archive | ||
rm -rf ${BASEDIR}/bpf/custom-archive/* || true | ||
|
||
[ ! -f ./tools/btfgen.sh ] && die "could not find btfgen.sh" | ||
./tools/btfgen.sh -a $1 -o ${KYANOS_BPF_CORE} | ||
|
||
# move tailored BTFs to dist | ||
mv ./custom-archive/* ${BASEDIR}/bpf/custom-archive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.