-
Notifications
You must be signed in to change notification settings - Fork 1.7k
172 lines (162 loc) · 6.3 KB
/
Copy pathkernel-beta-update.yml
File metadata and controls
172 lines (162 loc) · 6.3 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
# Triggered when raspberrypi/firmware's extra/git_hash file changes,
# i.e. a new upstream firmware/kernel pair is being shipped to
# rpi-update. Kicks off a kernel beta build so
# the matching kernel .deb lands on public/beta automatically.
#
# Required secrets (org or repo level):
# GITLAB_URL GitLab instance URL.
# PACKAGING_TOKEN Project access token on the linux-packaging
# project: api scope, Maintainer role.
# BRIDGE_TOKEN Project access token on the bridge project:
# read_repository scope, Reporter role.
# PACKAGING_PROJECT linux-packaging project path on GitLab.
# BRIDGE_PROJECT Bridge tool's project path on GitLab.
# Required variables (org or repo level):
# KERNEL_SOURCE_PATH Path to the persistent raspberrypi/linux clone
# on the runner. Variable rather than secret
# because container.volumes is evaluated before
# the secrets context is available.
# CI_AUTHOR_NAME Name attributed to bridge-driven commits and
# the debian/changelog entry.
# CI_AUTHOR_EMAIL Email attributed to the same.
name: kernel beta update
on:
push:
branches: [master]
workflow_dispatch:
inputs:
ref:
description: 'Kernel ref to build (SHA, tag, or origin/branch). Blank = read extra/git_hash.'
required: false
type: string
dry_run:
description: 'Dry run (no rpi/update, no GitLab push)'
required: false
type: boolean
default: false
permissions:
contents: read
concurrency:
group: kernel-beta-update
cancel-in-progress: true
jobs:
# Gate the heavy trixie job on whether extra/git_hash actually moved.
# Compares the file's content at the push's parent and tip via
# raw.githubusercontent.com - no checkout needed, nothing touches the
# workspace.
detect:
runs-on: [self-hosted, linux, linux-bridge]
container:
image: debian:stable
outputs:
run: ${{ steps.check.outputs.run }}
steps:
- id: check
env:
BEFORE: ${{ github.event.before }}
AFTER: ${{ github.sha }}
REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
apt-get update -qq
apt-get install -y -qq --no-install-recommends ca-certificates curl
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "workflow_dispatch; proceeding"
echo "run=true" >> "$GITHUB_OUTPUT"
exit 0
fi
api="https://api.github.com/repos/$REPO/contents/extra/git_hash"
fetch() {
curl -fsSL \
-H "Authorization: Bearer $GH_TOKEN" \
-H "Accept: application/vnd.github.raw" \
"$api?ref=$1" | tr -d '[:space:]'
}
before=$(fetch "$BEFORE")
after=$(fetch "$AFTER")
echo "before='$before' after='$after'"
if [ -z "$before" ] || [ -z "$after" ]; then
echo "could not determine extra/git_hash; skipping (re-run manually if needed)"
echo "run=false" >> "$GITHUB_OUTPUT"
elif [ "$before" = "$after" ]; then
echo "extra/git_hash unchanged; skipping"
echo "run=false" >> "$GITHUB_OUTPUT"
else
echo "extra/git_hash changed; proceeding"
echo "run=true" >> "$GITHUB_OUTPUT"
fi
trixie:
needs: [detect]
if: needs.detect.outputs.run == 'true'
runs-on: [self-hosted, linux, linux-bridge]
timeout-minutes: 30
environment: beta-release
container:
image: debian:stable
volumes:
- ${{ vars.KERNEL_SOURCE_PATH }}:${{ vars.KERNEL_SOURCE_PATH }}
env:
GITLAB_BASE: ${{ secrets.GITLAB_URL }}
GITLAB_PROJECT: ${{ secrets.PACKAGING_PROJECT }}
GITLAB_TOKEN: ${{ secrets.PACKAGING_TOKEN }}
LINUX_SRC: ${{ vars.KERNEL_SOURCE_PATH }}
GIT_AUTHOR_NAME: ${{ vars.CI_AUTHOR_NAME }}
GIT_AUTHOR_EMAIL: ${{ vars.CI_AUTHOR_EMAIL }}
GIT_COMMITTER_NAME: ${{ vars.CI_AUTHOR_NAME }}
GIT_COMMITTER_EMAIL: ${{ vars.CI_AUTHOR_EMAIL }}
DEBFULLNAME: ${{ vars.CI_AUTHOR_NAME }}
DEBEMAIL: ${{ vars.CI_AUTHOR_EMAIL }}
steps:
# All file work happens under /build (container-local). The bind-mounted
# workspace stays empty so host-side cleanup never has to fight
# root-owned files left behind by the container.
- name: Install dependencies
run: |
apt-get update -qq
apt-get install -y -qq --no-install-recommends \
curl \
devscripts \
git \
git-buildpackage \
python3-minimal \
quilt
mkdir -p /build
- name: Sync bridge from GitLab
working-directory: /build
env:
BRIDGE_PROJECT: ${{ secrets.BRIDGE_PROJECT }}
BRIDGE_TOKEN: ${{ secrets.BRIDGE_TOKEN }}
run: |
host="${GITLAB_BASE#https://}"
clone_url="https://oauth2:${BRIDGE_TOKEN}@${host}/${BRIDGE_PROJECT}.git"
git clone --depth 1 "$clone_url" bridge
- name: Resolve kernel ref
id: kernel
working-directory: /build
run: |
if [ -n "${{ inputs.ref }}" ]; then
ref="${{ inputs.ref }}"
else
ref=$(curl -fsSL \
"https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/extra/git_hash" \
| tr -d '[:space:]')
fi
[ -n "$ref" ] || { echo "no kernel ref resolved" >&2; exit 1; }
echo "ref=$ref" >> "$GITHUB_OUTPUT"
- name: Sync linux-packaging from GitLab
working-directory: /build
run: |
host="${GITLAB_BASE#https://}"
clone_url="https://oauth2:${GITLAB_TOKEN}@${host}/${GITLAB_PROJECT}.git"
git clone "$clone_url" linux-packaging
- name: Run bridge
working-directory: /build
run: |
git config --global --add safe.directory "$LINUX_SRC"
git -C "$LINUX_SRC" fetch --all --tags --prune
./bridge/bridge beta \
${{ inputs.dry_run && '--dry-run' || '' }} \
--packaging ./linux-packaging \
--linux "$LINUX_SRC" \
--codename trixie \
"${{ steps.kernel.outputs.ref }}"