-
Notifications
You must be signed in to change notification settings - Fork 8
178 lines (162 loc) · 5.61 KB
/
release.yml
File metadata and controls
178 lines (162 loc) · 5.61 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
name: Build & Release
on:
workflow_dispatch:
pull_request:
permissions:
contents: read
jobs:
matrix:
runs-on: ubuntu-24.04
permissions:
contents: read
outputs:
build_matrix: ${{ steps.gen.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: gen
run: |
python3 - >> "$GITHUB_OUTPUT" <<'PY'
import json
import re
import sys
VERSION_RE = re.compile(r"^[0-9]+(?:\.[0-9]+)+$")
versions = []
for line in open("kernel_versions.txt").read().splitlines():
v = line.split("#", 1)[0].strip()
if not v:
continue
if not VERSION_RE.match(v):
sys.exit(f"::error::invalid kernel version in kernel_versions.txt: {v!r}")
versions.append(v)
include = []
for v in versions:
include.append({"version": v, "arch": "amd64", "target_arch": "x86_64", "runner": "ubuntu-24.04"})
include.append({"version": v, "arch": "arm64", "target_arch": "arm64", "runner": "ubuntu-24.04-arm"})
print(f"matrix={json.dumps({'include': include})}")
PY
build:
needs: matrix
name: Build ${{ matrix.version }} (${{ matrix.arch }})
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.build_matrix) }}
runs-on: ${{ matrix.runner }}
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Build kernel
env:
KERNEL_VERSION: ${{ matrix.version }}
KERNEL_TARGET_ARCH: ${{ matrix.target_arch }}
run: sudo ./build.sh "$KERNEL_VERSION" "$KERNEL_TARGET_ARCH"
- uses: actions/upload-artifact@v4
with:
name: kernel-${{ matrix.version }}-${{ matrix.arch }}
path: ./builds
retention-days: 7
# Aggregator with the exact name required by the `Main` ruleset on this
# repo. Per-(version, arch) jobs above run in parallel; this single check
# gates the whole arch on their combined success.
build-status:
needs: build
if: always()
name: Build kernels (${{ matrix.target_arch }})
strategy:
matrix:
target_arch: [x86_64, arm64]
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- run: |
if [[ "${{ needs.build.result }}" != "success" ]]; then
echo "build matrix did not succeed (result=${{ needs.build.result }})"
exit 1
fi
publish:
needs: build
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-24.04
permissions:
contents: write
outputs:
commit_hash: ${{ github.sha }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
path: ./builds
merge-multiple: true
- name: Prepare release assets
run: |
set -euo pipefail
mkdir -p release-assets
for dir in ./builds/vmlinux-*/; do
name=$(basename "$dir")
[ -f "$dir/amd64/vmlinux.bin" ] && cp "$dir/amd64/vmlinux.bin" "release-assets/${name}-amd64.bin"
[ -f "$dir/arm64/vmlinux.bin" ] && cp "$dir/arm64/vmlinux.bin" "release-assets/${name}-arm64.bin"
# Legacy non-arch-suffixed asset (= amd64) for backwards compat.
[ -f "$dir/vmlinux.bin" ] && cp "$dir/vmlinux.bin" "release-assets/${name}.bin"
done
ls -la release-assets/
- name: Pick calver tag
id: tag
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
base="$(date -u +%Y.%m.%d)"
tag="$base"
n=0
while gh release view "$tag" >/dev/null 2>&1 \
|| git rev-parse "refs/tags/$tag" >/dev/null 2>&1 \
|| git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null 2>&1; do
n=$((n + 1))
tag="${base}.${n}"
done
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "${{ steps.tag.outputs.tag }}"
git push origin "${{ steps.tag.outputs.tag }}"
gh release create "${{ steps.tag.outputs.tag }}" \
--title "Kernels ${{ steps.tag.outputs.tag }}" \
--notes "Built from commit ${{ github.sha }} on ${{ github.ref_name }}" \
./release-assets/*
deploy:
needs: publish
if: github.event_name == 'workflow_dispatch'
strategy:
fail-fast: false
matrix:
environment: [staging, juliett, foxtrot]
runs-on: ubuntu-24.04
environment: ${{ matrix.environment }}
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v2
with:
project_id: ${{ vars.GCP_PROJECT_ID }}
workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ vars.GCP_SERVICE_ACCOUNT }}
- uses: google-github-actions/setup-gcloud@v2
- name: Upload release to GCS
env:
GH_TOKEN: ${{ github.token }}
GCP_BUCKET_NAME: ${{ vars.GCP_BUCKET_NAME }}
run: |
./scripts/upload-release-to-gcs.sh \
--hash "${{ needs.publish.outputs.commit_hash }}" \
--bucket "${GCP_BUCKET_NAME}/kernels" \
--repo "${{ github.repository }}"