-
Notifications
You must be signed in to change notification settings - Fork 255
157 lines (144 loc) · 4.87 KB
/
deb.yml
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Build package
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
concurrency:
group: deb-${{ github.ref }}
cancel-in-progress: true
jobs:
deb:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
container:
- "debian:bullseye"
- "debian:bookworm"
- "ubuntu:jammy"
- "ubuntu:noble"
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Generate variables
id: gen_vars
run: |
XEN_COMMIT=$(git ls-tree HEAD xen | cut -f3 '-d ' | cut -f1 -d$'\t')
echo "Xen commit: $XEN_COMMIT"
echo xen_commit=${XEN_COMMIT} >> $GITHUB_OUTPUT
CONTAINER=$(echo ${{ matrix.container }} | tr -d ":")
echo "container=$CONTAINER" >> $GITHUB_OUTPUT
DRAKVUFVERSION=$(./scripts/version.sh --dev)
echo "DRAKVUF version: $DRAKVUFVERSION"
echo "drakvufversion=$DRAKVUFVERSION" >> $GITHUB_OUTPUT
XENVERSION=$(./xen/version.sh --full ./xen/xen/Makefile)
echo "Xen version: $XENVERSION"
echo "xenversion=$XENVERSION" >> $GITHUB_OUTPUT
- name: Cache Xen intermediate
uses: actions/cache@v4
with:
path: |
package/cache
key: xen-${{ matrix.container }}-${{ steps.gen_vars.outputs.xen_commit }}-v7
- name: Build package
id: build_drakvuf_deb
run: |
sh package/build.sh "${{ matrix.container }}" "${{ steps.gen_vars.outputs.drakvufversion }}" "${{ steps.gen_vars.outputs.xenversion }}"
DRAKVUF_DEB_PATH=$(find package/out/drakvuf*.deb | head -n1)
XEN_DEB_PATH=$(find package/out/xen*.deb | head -n1)
if [ ! -z $DRAKVUF_DEB_PATH ]; then
cp $DRAKVUF_DEB_PATH ${{ github.workspace}}
fi
if [ ! -z $XEN_DEB_PATH ]; then
cp $XEN_DEB_PATH ${{ github.workspace }}
fi
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.gen_vars.outputs.container }}-debs
path: ${{ github.workspace }}/*.deb
release:
needs: [deb]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/download-artifact@v4
- name: Generate variables
id: gen_vars
run: |
echo short_sha=$(echo ${GITHUB_SHA} | cut -c1-8) >> $GITHUB_OUTPUT
echo cur_datetime=$(date '+%Y-%m-%d %H:%M:%S') >> $GITHUB_OUTPUT
- name: Delete old release
uses: dev-drprasad/delete-older-releases@5494cd8b61c31b3c7a15f6267901195ec7df64e8 # pin 0.3.2
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
repo: tklengyel/drakvuf-builds
keep_latest: 0
delete_tags: true
- name: Create a Release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
release_tag="build-${{ github.sha }}"
title="DRAKVUF ${{ steps.gen_vars.outputs.cur_datetime }} ${{ steps.gen_vars.outputs.short_sha }}"
gh release create $release_tag --notes "Automated build" -R tklengyel/drakvuf-builds -t "$title"
for deb in $(find . -name "*.deb"); do
gh release upload $release_tag $deb -R tklengyel/drakvuf-builds
done
install:
needs: [deb]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
container:
- "debian:bullseye"
- "debian:bookworm"
- "ubuntu:jammy"
- "ubuntu:noble"
container:
image: ${{ matrix.container}}
steps:
- uses: actions/checkout@v4
- id: gen_vars
run: |
CONTAINER=$(echo ${{ matrix.container }} | tr -d ":")
echo "container=$CONTAINER" >> $GITHUB_OUTPUT
- uses: actions/download-artifact@v4
with:
name: ${{ steps.gen_vars.outputs.container }}-debs
path: ~/debs
- name: install
run: ./scripts/install.sh ~/debs
registry:
needs: [deb]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: actions/download-artifact@v4
with:
name: debianbullseye-debs
path: debs
- name: remove xen
run: rm debs/*xen*
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: package/Dockerfile-registry
push: true
tags: tklengyel/drakvuf:latest
cache-from: type=gha
cache-to: type=gha,mode=max