-
Notifications
You must be signed in to change notification settings - Fork 8
feat: hash-based manual release workflow #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+275
−184
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b6c9cd9
feat: hash-based manual release workflow
ValentaTomas 725cae3
fix: preserve version_name in artifact, force checkout
ValentaTomas 9274f23
fix: hash only top-level *.patch files
ValentaTomas 1e82d8d
fix: align bash kernel_versions.txt parser with python
ValentaTomas 6c08a3f
refactor: simplify to "build everything, calver release per run"
ValentaTomas 583d298
fix: calver suffix sequence base, .1, .2 (was skipping .1)
ValentaTomas 8eab674
feat: also build on pull_request, gate publish on workflow_dispatch
ValentaTomas c167397
feat: parallelize build per (kernel_version, arch)
ValentaTomas ef204f4
fix: scope id-token to publish, harden version handling, idempotent c…
ValentaTomas fd2430a
fix: emit Build kernels (x86_64|arm64) checks for branch protection
ValentaTomas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| name: Manual Build & Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| kernel_versions: | ||
| description: 'Comma-separated kernel versions to build (default: kernel_versions.txt)' | ||
| required: false | ||
| type: string | ||
| default: '' | ||
|
ValentaTomas marked this conversation as resolved.
Outdated
|
||
| build_amd64: | ||
| description: 'Build for amd64 architecture' | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
| build_arm64: | ||
| description: 'Build for arm64 architecture' | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
|
|
||
| permissions: | ||
|
ValentaTomas marked this conversation as resolved.
|
||
| contents: write | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| validate: | ||
| runs-on: ubuntu-24.04 | ||
| outputs: | ||
| build_matrix: ${{ steps.validate.outputs.build_matrix }} | ||
| versions: ${{ steps.validate.outputs.versions }} | ||
| has_new_artifacts: ${{ steps.validate.outputs.has_new_artifacts }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - id: validate | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| python3 scripts/validate.py \ | ||
| --kernel-versions "${{ inputs.kernel_versions }}" \ | ||
| --build-amd64 "${{ inputs.build_amd64 }}" \ | ||
| --build-arm64 "${{ inputs.build_arm64 }}" | ||
|
|
||
| build: | ||
| needs: validate | ||
| if: needs.validate.outputs.has_new_artifacts == 'true' | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: ${{ fromJson(needs.validate.outputs.build_matrix) }} | ||
| runs-on: ${{ matrix.runner }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Build kernel ${{ matrix.version_name }} (${{ matrix.arch }}) | ||
| env: | ||
| VERSION_NAME: ${{ matrix.version_name }} | ||
| run: | | ||
| target_arch="${{ matrix.arch }}" | ||
| [ "$target_arch" = "amd64" ] && target_arch="x86_64" | ||
| sudo VERSION_NAME="$VERSION_NAME" ./build.sh "${{ matrix.kernel_version }}" "$target_arch" | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ matrix.version_name }}-${{ matrix.arch }} | ||
| path: ./builds | ||
| retention-days: 7 | ||
|
|
||
| publish: | ||
| needs: [validate, build] | ||
| if: needs.validate.outputs.has_new_artifacts == 'true' | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| path: ./builds | ||
| merge-multiple: true | ||
|
|
||
| - name: Show build artifacts | ||
| run: find ./builds -type f | head -50 | ||
|
|
||
| - name: Create or update releases | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| VERSIONS: ${{ needs.validate.outputs.versions }} | ||
| run: | | ||
| set -euo pipefail | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| echo "$VERSIONS" | jq -c '.[]' | while read -r entry; do | ||
| version_name=$(echo "$entry" | jq -r '.version_name') | ||
| kernel_version=$(echo "$entry" | jq -r '.kernel_version') | ||
|
|
||
| if ! gh release view "$version_name" >/dev/null 2>&1; then | ||
| if ! git rev-parse "refs/tags/$version_name" >/dev/null 2>&1; then | ||
| git tag "$version_name" | ||
| git push origin "$version_name" | ||
| fi | ||
| gh release create "$version_name" \ | ||
| --title "Kernel $version_name" \ | ||
| --notes "Linux kernel $kernel_version built from configs at ${{ github.sha }}" | ||
| fi | ||
|
|
||
| existing=$(gh release view "$version_name" --json assets -q '.assets[].name' || true) | ||
|
|
||
| for arch in amd64 arm64; do | ||
| local_path="./builds/$version_name/$arch/vmlinux.bin" | ||
| [ -f "$local_path" ] || continue | ||
|
|
||
| asset="vmlinux-${arch}.bin" | ||
| if echo "$existing" | grep -qx "$asset"; then | ||
| echo "Release $version_name: $asset exists, skipping" | ||
| else | ||
| tmp=$(mktemp -d)/$asset | ||
| cp "$local_path" "$tmp" | ||
| gh release upload "$version_name" "$tmp" | ||
| rm -f "$tmp" | ||
| fi | ||
|
|
||
| # Legacy non-arch-suffixed asset (amd64 only) for backwards compat. | ||
| if [ "$arch" = "amd64" ] && ! echo "$existing" | grep -qx "vmlinux.bin"; then | ||
| tmp=$(mktemp -d)/vmlinux.bin | ||
| cp "$local_path" "$tmp" | ||
| gh release upload "$version_name" "$tmp" | ||
| rm -f "$tmp" | ||
| fi | ||
| done | ||
| done | ||
|
|
||
| deploy: | ||
| needs: [validate, publish] | ||
| if: needs.validate.outputs.has_new_artifacts == 'true' | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: google-github-actions/auth@v2 | ||
| with: | ||
| workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} | ||
| service_account: ${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }} | ||
|
|
||
| - uses: google-github-actions/setup-gcloud@v2 | ||
|
|
||
| - name: Download release assets and upload to GCS | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| GCP_BUCKET_NAME: ${{ vars.GCP_BUCKET_NAME }} | ||
| VERSIONS: ${{ needs.validate.outputs.versions }} | ||
| run: | | ||
| set -euo pipefail | ||
| echo "$VERSIONS" | jq -c '.[]' | while read -r entry; do | ||
| version_name=$(echo "$entry" | jq -r '.version_name') | ||
|
|
||
| for arch in amd64 arm64; do | ||
| asset="vmlinux-${arch}.bin" | ||
|
ValentaTomas marked this conversation as resolved.
Outdated
|
||
| dl_dir="./dl/$version_name/$arch" | ||
| mkdir -p "$dl_dir" | ||
| if ! gh release download "$version_name" \ | ||
| --repo "${{ github.repository }}" \ | ||
| --pattern "$asset" \ | ||
| --output "$dl_dir/vmlinux.bin" 2>/dev/null; then | ||
| continue | ||
| fi | ||
|
|
||
| gcs_path="gs://${GCP_BUCKET_NAME}/kernels/${version_name}/${arch}/vmlinux.bin" | ||
| if gcloud storage ls "$gcs_path" >/dev/null 2>&1; then | ||
| echo "GCS: $gcs_path exists, skipping" | ||
| else | ||
| gcloud storage cp "$dl_dir/vmlinux.bin" "$gcs_path" | ||
| fi | ||
|
|
||
| # Legacy non-arch path (amd64 only) for backwards compat. | ||
| if [ "$arch" = "amd64" ]; then | ||
| legacy_path="gs://${GCP_BUCKET_NAME}/kernels/${version_name}/vmlinux.bin" | ||
| if gcloud storage ls "$legacy_path" >/dev/null 2>&1; then | ||
| echo "GCS: $legacy_path exists, skipping" | ||
| else | ||
| gcloud storage cp "$dl_dir/vmlinux.bin" "$legacy_path" | ||
| fi | ||
| fi | ||
| done | ||
| done | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.