-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (102 loc) · 3.73 KB
/
ci.yml
File metadata and controls
119 lines (102 loc) · 3.73 KB
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
117
118
119
name: Release Workflow
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Install GoReleaser
run: go install github.com/goreleaser/goreleaser@latest
- name: Check version
run: |
VERSION=$(cat VERSION.txt)
echo "version=$VERSION" >> $GITHUB_ENV
echo "Version: $VERSION"
- name: Run build using goreleaser on local
run: goreleaser release --snapshot --skip=publish --clean
- name: Create Tag
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'pull_request' &&
github.event.action == 'closed' &&
github.event.pull_request.merged == true &&
github.event.pull_request.base.ref == 'main')
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git tag "v${{ env.version }}"
git push origin "v${{ env.version }}"
- name: Run GoReleaser Release
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'pull_request' &&
github.event.action == 'closed' &&
github.event.pull_request.merged == true &&
github.event.pull_request.base.ref == 'main')
run: |
export GORELEASER_CURRENT_TAG="v${{ env.version }}"
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
goreleaser release --clean --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser Docker Push
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'pull_request' &&
github.event.action == 'closed' &&
github.event.pull_request.merged == true &&
github.event.pull_request.base.ref == 'main')
run: |
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
goreleaser release --rm-dist --skip-publish --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Download BPF object file
run: |
gh release download --repo SentinalFS/file-monitor --clobber --pattern "monitor.bpf.o"
- name: Decide to push or not
id: decide
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "PUSH=true" >> $GITHUB_ENV
else
echo "PUSH=false" >> $GITHUB_ENV
fi
- name: Build Image
if: env.PUSH == 'false'
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
--build-arg TARGETARCH=amd64 \
--file Dockerfile \
-t siddh34/go-ebpf-logger:latest \
-f Dockerfile64.amd64 .
- name: Login to DockerHub
if: env.PUSH == 'true'
run: echo "${{ secrets.DOCKER_ACCESS_TOKEN }}" | docker login -u "siddh34" --password-stdin
- name: Build & Push Docker images
if: env.PUSH == 'true'
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
--file Dockerfile \
--push \
-t siddh34/go-ebpf-logger:latest \
-f Dockerfile64.amd64 .