forked from linux-surface/linux-surface
-
Notifications
You must be signed in to change notification settings - Fork 0
196 lines (161 loc) · 5.49 KB
/
debian.yml
File metadata and controls
196 lines (161 loc) · 5.49 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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
on:
push:
tags:
- 'debian-*'
name: Debian
env:
GPG_KEY_ID: 56C464BAAC421453
KERNEL_VERSION: 5.13.7
KERNEL_REVISION: 1
LOCALVERSION: -surface
MAINLINE_REPO: git://git.launchpad.net/~ubuntu-kernel-test/ubuntu/+source/linux/+git/mainline-crack
MAINLINE_BRANCH: cod/mainline
TZ: UTC
jobs:
build:
name: Build Kernel
runs-on: ubuntu-latest
container: ubuntu:20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install build dependencies
run: |
sed 's/^deb /deb-src /' /etc/apt/sources.list >> /etc/apt/sources.list
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
echo $TZ > /etc/timezone
apt-get -y update
apt-get -y install build-essential fakeroot rsync git wget python3-debian dpkg-sig lz4 \
sbsigntool debhelper dpkg-dev zstd
apt-get -y build-dep linux
- name: Prepare kernel source
run: |
cd pkg/debian/kernel
# setup git
git config --global user.email "surfacebot@users.noreply.github.com"
git config --global user.name "surfacebot"
# get ubuntu mainline source
# see https://kernel.ubuntu.com/~kernel-ppa/mainline
git clone "$MAINLINE_REPO" --branch "$MAINLINE_BRANCH/v$KERNEL_VERSION" --single-branch linux
cd linux
# apply surface build/packaging patches
for PATCH in ../*.patch; do
git am -3 ${PATCH}
done
git add .
git commit --allow-empty -m "Apply linux-surface packaging patches"
# apply surface patches
for PATCH in ../../../../patches/${KERNEL_VERSION%.*}/*.patch; do
git am -3 ${PATCH}
done
git add .
git commit --allow-empty -m "Apply linux-surface patches"
- name: Configure
run: |
cd pkg/debian/kernel/linux
# merge configs
./scripts/kconfig/merge_config.sh \
debian.master/config/config.common.ubuntu \
debian.master/config/amd64/config.common.amd64 \
debian.master/config/amd64/config.flavour.generic \
../ubuntu.config \
../../../../configs/surface-${KERNEL_VERSION%.*}.config
# set revision
echo "$KERNEL_REVISION" > .version
- name: Setup secureboot certificate
env:
SB_KEY: ${{ secrets.SURFACE_SB_KEY }}
run: |
cd pkg
mkdir -p debian/kernel/linux/keys
# unlock/copy key and certificate
echo "$SB_KEY" | base64 -d > debian/kernel/linux/keys/MOK.key
cp keys/surface.crt debian/kernel/linux/keys/MOK.crt
- name: Build kernel
run: |
cd pkg/debian/kernel/linux
make bindeb-pkg -j2
- name: Build meta-package
run: |
cd pkg/debian/meta
./mkdebian.sh $(make -C ../kernel/linux -s kernelrelease) ${KERNEL_REVISION}
dpkg-buildpackage -b
- name: Prepare release
run: |
mkdir release
rm pkg/debian/kernel/linux-libc-dev*.deb
mv pkg/debian/kernel/*.deb release
mv pkg/debian/*.deb release
- name: Sign packages
env:
GPG_KEY: ${{ secrets.SURFACE_GPG_KEY }}
run: |
# import GPG key
echo "$GPG_KEY" | base64 -d | gpg --import --no-tty --batch --yes
export GPG_TTY=$(tty)
# sign package
dpkg-sig -g "--batch --no-tty" --sign builder -k $GPG_KEY_ID release/*.deb
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: debian-latest
path: release
release:
name: Publish release
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v1
with:
name: debian-latest
- name: Upload assets
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_BOT_TOKEN }}
file: ./*-latest/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
repo:
name: Update package repository
needs: [release]
runs-on: ubuntu-latest
container: debian:sid
steps:
- name: Install dependencies
run: |
apt-get update
apt-get install -y git
- name: Download artifacts
uses: actions/download-artifact@v1
with:
name: debian-latest
- name: Update repository
env:
SURFACEBOT_TOKEN: ${{ secrets.GITHUB_BOT_TOKEN }}
BRANCH_STAGING: u/staging
GIT_REF: ${{ github.ref }}
run: |
repo="https://surfacebot:${SURFACEBOT_TOKEN}@github.com/linux-surface/repo.git"
# clone package repository
git clone -b "${BRANCH_STAGING}" "${repo}" repo
# copy packages
cp debian-latest/* repo/debian/
cd repo/debian
# parse git tag from ref
GIT_TAG=$(echo $GIT_REF | sed 's|^refs/tags/||g')
# convert packages into references
for pkg in $(find . -name '*.deb'); do
echo "linux-surface:$GIT_TAG/$(basename $pkg)" > $pkg.blob
rm $pkg
done
# set git identity
git config --global user.email "surfacebot@users.noreply.github.com"
git config --global user.name "surfacebot"
# commit and push
update_branch="${BRANCH_STAGING}-$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
git switch -c "${update_branch}"
git add .
git commit -m "Update Debian kernel"
git push --set-upstream origin "${update_branch}"